API:Data formats/fr

Entrées
L'API récupère ses entrées à partir des paramètres fournis dans la requête ou à partir d'une entité POST dans le format application/x-www-form-urlencoded ou multipart/form-data. Chaque module (et chaque sous-module ) a sa propre liste de paramètres, qui sont listés dans la documentation et dans action=help. Ils peuvent également être récupérés par.

Encodage
Toute entrée doit être du UTF-8 valide, sous la forme NFC. MediaWiki essayera de convertir les autres formats ce qui pourra éventuellement générer des erreurs.

Paramètres Multi-valeurs
Certains paramètres acceptent plusieurs valeurs séparées par une barre verticale   (pipe). Par exemple, pour soumettre les trois valeurs,   et   pour le paramètre  , vous devez écrire    dans la requête. Si un paramètre accepte de multiples valeurs, cela est affiché explicitement par  et. 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 ...".

If you need to submit a list of values where some of the values contain a pipe character (which should be rare - most multivalue parameters are lists of page titles or usernames, neither of which can contain pipes), you can use the unit separator character instead:  (where  stands for U+001F) will submit the three values ,   and. (Note that there is an extra  at the beginning. This is mandatory to avoid ambiguity around submitting a single value containing a pipe.)

Valeurs booléennes
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.

Horodatages
Parameters that take timestamp values accept multiple timestamp formats:


 * format ISO 8601:
 * MySQL's internal timestamp format:
 * UNIX timestamp format  (Nombre de secondes depuis le 1er janvier 1970)
 * UNIX timestamp format  (Nombre de secondes depuis le 1er janvier 1970)

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

Sortie
MediaWiki API has historically supported a number of different formats, but this has significantly complicated further development. We would like to standardize on just one JSON format. For now, MediaWiki discourages, but still supports two additional generic output formats (XML and PHP). You should always specify the format with the input (request) parameter  and a lowercase value. Feed modules like Feed Recent Changes override the standard output format, instead using RSS or Atom, as specified by their  parameter. In those cases, the format specified in the  parameter is only used if there's an error. All formats other than JSON are deprecated. XML and PHP are still supported, but all others have been removed in either MediaWiki 1.26 or 1.27; see the table below. Tous les nouveaux utilisateurs de l'API doivent utiliser JSON. 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.

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  suffix.

The default format changed in MediaWiki 1.25 to ; it was   in earlier MediaWiki releases.

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, JSON-CSV converts to Comma-Separated Values

Paramètres JSON
and  accept the following additional parameters:


 * Specify  for to get json (and php) format responses in a  cleaner format. This also encodes most non-ASCII characters as UTF-8.
 * Specify  for to get json (and php) format responses in a  cleaner format. This also encodes most non-ASCII characters as UTF-8.
 * Specify  for to get json (and php) format responses in a  cleaner format. This also encodes most non-ASCII characters as UTF-8.

Restrictions pour les callback
Si vous utilisez JSON en mode callback, certains éléments sont désactivés par sécurité :


 * 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
 * This means that things that require additional rights, such as, won't work unless anonymous users are allowed to use them

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