Wikibase/API

From mediawiki.org
This page is a translated version of the page Wikibase/API and the translation is 48% complete.
MediaWiki version:
1.9

Wat is die Wikibase API?

Wikibase bied 'n algemene meganisme om stellings as gestruktureerde data te stoor. Die verklarings oor items verskyn op die bediener by wikidata.org. Raadpleeg Wikidata:Glossary vir meer inligting oor Wikibase en ander konspete.

A statement

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

Dit word voorsien deur 'n stel uitbreidings wat MediaWiki API-modules implementeer. Om die Wikibase API te gebruik,moet u dus basiese vertroudheid met die MediaWiki Action API:aksies,navrae,ens.Hê,en omgekeerd u ervaring met generiese parameters soos curtimestamp en requestid is van toepassing op die Wikibase API.

How to use the Wikibase api

Send requests to the API through HTTP, the same as with the MediaWiki Action API. See API:Tutorial#How to use it for information about 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. For example, action=wbgetentities tells the API to get the data for Wikibase entities. For meta and property submodules, use action=query&meta=yourmodule and action=query&prop=modulename respectively.

Daar is 'n paar parameters wat byna altyd beskikbaar is.Meervoudsvorme word gebruik in gevalle waar 'n parameter verskillende waardes kan inneem.Die parameters is:

  • id/ids: Identifiseer 'n spesifieke "entiteit" of "entiteite",die mees tipiese "item".Meervoudsvorm word in "wbgetentiteite" gebruik.Lyste van ID's moet van die pypkarakter geskei word
  • site ∩ title/sites ∩ titles: Identifiseer 'n enkele item of meerdere items.Meervoudsvorm word in "wbgetentiteite" gebruik.Slegs een van "webwerwe" en "titels" kan gelyktydig verskeie waardes hê.
  • language/languages: Die taal word gebruik as 'n filtermeganisme om etikette en beskrywings te filter in aksies of om 'n spesifieke taal vir bepaalde aksies identifiseer.
  • format: Moet altyd ingestel wees op"json"(of "jsonfm for debugging"),of"xml"(of"xmlfm for debugging"),word geen ander vorm ondersteun nie.
  • summary: Voeg 'n gebruiker gespesifiseerde opsomming by,bykomend tot die stelsel wat gegenereer is.
  • token: An encrypted string the requester must pass on shall the request be fulfilled.
  • baserevid: 'N ID vir die laaste bekende hersiening wat deurgegee moet word sodat die bediener wysigingsbitsings kan opspoor.

A simple query

GET request

Get the item for page "Berlin" on English Wikipedia.


Explanation of each part of the URL:

  • http://www.wikidata.org/w/api.php is the main endpoint.
  • action=wbgetentities tells the API to get the data for Wikibase entities.
  • sites=enwiki means get the data from English Wikipedia.
  • titles=Berlin indicates the title of the page to get data from.
  • props=descriptions indicates properties to get from the entities, in this case the property is the descriptions of the entities.
  • languages=en means filter the results down to the English language.
  • format=json indicates JSON output, which is the recommended output format.

Response

{
    "entities": {
        "Q64": {
            "type": "item",
            "id": "Q64",
            "descriptions": {
                "en": {
                    "language": "en",
                    "value": "capital and largest city of Germany"
                }
            }
        }
    },
    "success": 1
}

Die antwoord van 'n versoek sal gewoonlik die volgende bevat:

  • 'N Sleutel $sleutel1 met 'n Boole-rolverdeling as 'n heelgetal as die versoek suksesvol is.As die heelgetal nul is,kan enige addisionele waardes verkeerd wees.
  • 'N $sleutel2 sleutel met 'n voorwerp van twee,opsioneel drie sleutels,$sleutels4,$sleutel5 en $sleutel6,indien die versoek nie suksesvol is nie
  • Inligting oor die aksie.Die inligting word of op die boonste vlak of onder "item" deugegee as dit en ekele item is of "items" as dit verskeie is.As dit verskillende items is, word elkeen onder 'n sleutel met hul eie item-ID gevind.

Leë voorwerpe word teruggestuur as JSON-skikkings en nie as voorwerpe nie, terwyl leë parameters die werklike item van die item verwyder.

API dokumentasie en Wikibase modules

Source-generated documentation for the MediaWiki Action API including Wikibase 'wb' API modules is available at wikidata.org/w/api.php

Meta submodules

  • wikibase: ⧼Apihelp-query+wikibase-description⧽
  • wbcontentlanguages: Returns information about the content languages Wikibase accepts in different contexts.

Property submodules

  • pageterms: ⧼Apihelp-query+pageterms-description⧽
  • wbentityusage: ⧼Apihelp-query+wbentityusage-description⧽

API modules

Moontlike foute

Moontlike foute vir enige module kan gevind word met behulp van action=paraminfo&modules=modulename. 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 internationalised (i18n) and localised (l10n). The user language for the logged-in user will be the default for error messages, but you can override this by adding uselang=languageCode to the URL query string.

Error type Code Info
An internationalized error message that isn't localized. no-such-item <wikibase-api-no-such-item>
A correctly localized error message. no-such-item There are no such item to be found
A localized variant.(Norwegian) no-such-item Det finnes ingen slik item

Additional notes

  • Many Wikimedia wikis run the Wikibase Client extension. This lets API clients on them to query the wikibase meta submodule to determine URLs for the full Wikibase repo, and the pageterms property submodule to get some Wikidata information about pages on the local wiki.
  • Die Kalendermodelle wat met Wikibase gebruik kan word,is die Gregoriaanse kalender(d:Q1985727) en die Juliaanse Kalender($2).
  • Die API gebruik hersienings-ID's vir die opsporing van botsings.As daar 'n wysigningbotsing is,moet die versoeker 'n nuwer hersienings -ID verkry om te kan voortgaan.Dit behels gewoonlik dat u wbgententiteite vir die betrokke item aanvra,en da die hersiening vanaf die inskrywing stoor(en gebruik).
  • Elkie Mediawiki Installasie kan Wikibase laat loop.In die Wikimedia groep bevat die meeste wiki's nie die volledige stel Wikibase uitbreidings nie. Wikimedia Commons het 'n eie Wikibase vir die eienskappe van die lêers op commons
  • Do not test the info value for a particular error, instead use the code value as this will remain independent of localisation.

Sien ook