MediaWiki API help
This is an auto-generated MediaWiki Action API documentation page.
General information
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.
Request methods
Action API requests may use GET and POST methods. Prefer using the GET method, which allows requests to be routed to faster replica servers and responses to be cached, unless the length of the URL with parameters would exceed its length limit (commonly 8000 bytes), or a module only accepts POST requests.
Parameters for POST requests may be sent in the query part of the request URL (like in GET requests) and in the POST request body, and mixing both ways in one request is allowed. Certain parameters such as passwords must be sent in the request body. If the same parameter is sent as part of the URL and also in the request body, it must have the same value in both places.
Data types
Input to MediaWiki should be NFC-normalized UTF-8. MediaWiki may attempt to convert other input, but this may cause some operations (such as edits with MD5 checks) to fail.
Parameters that take multiple values are normally submitted with the values separated using the pipe character, e.g. param=value1|value2 or param=value1%7Cvalue2. If a value must contain the pipe character, use U+001F (Unit Separator) as the separator and prefix the value with U+001F, e.g. param=%1Fvalue1%1Fvalue2.
Some parameter types in API requests need further explanation:
- boolean
Boolean parameters work like HTML checkboxes: if the parameter is specified, regardless of value, it is considered true. For a false value, omit the parameter entirely.
- expiry
Expiry values may be relative (e.g. 5 months or 2 weeks) or absolute (e.g. 2014-09-18T12:34:56Z). For no expiry, use infinite, indefinite, infinity or never.
- timestamp
Timestamps may be specified in several formats, see the Timestamp library input formats documented on mediawiki.org for details. ISO 8601 date and time is recommended: 2001-01-15T14:56:00Z. The string now may be used to specify the current time.
Limits
Most API modules can accept up to 50 inputs in multivalue parameters, and can return up to 500 results per query (50 results for slow queries).
For users with the apihighlimits right (Bots and Administrators), the limits are increased to 500 inputs and 5,000 results (500 results for slow queries).
Templated parameters
Templated parameters support cases where an API module needs a value for each value of some other parameter. For example, if there were an API module to request fruit, it might have a parameter fruits to specify which fruits are being requested and a templated parameter {fruit}-quantity to specify how many of each fruit to request. An API client that wants 1 apple, 5 bananas, and 20 strawberries could then make a request like fruits=apples|bananas|strawberries&apples-quantity=1&bananas-quantity=5&strawberries-quantity=20.
Main module
- Source: MediaWiki
- License: GPL-2.0-or-later
Specify the action to perform, the format of the response, and options that apply to all API modules.
- action
Which action to perform. This parameter should be sent as part of the request URL (not the POST body) for ease of use in debugging, analytics, and request routing or filtering.
- abusefiltercheckmatch
- Check to see if an AbuseFilter matches a set of variables, an edit, or a logged AbuseFilter event.
- abusefilterchecksyntax
- Check syntax of an AbuseFilter filter.
- abusefilterevalexpression
- Evaluates an AbuseFilter expression.
- abusefilterunblockautopromote
- Unblocks a user from receiving autopromotions due to an abusefilter consequence.
- abuselogprivatedetails
- View private details of an AbuseLog entry.
- acquiretempusername
- Acquire a temporary user username and stash it in the current session, if temp account creation is enabled and the current user is logged out. If a name has already been stashed, returns the same name.
- block
- Block a user.
- changeauthenticationdata
- Change authentication data for the current user.
- changecontentmodel
- Change the content model of a page
- checktoken
- Check the validity of a token from action=query&meta=tokens.
- clearhasmsg
- Clears the
hasmsgflag for the current user. - clientlogin
- Log in to the wiki using the interactive flow.
- compare
- Get the difference between two pages.
- createaccount
- Create a new user account.
- csdeletecomment
- Delete a comment. Either pageid or title must be provided.
- csdeletereply
- Delete a reply. Either pageid or title must be provided.
- cseditcomment
- Edit an existing comment. Either pageid or title must be provided.
- cseditreply
- Edit an existing reply. Either pageid or title must be provided.
- cspostcomment
- Post a new comment.
- cspostreply
- Post a new reply.
- cspreviewcomment
- Preview comment wikitext as HTML without posting a comment.
- csquerycomment
- Return details of a comment. Either pageid or title must be provided.
- csqueryreply
- Return details of a reply. Either pageid or title must be provided.
- csunwatch
- Unwatch a comment to no longer be notified when it receives replies
- csvote
- Vote (up, down, or neutral) on a comment.
- cswatch
- Watch a comment to be notified when it receives replies
- delete
- Delete a page.
- detectfileextension
- Detect a supported image or PDF extension from a URL or its Content-Type header.
- echocreateevent
- Manually trigger a notification to a user
- echomarkread
- Mark notifications as read for the current user.
- echomarkseen
- Mark notifications as seen for the current user.
- echomute
- Mute or unmute notifications from certain users or pages.
- edit
- Create and edit pages.
- emailuser
- Email a user.
- expandtemplates
- Expands all templates within wikitext.
- favorite
- Add or remove a page from/to the current user's favorite list
- feedcontributions
- Returns a user's contributions feed.
- feedrecentchanges
- Returns a recent changes feed.
- feedwatchlist
- Returns a watchlist feed.
- filerevert
- Revert a file to an old version.
- help
- Display help for the specified modules.
- imagerotate
- Rotate one or more images.
- import
- Import a page from another wiki, or from an XML file.
- languagesearch
- Search for language names in any script.
- linkaccount
- Link an account from a third-party provider to the current user.
- login
- Log in and get authentication cookies.
- logout
- Log out and clear session data.
- managetags
- Perform management tasks relating to change tags.
- mdbnames
- Resolve case-insensitive MixesDB category names and return their canonical title, type, and mix count.
- mergehistory
- Merge page histories.
- mixesdb_player_search
- Find MixesDB pages containing a player URL.
- mixesdbaddmixtemplate
- Render an AddMix template preview without saving a page.
- mixesdbeditformatreview
- Review proposed mix-page wikitext and return formatting suggestions without saving.
- mixesdbnativeplayer
- Render a player preview and return its HTML and required ResourceLoader modules.
- mixesdbnewmixes
- Get the next fixed batch of latest mixes.
- mixesdbplayerhealthaction
- Preview, recheck, replace, comment out, or add a replacement for a page player.
- mixesdbplayerhealthreview
- Accept, reject, or undo proposed player replacements.
- mixesdbplayerhealthsearch
- Search a provider for replacements for a broken player URL.
- mixesdbremotehelp
- Get rendered README help or userscript version metadata from a configured source.
- mixesdbrenderlinks
- Render local page titles as MediaWiki HTML links.
- mixesdbsearchjsonld
- Search MixesDB and return structured results with JSON-LD metadata.
- mixesdbsearchmeta
- List supported MixesDB search keywords, context groups, and sort orders.
- mixesdbsearchresultshtml
- Search MixesDB and return rendered result HTML.
- mixesdbsearchtypeahead
- Suggest values for a MixesDB search field.
- mixesdbtrackid
- Retrieve cached TrackId data or link a cached player URL to a MixesDB page.
- mixesdbtrackidbatch
- Retrieve cached TrackId data and linked pages for multiple player URLs.
- mixesdbtrackidquery
- Browse cached TrackId rows with filtering, sorting, and pagination.
- mixesdbtrackidrefresh
- Refresh an existing cached TrackId record from the TrackId API.
- mixesdbtrackidupdate
- Process inbound TrackId email notifications and update the cached last-parsed timestamp.
- mixesdbuserlinks
- Get safe, viewer-specific decorations for user contribution links.
- move
- Move a page.
- ogg_to_mp3
- Convert an uploaded OGG audio file to an MP3 fallback.
- opensearch
- Search the wiki using the OpenSearch protocol.
- options
- Change preferences of the current user.
- paraminfo
- Obtain information about API modules.
- parse
- Parses content and returns parser output.
- patrol
- Patrol a page or revision.
- protect
- Change the protection level of a page.
- purge
- Purge the cache for the given titles.
- query
- Fetch data from and about MediaWiki.
- removeauthenticationdata
- Remove authentication data for the current user.
- resetpassword
- Send a password reset email to a user.
- revisiondelete
- Delete and undelete revisions.
- rollback
- Undo the last edit to the page.
- rsd
- Export an RSD (Really Simple Discovery) schema.
- scaleway_webhook
- Receive Scaleway email bounce notifications.
- setnotificationtimestamp
- Update the notification timestamp for watched pages.
- setpagelanguage
- Change the language of a page.
- soundcloud
- Authorize the SoundCloud integration or synchronize its playlists.
- tag
- Add or remove change tags from individual revisions or log entries.
- thank
- Send a thank-you notification to an editor.
- titleblacklist
- Validate a page title, filename, or username against the TitleBlacklist.
- tracklist_api
- Look up cached track matches or update track-to-YouTube associations.
- tracklist_api_batch
- Run multiple track lookup or association requests in one call.
- unblock
- Unblock a user.
- undelete
- Undelete revisions of a deleted page.
- unlinkaccount
- Remove a linked third-party account from the current user.
- upload
- Upload a file, or get the status of pending uploads.
- userrights
- Change a user's group membership.
- validatepassword
- Validate a password against the wiki's password policies.
- watch
- Add or remove pages from the current user's watchlist.
- youtube_search
- Search YouTube through the cached MixesDB search proxy.
- cirrus-check-sanity
- Internal. Reports on the correctness of a range of page ids in the search index
- cirrus-config-dump
- Internal. Dump of CirrusSearch configuration.
- cirrus-profiles-dump
- Internal. Dump of CirrusSearch profiles for this wiki.
- cirrus-schema-dump
- Internal. Dump of CirrusSearch schema (settings and mappings) for this wiki.
- cspreport
- 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.
- stashedit
- Internal. Prepare an edit in shared cache.
- One of the following values: abusefiltercheckmatch, abusefilterchecksyntax, abusefilterevalexpression, abusefilterunblockautopromote, abuselogprivatedetails, acquiretempusername, block, changeauthenticationdata, changecontentmodel, checktoken, clearhasmsg, clientlogin, compare, createaccount, csdeletecomment, csdeletereply, cseditcomment, cseditreply, cspostcomment, cspostreply, cspreviewcomment, csquerycomment, csqueryreply, csunwatch, csvote, cswatch, delete, detectfileextension, echocreateevent, echomarkread, echomarkseen, echomute, edit, emailuser, expandtemplates, favorite, feedcontributions, feedrecentchanges, feedwatchlist, filerevert, help, imagerotate, import, languagesearch, linkaccount, login, logout, managetags, mdbnames, mergehistory, mixesdb_player_search, mixesdbaddmixtemplate, mixesdbeditformatreview, mixesdbnativeplayer, mixesdbnewmixes, mixesdbplayerhealthaction, mixesdbplayerhealthreview, mixesdbplayerhealthsearch, mixesdbremotehelp, mixesdbrenderlinks, mixesdbsearchjsonld, mixesdbsearchmeta, mixesdbsearchresultshtml, mixesdbsearchtypeahead, mixesdbtrackid, mixesdbtrackidbatch, mixesdbtrackidquery, mixesdbtrackidrefresh, mixesdbtrackidupdate, mixesdbuserlinks, move, ogg_to_mp3, opensearch, options, paraminfo, parse, patrol, protect, purge, query, removeauthenticationdata, resetpassword, revisiondelete, rollback, rsd, scaleway_webhook, setnotificationtimestamp, setpagelanguage, soundcloud, tag, thank, titleblacklist, tracklist_api, tracklist_api_batch, unblock, undelete, unlinkaccount, upload, userrights, validatepassword, watch, youtube_search, cirrus-check-sanity, cirrus-config-dump, cirrus-profiles-dump, cirrus-schema-dump, cspreport, stashedit
- 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-maxageHTTP cache control header to this many seconds. Errors are never cached.- Type: integer
- The value must be no less than 0.
- Default: 0
- maxage
Set the
max-ageHTTP cache control header to this many seconds. Errors are never cached.- Type: integer
- The value must be no less than 0.
- Default: 0
- assert
Verify that the user is logged in (including possibly as a temporary user) 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 any of username and Temporary user
- 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 URL (not the POST body).
For authenticated requests, this must match one of the origins in the
Originheader exactly, so it has to be set to something like en.wikipedia.org or meta.wikimedia.org. If this parameter does not match theOriginheader, a 403 response will be returned. If this parameter matches theOriginheader and the origin is allowed, theAccess-Control-Allow-OriginandAccess-Control-Allow-Credentialsheaders will be set.For non-authenticated requests, specify the value *. This will cause the
Access-Control-Allow-Originheader to be set, butAccess-Control-Allow-Credentialswill befalseand all user-specific data will be restricted.- crossorigin
When accessing the API using a cross-domain AJAX request (CORS) and using a session provider that is safe against cross-site request forgery (CSRF) attacks (such as OAuth), use this instead of
origin=*to make the request authenticated (i.e., not logged out). This must be included in any pre-flight request, and therefore must be part of the request URL (not the POST body).Note that most session providers, including standard cookie-based sessions, do not support authenticated CORS and cannot be used with this parameter.
- Type: boolean (details)
- uselang
Language to use for message translations. action=query&meta=siteinfo&siprop=languages returns a list of language codes. You can specify user to use the current user's language preference or content to use this wiki's content language.
- Default: user
- variant
Variant of the language. Only works if the base language supports variant conversion.
- 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&siprop=languages returns a list of language codes. Specify content to use this wiki's content language or 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)
- Help for the main module.
- api.php?action=help [open in sandbox]
- All help in one page.
- api.php?action=help&recursivesubmodules=1&toc [open in sandbox]
Credits
API developers:
- Yuri Astrakhan (creator, lead developer Sep 2006–Sep 2007)
- Roan Kattouw (lead developer Sep 2007–2009)
- Victor Vasiliev
- Bryan Tong Minh
- Sam Reed
- Brad Jorsch (lead developer 2013–2020)
Please send your comments, suggestions and questions to [email protected] or file a bug report at phabricator.wikimedia.org/.