API:Main page - MediaWiki
API:Main page
Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎Esperanto • ‎Nederlands • ‎Taqbaylit • ‎Tiếng Việt • ‎Türkçe • ‎azərbaycanca • ‎català • ‎dansk • ‎español • ‎français • ‎italiano • ‎latviešu • ‎lietuvių • ‎polski • ‎português • ‎português do Brasil • ‎română • ‎svenska • ‎čeština • ‎български • ‎русский • ‎українська • ‎עברית • ‎اردو • ‎العربية • ‎فارسی • ‎پښتو • ‎मराठी • ‎हिन्दी • ‎ಕನ್ನಡ • ‎ไทย • ‎中文 • ‎文言 • ‎日本語 • ‎粵語 • ‎ꯃꯤꯇꯩ ꯂꯣꯟ • ‎한국어
This page is part of the MediaWiki Action API documentation.
Overview
This page provides an overview of the MediaWiki Action API. This page is intended for technical contributors and software developers who wish to understand and use the MediaWiki Action API.
Quick Start
Endpoint
All Wikimedia wikis have endpoints that follow this pattern:​https://www.example.org/w/api.php
Examples of Wikimedia Wiki Endpoints
API EndpointWiki
MediaWiki API
Meta-Wiki API
English Wikipedia API
Dutch Wikipedia API
Wikimedia Commons API
https://test.wikipedia.org/w/api.phpTest Wiki API
Introduction
The MediaWiki Action API is a web service that allows access to some wiki-features like authentication, page operations, and search. It can provide meta information about the wiki and the logged-in user.
Uses for the MediaWiki Action API
Getting started with MediaWiki Action API
Before you start using the MediaWiki Action API, you should review the following pages:
API documentation
The following documentation is the output of Special:ApiHelp/main​, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).
Main module
Documentation​Etiquette & usage guidelines FAQMailing list API AnnouncementsBugs & requests
Status: The MediaWiki API is a mature and stable interface that is actively supported and improved. While we try to avoid it, we may occasionally need to make breaking changes; subscribe to the mediawiki-api-announce mailing list for notice of updates.
Erroneous requests: When erroneous requests are sent to the API, an HTTP header will be sent with the key "MediaWiki-API-Error" and then both the value of the header and the error code sent back will be set to the same value. For more information see API: Errors and warnings.
Testing: For ease of testing API requests, see Special:ApiSandbox.
Parameters:
action
Which action to perform.
Check to see if an AbuseFilter matches a set of variables, an edit, or a logged AbuseFilter event.
Check syntax of an AbuseFilter filter.
Evaluates an AbuseFilter expression.
Unblocks a user from receiving autopromotions due to an abusefilter consequence.
View private details of an AbuseLog entry.
Manage aggregate message groups.
Check a username against AntiSpoof's normalisation checks.
Block a user.
Fetch a centralauthtoken for making an authenticated request to an attached wiki.
Request the purge of banner content stored in the CDN (front-end) cache for anonymous users, for the requested banner and language
Get data needed to choose a banner for a given project and language
Get all configuration settings for a campaign.
Change authentication data for the current user.
Change the content model of a page
Check the validity of a token from action=query&meta=tokens​.
Dump of CirrusSearch configuration.
Dump of CirrusSearch mapping for this wiki.
Dump of CirrusSearch profiles for this wiki.
Dump of CirrusSearch settings for this wiki.
Clears the hasmsg flag for the current user.
Log in to the wiki using the interactive flow.
Fetch formatted diff from CodeReview's backing revision control system.
Submit comments, new status and tags to a revision.
Update CodeReview repository data from master revision control system.
Get the difference between two pages.
Create a new user account.
Forcibly create a local account
Delete a page.
Delete a global user.
Mark notifications as read for the current user.
Mark notifications as seen for the current user.
Mute or unmute notifications from certain users or pages.
Create and edit pages.
Edit a mass message delivery list.
Email a user.
Expands all templates within wikitext.
Get a new FancyCaptcha.
Returns a featured content feed.
Returns a user's contributions feed.
Returns a recent changes feed.
Return a feed of discussion threads.
Returns a watchlist feed.
Revert a file to an old version.
Allows actions to be taken on Structured Discussions pages.
Convert text between wikitext and HTML.
Send a public thank-you notification for a Flow comment.
Globally block or unblock a user.
Change local overrides for global preferences for the current user.
Change global preferences of the current user.
Add/remove a user to/from global groups.
Access graph tag functionality.
Set message group workflow states.
Display help for the specified modules.
This module has been disabled.
Import a page from another wiki, or from an XML file.
Allows direct access to JsonConfig subsystem.
Search for language names in any script.
Link an account from a third-party provider to the current user.
Log in and get authentication cookies.
Log out and clear session data.
Perform management tasks relating to change tags.
Send a message to a list of pages.
Merge page histories.
Move a page.
Subscribe to or unsubscribe from a newsletter.
Search the wiki using the OpenSearch protocol.
Change preferences of the current user.
Obtain information about API modules.
Parses content and returns parser output.
Patrol a page or revision.
Change the protection level of a page.
Purge the cache for the given titles.
Fetch data from and about MediaWiki.
Remove authentication data for the current user.
Send a password reset email to a user.
Delete and undelete revisions.
Undo the last edit to the page.
Export an RSD (Really Simple Discovery) schema.
Search translations.
Set a global user's status.
Update the notification timestamp for watched pages.
Change the language of a page.
Shorten a long URL into a shorter one.
Get Wikimedia sites list.
Validate one or more URLs against the SpamBlacklist.
Exposes event stream config. Returns only format=json with formatversion=2.
Allows admins to strike or unstrike a vote.
Add or remove change tags from individual revisions or log entries.
Fetch data stored by the TemplateData extension.
Send a thank-you notification to an editor.
Allows actions to be taken on threads and posts in threaded discussions.
Validate a page title, filename, or username against the TitleBlacklist.
Users with the 'transcode-reset' right can reset and re-run a transcode job.
Query all translations aids.
Mark translations reviewed.
Fetch translation statistics
Query suggestions from translation memories.
Unblock a user.
Restore revisions of a deleted page.
Remove a linked third-party account from the current user.
Upload a file, or get the status of pending uploads.
Change a user's group membership.
Validate a password against the wiki's password policies.
Add or remove pages from the current user's watchlist.
Returns a webapp manifest.
API Module to communicate between server and client during registration/authentication process
Give WikiLove to another user.
Deprecated. Returns data needed for mobile views.
Deprecated. Get tokens for data-modifying actions.
Internal. Receive a bounce email and process it to handle the failing recipient.
Internal. Internal module for the CategoryTree extension.
Internal. Used by browsers to report violations of the Content Security Policy. This module should never be used, except when used automatically by a CSP compliant web browser.
Internal. Returns metadata required to initialize the discussion tools.
Internal. Post a message on a discussion page.
Internal. Subscribe (or unsubscribe) to receive notifications about a topic.
Internal. Retrieve localized JSON data.
Internal. Manage group synchronization cache.
Internal. Add a message as a rename of an existing message or a new message in the group during imports
Internal. Validate a two-factor authentication (OATH) token.
Internal. Reading list write operations.
Internal. Record a lint error in the database
Internal. Performs data validation for Kartographer extension
Internal. Internal module for servicing XHR requests from the Scribunto console.
Internal. Prepare an edit in shared cache.
Internal. Provides timed text content for usage by <track> elements
Internal. Validate translations.
Internal. Get the localization of ULS in the given language.
Internal. Update user's preferred interface language.
Internal. Returns HTML5 for a page from the Parsoid service.
visualeditoredit
Internal. Save an HTML5 page to MediaWiki (converted to wikitext via the Parsoid service).
One of the following values: abusefiltercheckmatch​, abusefilterchecksyntax​, abusefilterevalexpression​, abusefilterunblockautopromote​, abuselogprivatedetails​, aggregategroups, antispoof, block, centralauthtoken, centralnoticecdncacheupdatebanner​, centralnoticechoicedata​, centralnoticequerycampaign​, changeauthenticationdata​, changecontentmodel, checktoken, cirrus-config-dump, cirrus-mapping-dump, cirrus-profiles-dump, cirrus-settings-dump, clearhasmsg, clientlogin, codediff, coderevisionupdate, codeupdate, compare, createaccount, createlocalaccount, delete, deleteglobalaccount, echomarkread, echomarkseen, echomute, edit, editmassmessagelist, emailuser, expandtemplates, fancycaptchareload, featuredfeed, feedcontributions, feedrecentchanges, feedthreads, feedwatchlist, filerevert, flow-parsoid-utils, flow, flowthank, globalblock, globalpreferenceoverrides​, globalpreferences, globaluserrights, graph, groupreview, help, imagerotate, import, jsonconfig, languagesearch, linkaccount, login, logout, managetags, massmessage, mergehistory, move, newslettersubscribe, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata​, resetpassword, revisiondelete, rollback, rsd, searchtranslations, setglobalaccountstatus​, setnotificationtimestamp​, setpagelanguage, shortenurl, sitematrix, spamblacklist, streamconfigs, strikevote, tag, templatedata, thank, threadaction, titleblacklist, transcodereset, translationaids, translationreview, translationstats, ttmserver, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, webapp-manifest, webauthn, wikilove, mobileview, tokens, bouncehandler, categorytree, cspreport, discussiontools, discussiontoolsedit, discussiontoolssubscribe​, jsondata, managegroupsynchronizationcache​, managemessagegroups​, oathvalidate, readinglists, record-lint, sanitize-mapdata, scribunto-console, stashedit, timedtext, translationcheck, ulslocalization, ulssetlang, visualeditor, visualeditoredit
Default: help
format
The format of the output.
json
Output data in JSON format.
jsonfm
Output data in JSON format (pretty-print in HTML).
none
Output nothing.
php
Output data in serialized PHP format.
phpfm
Output data in serialized PHP format (pretty-print in HTML).
rawfm
Output data, including debugging elements, in JSON format (pretty-print in HTML).
xml
Output data in XML format.
xmlfm
Output data in XML format (pretty-print in HTML).
One of the following values: json, jsonfm, none, php, phpfm, rawfm, xml, xmlfm
Default: jsonfm
maxlag
Maximum lag can be used when MediaWiki is installed on a database replicated cluster. To save actions causing any more site replication lag, this parameter can make the client wait until the replication lag is less than the specified value. In case of excessive lag, error code maxlag is returned with a message like Waiting for $host: $lag seconds lagged.
See Manual: Maxlag parameter for more information.
Type: integer
smaxage
Set the s-maxage HTTP cache control header to this many seconds. Errors are never cached.
Type: integer
Default: 0
maxage
Set the max-age HTTP cache control header to this many seconds. Errors are never cached.
Type: integer
Default: 0
assert
Verify that the user is logged in if set to user, not logged in if set to anon, or has the bot user right if bot.
One of the following values: anon, bot, user
assertuser
Verify the current user is the named user.
Type: user, by user name
requestid
Any value given here will be included in the response. May be used to distinguish requests.
servedby
Include the hostname that served the request in the results.
Type: boolean (details)
curtimestamp
Include the current timestamp in the result.
Type: boolean (details)
responselanginfo
Include the languages used for uselang and errorlang in the result.
Type: boolean (details)
origin
When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain. This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body).
For authenticated requests, this must match one of the origins in the Origin header exactly, so it has to be set to something like https://en.wikipedia.org or https://meta.wikimedia.org​. If this parameter does not match the Origin header, a 403 response will be returned. If this parameter matches the Origin header and the origin is allowed, the Access-Control-Allow-Origin and Access-Control-Allow-Credentials headers will be set.
For non-authenticated requests, specify the value *. This will cause the Access-Control-Allow-Origin header to be set, but Access-Control-Allow-Credentials will be false and all user-specific data will be restricted.
uselang
Language to use for message translations. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify user to use the current user's language preference, or specify content to use this wiki's content language.
Default: user
errorformat
Format to use for warning and error text output.
plaintext
Wikitext with HTML tags removed and entities replaced.
wikitext
Unparsed wikitext.
html
HTML.
raw
Message key and parameters.
none
No text output, only the error codes.
bc
Format used prior to MediaWiki 1.29. errorlang and errorsuselocal are ignored.
One of the following values: bc, html, none, plaintext, raw, wikitext
Default: bc
errorlang
Language to use for warnings and errors. action=query&meta=siteinfo with siprop=languages returns a list of language codes, or specify content to use this wiki's content language, or specify uselang to use the same value as the uselang parameter.
Default: uselang
errorsuselocal
If given, error texts will use locally-customized messages from the MediaWiki namespace.
Type: boolean (details)
centralauthtoken
When accessing the API using a cross-domain AJAX request (CORS), use this to authenticate as the current SUL user. Use action=centralauthtoken on this wiki to retrieve the token, before making the CORS request. Each token may only be used once, and expires after 10 seconds. This should be included in any pre-flight request, and therefore should be included in the request URI (not the POST body).
Examples:
Help for the main module.
api.php?action=help [open in sandbox]
All help in one page.
api.php?action=help&recursivesubmodules=1 [open in sandbox]
Permissions:
writeapi
Use of the write API
Granted to: all, user and bot
apihighlimits
Use higher limits in API queries (slow queries: 500; fast queries: 5000). The limits for slow queries also apply to multivalue parameters.
Granted to: bot and sysop
Other APIs
If you do not find what you are looking for in this API documentation, there are many other APIs related to Wikimedia projects. See the Web APIs hub for information on other APIs for Wikimedia project data and their usage.
For the REST API included with MediaWiki 1.35 and later, see API:REST API.
Code stewardship
This page or project is maintained by Core Platform Team.
Get help:
Last edited on 16 June 2021, at 19:15
Content is available under CC BY-SA 3.0 unless otherwise noted.
Privacy policy
Terms of Use
Desktop
HomeRandomLog inSettingsDonateAbout MediaWiki.orgDisclaimers
LanguageWatchEdit