এপিআই: তথ্য বিন্যাস

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Data formats and the translation is 10% complete.

Outdated translations are marked like this.
Other languages:
English • ‎español • ‎français • ‎português do Brasil • ‎русский • ‎বাংলা • ‎ไทย • ‎中文 • ‎日本語 • ‎한국어

নিবেশ

এপিআই পরিমিতি প্রদান করার মাধ্যমে application/x-www-form-urlencoded or multipart/form-data format -এ প্রশ্নের স্ট্রিং বা পোস্ট গ্রহন করে।

প্রত্যেক মডিউলের (এবং প্রত্যেক $query উপমডিউল) তার নিজস্ব পরিমিতির সেট রয়েছে যা action=help এ ডকুমেন্টের তালিকা করতে পারে এবং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.

বহুচলকবিশিষ্ট পরিমিতি

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.

সময়-চিহ্ন

Parameters that take timestamp values accept multiple timestamp formats:

  • ISO 8601 বিন্যাস: 2008-08-23T18:05:46Z.
  • MediaWiki's internal timestamp format : 20080823180546.
  • MySQL's internal timestamp format: 2008-08-23 18:05:46.
  • ইউনিক্স সময়-চিহ্ন বিন্যাস 1219514746 (number of seconds since January 1, 1970).

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:

  • json: JSON format. (recommended)
  • php: serialized PHP format. (deprecated)
  • xml: XML format. (deprecated)
  • txt: PHP print_r() format. (removed in 1.27)
  • dbg: PHP var_export() format. (removed in 1.27)
  • yaml: YAML format. (removed in 1.27)
  • wddx: WDDX format. (removed in 1.26)
  • dump: PHP var_dump() format. (removed in 1.26)
  • none: Returns a blank response. 1.21+

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:

  • utf8: Encodes most (but not all) non-ASCII characters as UTF-8 instead of replacing them with hexadecimal escape sequences. Type: boolean.
  • ascii: Encodes all non-ASCII characters using hexadecimal escape sequences. Type: boolean.
  • formatversion: The output formatting. 1.25+
    • 1: Backwards-compatible format, uses * keys for content nodes, encodes non-ASCII characters using hexadecimal escape sequences.
    • 2: Modern format. Returns responses in a cleaner format, encodes most non-ASCII characters as UTF-8. (recommended)
  • callback: The function in which the result will be wrapped. For safety, all user-specific data will be restricted. 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 modules which require additional rights won't work unless anonymous users are allowed to use them.

Additional notes

  • XML and PHP output formats are deprecated but still in use. Clients written in PHP should avoid using the PHP format because it is fundamentally insecure. It is maintained for now only due to its popularity.
  • There are many conversion libraries and online converters to convert JSON responses to other formats—for example, JSON-CSV converts to Comma-Separated Values.
  • Feed modules like Feed Recent Changes override the standard output format, instead using RSS or Atom, as specified by their feedformat parameter. In those cases, the format specified in the format parameter is only used if there's an error.

See also