Main module

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.

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 the user is logged in if set to user, or has the bot user right if bot.

One of the following values: user, bot

assertuser

Verify the current user is the named user.

Type: user name

requestid

Any value given here will be included in the response. May be used to distinguish requests.

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 whitelisted, 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: plaintext, wikitext, html, raw, none, bc

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.

Seconds since 1970-01-01T00:00:00Z as a 1 to 13 digit integer (excluding 0)

The string now

alternative multiple-value separator

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.

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.