Wikibase/API/fr

Qu'est-ce que l'API Wikibase ?
Wikibase fournit un mécanisme général pour sauvegarder des déclarations en tant que données structurées. Les déclarations concernant les éléments se trouvent sur le serveur wikidata.org. Voir wikidata:Glossary pour plus d'explications sur Wikibase et d'autres concepts.



The Wikibase API allows querying, adding, removing and editing information on Wikidata or any other Wikibase instance.

Elle est représentée par un ensemble d'extensions qui implémentent les modules de l'API MediaWiki. Ainsi pour utiliser l'API Wikibase vous devriez avoir une connaissance de base de l'API MediaWiki Action: actions, requêtes, etc., et inversement toute votre expérience avec les paramètres génériques comme  et , etc. s'appliquera à l'API Wikibase.

How to use it
Send requests to the API through HTTP, the same way with the MediaWiki Action API. See API:Tutorial#How to use it for information on how to use the MediaWiki Action API.

Request format
The endpoint for the API is https://wikidata.org/w/api.php.

In the query string, add the action parameter which tells the API which action to perform, e.g.  tells the API to get the data for Wikibase entities. For meta and property submodules, use and   respectively.

Certains paramètres sont presque toujours disponibles. Les formes plurielles sont utilisées dans les cas où un paramètre peut prendre plusieurs valeurs. Les paramètres sont :

GET request
Explanation of each part of the URL:


 * is the main endpoint.
 * tells the API to get the data for Wikibase entities.
 * means get the data from English Wikipedia.
 * indicates the title of the page to get data from.
 * indicates properties to get from the entities, in this case the property is the descriptions of the entities.
 * means filter the results down to the English language.
 * indicates JSON output, which is the recommended output format.

Response
La réponse à la requête contient généralement :
 * Une clé  avec une conversion booléenne sous forme d'entier si la demande aboutit. Si l'entier est zéro, toute valeur supplémentaire peut être erronée.
 * An  key with an object of two, optionally three keys, ,   and  , if the request is unsuccessful.
 * Information about the action. The information is either passed on the top level or under item if it is one single item or items if it is several. If it is several items, each is found under a key with its own item id.

Empty objects are returned as JSON arrays and not as objects, while empty parameters remove the actual entry from the item.

Meta submodules

 * wikibase: Gets information about the Wikibase client and the associated Wikibase repository.
 * wbcontentlanguages: Returns information about the content languages Wikibase accepts in different contexts.

Property submodules

 * pageterms: Get the Wikidata terms (typically labels, descriptions and aliases) associated with a page via a sitelink.
 * wbentityusage: Returns all entity IDs used in the given pages.

API modules

 * wbgetentities: Gets the data for multiple Wikibase entities.
 * wbavailablebadges: Queries available badge items.
 * wbcreateclaim: Creates Wikibase claims.
 * wbcreateredirect: Creates Entity redirects.
 * wbeditentity: Creates a single new Wikibase entity and modifies it with serialised information.
 * wbformatvalue: Formats DataValues.
 * wbgetclaims: Gets Wikibase claims.
 * wblinktitles: Associates two pages on two different wikis with a Wikibase item.
 * wbmergeitems: Merges multiple items.
 * wbparsevalue: Parses values using a ValueParser.
 * wbremoveclaims: Removes Wikibase claims.
 * wbremovequalifiers: Removes a qualifier from a claim.
 * wbremovereferences: Removes one or more references of the same statement.
 * wbsearchentities: Searches for entities using labels and aliases.
 * wbsetaliases: Sets the aliases for a Wikibase entity.
 * wbsetclaim: Creates or updates an entire Statement or Claim.
 * wbsetclaimvalue: Sets the value of a Wikibase claim.
 * wbsetdescription: Sets a description for a single Wikibase entity.
 * wbsetlabel: Sets a label for a single Wikibase entity.
 * wbsetqualifier: Creates a qualifier or sets the value of an existing one.
 * wbsetreference: Creates a reference or sets the value of an existing one.
 * wbsetsitelink: Associates a page on a wiki with a Wikibase item or removes an already made such association.
 * wbsgetsuggestions: Gets suggestions of additional properties to add to a Wikibase entity.
 * wbcheckconstraints: Performs constraint checks on any entity you want and returns the result.
 * wbcheckconstraintparameters: Checks the constraint parameters of constraint statements.

Erreurs possibles
Des erreurs possibles pour n'importe quel module peuvent être trouvées en utilisant. The error format corresponds to that of the Mediawiki Action API. See API:Errors and warnings#Legacy format.

All error messages from the Wikibase modules should be internationalized (i18n) and localized (l10n). The user language for the logged-in user will be the default for error messages, but you can override this by adding  to the URL query string.

Additional notes

 * Many Wikimedia wikis run the Wikibase Client extension. This lets API clients on them to query the  meta submodule to determine URLs for the full Wikibase repo, and the   property submodule to get some Wikidata information about pages on the local wiki.
 * The calender models that can be used with Wikibase are the Gregorian calendar(Q1985727) and the Julian calendar(Q1985786).
 * The API uses revision ids for edit collision detection. If there is an edit collision, the requester must acquire a newer revision id to be able to continue. This typically involves requesting  for the item in question, and then storing (and using) the revision from the entry.
 * Toute installation MediaWiki peut exécuter Wikibase. Sur le cluster Wikimedia, la plupart des wikis n'utilisent pas l'ensemble complet d'extensions Wikibase. Wikimedia Commons possède sa propre Wikibase pour les propriétés des fichiers sur Commons.
 * Do not test the  value for a particular error, instead use the   value as this will remain independent of localization.

Voir aussi

 * - Le guide de démarrage rapide pour l'API Action de MediaWiki.
 * - Questions fréquentes à propos de l'API Action MediaWiki.
 * - Un tutoriel sur comment utiliser l'API Action de MediaWiki.
 * Download Wikidata database dumps in JSON (recommended), XML and RDF formats.