API:Data formats - MediaWiki (original) (raw)

Languages:

This page is part of the MediaWiki Action API documentation.

Input

The API takes its input through parameters provided by the HTTP request in application/x-www-form-urlencoded or multipart/form-data format. (unlike REST API, the Action API currently does not support application/json input format.) Every module and submodule has its own set of parameters, which are listed in the documentation and in action=help. They can also be retrieved through action=paraminfo .

Encoding

All input should be valid UTF-8, in NFC form. MediaWiki will attempt to convert other formats, which may result in an error.

Multivalue parameters

Parameters that take multiple values are normally submitted with the values separated using the pipe character (|), e.g. param=value1|value2. If a value contains the pipe character in itself, use U+001F (Unit Separator) as the separator and prefix the value with U+001F, e.g. param=%1Fvalue1%1Fvalue2.

Whether a parameter accepts multiple values is listed explicitly in its module documentation.

Boolean parameters

If a boolean parameter is specified in an HTTP request, it is considered true regardless of its value. For a false value, omit the parameter entirely. The best way to specify a true parameter in an HTTP request is to use _someParam_=; the trailing = ensures the browser or HTTP library does not discard the "empty" someParam.

Timestamps

Parameters that take timestamp values accept multiple timestamp formats:

Timestamps are always output in ISO 8601 format.

Output

The standard and default output format in MediaWiki is JSON. All other formats are discouraged.

The output format should always be specified using format=_yourformat_ with yourformat being one of the following:

Example

Get the output in JSON.

Response

{ "query": { "pages": { "217225": { "pageid": 217225, "ns": 0, "title": "Main page" } } } }

Unless specified, all modules allow data output in all generic formats. To simplify debugging, all generic formats have "pretty-print in HTML" alternatives with an fm suffix, e.g. jsonfm.

JSON parameters

The following parameters can be used with format=json and format=jsonfm:

Additional notes

See also