Hello everyone,
We are working on making it easier to access Wikidata’s data
programmatically so that more people can build great applications on top of
our data. As part of this we are building a new REST API for Wikibase. A
while ago we asked for feedback on the draft specification for that new API
<https://www.wikidata.org/wiki/Wikidata:REST_API_feedback_round> (see previous
communication
<https://lists.wikimedia.org/hyperkitty/list/wikidata@lists.wikimedia.org/me…>
). It is in development now. While it is not in the state which we would
like to run on Wikidata, you can now have a look at the current development
state on Beta Wikidata <https://wikidata.beta.wmflabs.org> and follow along
as we build out the API. You can find the current state of the
specification we are working from at
https://doc.wikimedia.org/Wikibase/master/js/rest-api/. *(Small caveat: The
specification might sometimes be slightly ahead of the code development and
contain functionality that still needs to be implemented.)*
Please note that the API is still in the experimental development state.
There might be changes in the functionality available and API’s behavior
that we will not announce separately.
The current state can already do the following:
-
Retrieve the data of an Item with ‘GET /entities/items/{item_id}’ and
filter what fields (i.e. type, labels, descriptions, aliases, statements,
sitelinks) are returned when reading the Item data
-
Retrieve all statements of an Item with ‘GET
/entities/items/{item_id}/statements’
-
Retrieve the data of a single statement of an Item with ‘GET
/entities/items/{item_id}/statements/{statement_id}’ or ‘GET
/statements/{statement_id}’
-
Conditionally request the data only if it has changed since the
specified revision/timestamp (using If-None-Match, If-Modified-Since
HTTP headers)
-
Create a statement on an Item with ‘POST
/entities/items/{item_id}/statements’
-
Authenticate and authorize as a Beta Wikidata user when making edits
using the API, as well as provide edit tags and edit comment, and mark an
edit as one made by a bot.
If you want to give it a try, here are some REST API calls for an example
Item (“house cat”) on Beta Wikidata:
-
Get the complete data of the Item: GET
https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/entities/items/Q59…
-
Get all labels: GET
https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/entities/items/Q59…
-
Get a specific statement by its ID: GET
https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/entities/items/Q59…
-
Get all statements: GET
https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/entities/items/Q59…
The following things are still missing before it can go live on Wikidata in
a first version:
-
Replacing the statement on an Item with ‘PUT
/entities/items/{item_id}/statements/{statement_id}’ or ‘PUT
/statements/{statement_id}’
-
Editing a statement on an Item with ‘PATCH
/entities/items/{item_id}/statements/{statement_id}’ or ‘PATCH
/statements/{statement_id}’
-
Removing the statement from an Item with ‘DELETE
/entities/items/{item_id}/statements/{statement_id}’ or ‘DELETE
/statements/{statement_id}’
-
Automated edit summaries
The following will likely not be available in the first version but follow
later:
-
Creating or deleting an Item
-
Getting a statement from an Item based on the Property ID in the
statement
-
Any operation (reading, adding, editing, removing) on sitelinks, labels,
descriptions and aliases
-
Any operation on entity types other than Items (i.e. Properties,
Lexemes, …)
-
Translated error messages
If you have any feedback on what’s there so far please let us know at Wikidata
talk:REST API feedback round
<https://www.wikidata.org/wiki/Wikidata_talk:REST_API_feedback_round>.
Cheers,
--
Mohammed Sadat
*Community Communications Manager for Wikidata/Wikibase*
Wikimedia Deutschland e. V. | Tempelhofer Ufer 23-24 | 10963 Berlin
Phone: +49 (0) 30 577 116 2466
https://wikimedia.de
Keep up to date! Current news and exciting stories about Wikimedia,
Wikipedia and Free Knowledge in our newsletter (in German): Subscribe now
<https://www.wikimedia.de/newsletter/>.
Imagine a world in which every single human being can freely share in the
sum of all knowledge. Help us to achieve our vision!
https://spenden.wikimedia.de
Wikimedia Deutschland – Gesellschaft zur Förderung Freien Wissens e. V.
Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter
der Nummer 23855 B. Als gemeinnützig anerkannt durch das Finanzamt für
Körperschaften I Berlin, Steuernummer 27/029/42207.