API:Data formats/ru

Input
The API takes its input through parameters provided by the query string or from a POST entity in application/x-www-form-urlencoded or multipart/form-data format. Every module (and every action=query submodule) has its own set of parameters, which is listed in the documentation and in action=help, and can be retrieved through action=paraminfo.

Multivalue parameters
Некоторые параметры могут принимать несколько значений, разделённых вертикальной чертой. Whether a parameter accepts multiple values is listed explicitly in  and. The documentation does not distinguish multivalue parameters explicitly, but the descriptions for these parameters are usually along the lines of "A list of ..." or "A pipe-separated list of ...".

Boolean values
Boolean parameters work like HTML checkboxes: if the parameter is specified in the HTTP request, regardless of value, it is considered true. For a false value, omit the parameter entirely. The best way to specify a true parameter in an HTTP request is to use ; the trailing   ensures the browser or HTTP library does not discard the "empty" someParam.

Timestamps
Parameters that take timestamp values accept multiple timestamp formats:


 * формат ISO 8601:
 * MySQL's internal timestamp format:
 * UNIX timestamp format  (время, прошедшее с 1 января 1970 года, в секундах)
 * UNIX timestamp format  (время, прошедшее с 1 января 1970 года, в секундах)

In the output, timestamps are always in ISO 8601 format.

Output
MediaWiki API supports a number of generic output formats (XML, JSON, YAML, ...), and some domain-specific formats (RSS, ...) for special modules. You should always specify the format with the input (request) parameter  and a lowercase value. Начиная с версии 1.24, все форматы, кроме JSON, XML и PHP, считаются устаревшими, и ожидается, что их поддержка будет отключена в версиях 1.26, 1.27. All new API users should use JSON. Clients written in PHP should avoid using the PHP format because it is fundamentally insecure. It is maintained only due to its popularity.

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

Использовавшийся по умолчанию в более ранних версиях MediaWiki формат  в MediaWiki 1.25 был заменён на.

Note that while the pretty-print formats are all indented and separate syntactic elements with newlines, the non-pretty formats don't do this.

There are many conversion libraries and online converters to convert JSON responses to other formats, for example http://json-csv.com converts to Comma-Separated Values

JSON parameters
and  accept the following additional parameters:

Specify  for to get json (and php) format responses in a  cleaner format.

Callback restrictions
When using JSON in callback mode, a number of things are disabled for security:
 * Tokens cannot be obtained (so state-changing actions aren't possible)
 * The client is treated as an anonymous user (i.e. not logged in) for all purposes, even after logging in through action=login
 * This means that things that require additional rights, such as, won't work unless anonymous users are allowed to use them

Examples
it may be useful to add the '&indexpageids' parameter, to parse the json if the pageid ("736") is not known before the result.