Wikidata:REST API/Comparison
Jump to navigation
Jump to search
Comparison of API calls
[edit]The following table shows some typical API tasks and how they can be performed using the Action API and the Wikibase REST API.
Task | Action API
https://www.wikidata.org/w/api.php |
Wikibase REST API https://www.wikidata.org/w/rest.php/wikibase/v0/entities | Notes |
---|---|---|---|
Get the label in a given language (en) for Item Q42 | ?action=wbgetentities&ids=Q42&props=labels&languages=en&languagefallback=1
|
GET: /items/Q42/labels_with_language_fallback/en
|
|
Get the value for P569 (date of birth) for Item Q42 | ?action=wbgetclaims&entity=Q42&property=P569
|
GET: /items/Q42/statements?property=P569
|
|
Set the English description of Q42 to “English science fiction writer and humourist” | ?action=wbsetdescription&id=Q42&language=en&value=English%20science&20fiction%20writer%20and%20humourist
|
PUT: /items/Q42/descriptions/en
|
|
If not already set, add Internet Book Database of Fiction writer ID "42" to Q42 (Douglas Adams) |
If that returns no result:
|
GET: If that returns an empty JSON object: POST: {
"statement": {
"rank": "normal",
"property": {
"id": "P5365"
},
"value": {
"content": "42",
"type": "value"
}
}
}
|
|
Get the English Wikipedia sitelink for Q42 | ?action=wbgetentities&ids=Q42&props=sitelinks&sitefilter=enwiki
|
GET: /items/Q42
locate the "sitelinks/enwiki" key |