Wikidata:REST API/Comparison

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 (uk) for Item Q42 ?action=wbgetentities&ids=Q42&props=labels&languages=en GET: /items/Q42/labels/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)

?action=wbgetclaims&entity=Q42&property=P5365

If that returns no result:

?action=wbcreateclaim&entity=Q42&property=P5365&snaktype=value&value=%2242%22

GET: /items/Q42/statements?property=P5365

If that returns an empty JSON object:

POST: /items/Q42/statements

{
  "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