MediaWiki API help

Main module

Status: All features shown on this page should be working, but the API is still in active development, and may change at any time. 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.

smaxage

Set the s-maxage header to this many seconds. Errors are never cached.

Default: 0

maxage

Set the max-age header to this many seconds. Errors are never cached.

Default: 0

assert

Verify the user is logged in if set to user, or has the bot userright if bot.

One value: user, bot

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.

curtimestamp

Include the current timestamp in the result.

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). 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, an Access-Control-Allow-Origin header will be set.

uselang

Language to use for message translations. A list of codes may be fetched from action=query&meta=siteinfo with siprop=languages, or specify user to use the current user's language preference, or specify content to use this wiki's content language.

Timestamp when the editing process began, used to detect edit conflicts. An appropriate value may be obtained using curtimestamp when beginning the edit process (e.g. when loading the page content to edit).

recreate

Override any errors about the page having been deleted in the meantime.

createonly

Don't edit the page if it exists already.

nocreate

Throw an error if the page doesn't exist.

watch

Deprecated.

Add the page to the current user's watchlist.

unwatch

Deprecated.

Remove the page from the current user's watchlist.

watchlist

Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.

One value: watch, unwatch, preferences, nochange

Default: preferences

md5

The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated. If set, the edit won't be done unless the hash is correct.

prependtext

Add this text to the beginning of the page. Overrides text.

appendtext

Add this text to the end of the page. Overrides text.

Use section=new to append a new section, rather than this parameter.

undo

Undo this revision. Overrides text, prependtext and appendtext.

undoafter

Undo all revisions from undo to this one. If not set, just undo one revision.

action=login (lg)

In the event of a successful log-in, the needed cookies will be included in the HTTP response headers. In the event of a failed log-in, further attempts may be throttled to limit automated password guessing attacks.

Remove a change tag from the database, including removing the tag from all revisions, recent change entries and log entries on which it is used.

activate

Activate a change tag, allowing users to apply it manually.

deactivate

Deactivate a change tag, preventing users from applying it manually.

This parameter is required.

One value: create, delete, activate, deactivate

tag

Tag to create, delete, activate or deactivate. For tag creation, the tag must not exist. For tag deletion, the tag must exist. For tag activation, the tag must exist and not be in use by an extension. For tag deactivation, the tag must be currently active and manually defined.

This parameter is required.

reason

An optional reason for creating, deleting, activating or deactivating the tag.

List of changes, formatted name=value (e.g. skin=vector). Value cannot contain pipe characters. If no value is given (not even an equals sign), e.g., optionname|otheroption|..., the option will be reset to its default value.

Separate values with |. Maximum number of values is 50 (500 for bots).

optionname

A name of a option which should be set to the value given by optionvalue.

optionvalue

A value of the option specified by optionname, can contain pipe characters.

list=random (rn)

Pages are listed in a fixed sequence, only the starting point is random. This means that if, for example, Main Page is the first random page in the list, List of fictional monkeys will always be second, List of people on stamps of Vanuatu third, etc.

If the number of pages in the namespace is lower than rnlimit, fewer pages will be returned. The same page will not be returned twice.

Separate values with |. Maximum number of values is 50 (500 for bots).

Default: *

amprop

Which properties to get.

Values (separate with |): default

amenableparser

Set to enable parser, will preprocess the wikitext of message (substitute magic words, handle templates, etc.).

amnocontent

If set, do not include the content of the messages in the output.

amincludelocal

Also include local messages, i.e. messages that don't exist in the software but do exist as a MediaWiki: page.
This lists all MediaWiki: pages, so it will also list those that aren't really messages such as Common.js.

amargs

Arguments to be substituted into message.

Separate values with |. Maximum number of values is 50 (500 for bots).

amfilter

Return only messages with names that contain this string.

amcustomised

Return only messages in this customisation state.

One value: all, modified, unmodified

Default: all

amlang

Return messages in this language.

amfrom

Return messages starting at this message.

amto

Return messages ending at this message.

amtitle

Page name to use as context when parsing message (for amenableparser option).