Wikibase/API/he
דף זה הוא חלק מהתיעוד של ה־action API של מדיה־ויקי |
MediaWiki version: | ≥ 1.9 |
What is the Wikibase API?
Wikibase provides a general mechanism for storing statements as structured data. The statements about items live on the server at wikidata.org. See Wikidata:Glossary for more information on Wikibase and other concepts.
The Wikibase API allows querying, adding, removing and editing information on Wikidata or any other Wikibase instance.
It is provided via a set of extensions to MediaWiki API modules.
So, to use the Wikibase API, you should have a basic familiarity with the MediaWiki Action API: actions, queries, etc., as well as with generic parameters such as curtimestamp
and requestid
.
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.
Some parameters are nearly always available. Plural forms are used in those cases in which a parameter can take several values. The parameters are:
id/ids
: Identifies a specific entity or entities, typically an item. The plural form is used in wbgetentities. Lists of ids should be separated by the pipe charactersite ∩ title/sites ∩ titles
: Identifies a single item or multiple items. The plural form is used in wbgetentities. Only one of sites and titles can have multiple values at the same time.language/languages
: The language parameter filters labels and descriptions in get actions or identifies a specific language for a set of actions.format
: Should always be set to json (or jsonfm for debugging), or xml (or xmlfm for debugging). No other form is supported.summary
: Adds a user-specified summary in addition to the system-generated one.token
: An encrypted string the requester must pass for the request to be fulfilled.baserevid
: An id for the last known revision that must be passed so that the server can detect edit collisions.
שאילתה פשוטה
בקשת GET
הסבר על כל חלק בכתובת:
http://www.wikidata.org/w/api.php
היא נקודת הגישה המרכזית.action=wbgetentities
אומר ל־API לקבל את הנתונים ליישויות ויקיבייס.sites=enwiki
אומר לקבל נתונים מהוויקיפדיה האנגלית.titles=Berlin
מציין את כותרת הדף ממנו לקבל נתונים.props=descriptions
מציין את המאפיינים המבוקשים מהיישויות, במקרה הזה המאפיין הוא התיאורים של היישויות.languages=en
אומר לסנן את התוצאות לאנגלית בלבד.format=json
מציין פלט JSON שהיא תצורת הפלט המומלצת.
תשובה
{
"entities": {
"Q64": {
"type": "item",
"id": "Q64",
"descriptions": {
"en": {
"language": "en",
"value": "capital and largest city of Germany"
}
}
}
},
"success": 1
}
התגובה לבקשה בדרך כלל תכיל:
- A
success
key with a boolean cast as an integer if the request is successful. If the integer is zero, any additional values might be wrong. - An
error
key with an object of two, optionally three keys,code
,info
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.
API documentation and Wikibase modules
Meta submodules
- wikibase: ⧼Apihelp-query+wikibase-description⧽
- wbcontentlanguages: מחזיר מידע על שפות התוכן של שוויקיבייס מקבל בהקשרים שונים.
Property submodules
- pageterms: ⧼Apihelp-query+pageterms-description⧽
- wbentityusage: ⧼Apihelp-query+wbentityusage-description⧽
API modules
- wbgetentities: ⧼Apihelp-wbgetentities-description⧽
- wbavailablebadges: ⧼Apihelp-wbavailablebadges-description⧽
- wbcreateclaim: ⧼Apihelp-wbcreateclaim-description⧽
- wbcreateredirect: ⧼Apihelp-wbcreateredirect-description⧽
- wbeditentity: ⧼Apihelp-wbeditentity-description⧽
- wbformatvalue: ⧼Apihelp-wbformatvalue-description⧽
- wbgetclaims: ⧼Apihelp-wbgetclaims-description⧽
- wblinktitles: ⧼Apihelp-wblinktitles-description⧽
- wbmergeitems: ⧼Apihelp-wbmergeitems-description⧽
- wbparsevalue: ⧼Apihelp-wbparsevalue-description⧽
- wbremoveclaims: ⧼Apihelp-wbremoveclaims-description⧽
- wbremovequalifiers: ⧼Apihelp-wbremovequalifiers-description⧽
- wbremovereferences: ⧼Apihelp-wbremovereferences-description⧽
- wbsearchentities: חיפוש ישויות באמצעות תוויות וכינויים.
- wbsetaliases: ⧼Apihelp-wbsetaliases-description⧽
- wbsetclaim: ⧼Apihelp-wbsetclaim-description⧽
- wbsetclaimvalue: ⧼Apihelp-wbsetclaimvalue-description⧽
- wbsetdescription: ⧼Apihelp-wbsetdescription-description⧽
- wbsetlabel: ⧼Apihelp-wbsetlabel-description⧽
- wbsetqualifier: ⧼Apihelp-wbsetqualifier-description⧽
- wbsetreference: ⧼Apihelp-wbsetreference-description⧽
- wbsetsitelink: ⧼Apihelp-wbsetsitelink-description⧽
- wbsgetsuggestions: ⧼Apihelp-wbsgetsuggestions-description⧽
- wbcheckconstraints: ⧼Apihelp-wbcheckconstraints-description⧽
- wbcheckconstraintparameters: בדיקת הפרמטרים של קביעות האילוצים.
Possible errors
Possible errors for any module can be found using 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 | קוד | פרטים |
---|---|---|
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 |
הערות נוספות
- 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 thepageterms
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(d:Q1985727) and the Julian calendar(d: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
wbgetentities
for the item in question, and then storing (and using) the revision from the entry.
- Any MediaWiki installation can run Wikibase. On the Wikimedia cluster, most wikis do not run the full set of Wikibase extensions.
Wikimedia Commons has its own Wikibase for properties of the files on Commons.
- Do not test the
info
value for a particular error, instead use thecode
value as this will remain independent of localisation.
ר׳ גם
- API:עמוד ראשי - מדריך ההתחלה המהירה ל־API הפעולות של מדיה־ויקי.
- API: שאלות ותשובות - שאלות נפוצות על API הפעולות של מדיה־ויקי.
- API:Tutorial - מדריך איך להשתמש ב־API הפעולות של מדיה־ויקי.
- Download Wikidata database dumps in JSON (recommended), XML and RDF formats.