Jump to content

Wikidata:REST API

From Wikidata
Translate this page; This page contains changes. Please contact a translation admin to mark them for translation.

Overview

Image for: Overview
[edit]

The Wikibase REST API is an OpenAPI-based interface that allows users to interact with, retrieve and edit Items, Properties and Statements on Wikibase instances -- including of course Wikidata. For more information about REST, see the Wikipedia entry on representational state transfer.

How to use the API

Image for: How to use the API
[edit]

You can access the Wikibase API on Wikidata using the base URL: https://www.wikidata.org/w/rest.php/wikibase/v1

  1. Set up authentication.
  2. Consult the OpenAPI Swagger documentation for specific instructions on each call.

You can also take a look at the Wikibase developer documentation.

The Wikibase REST API is covered by Wikidata's Stable Interface Policy.

Functionality

Image for: Functionality
[edit]

You'll find all the calls in our new REST API, including examples, in our OpenAPI Swagger documentation.

We're constantly working on improving the functionality of the API. To have your say in that changing functionality, consider adding your feedback on the talk page or make a ticket on the Phabricator board.

Error messages

[edit]

The Wikibase REST API throws informative error messages, documented for each call in detail in the Responses section of the OpenAPI documentation.

Rate limits

[edit]

As does any public API, the Wikibase REST API on Wikidata has certain rate limits in place to prevent misuse and abuse.

Because the Wikibase REST API uses the same underlying classes as the Action API, rate limiting happens according to the same rules and using the same setting, $wgRateLimits. See the Action API rate-limiting documentation for more details.

Why should I use the Wikibase REST API?

Image for: Why should I use the Wikibase REST API?
[edit]

The REST API is tailored to the Wikibase data model, and it solves a number of existing issues that are easier to solve with REST.

  • For Item data, the REST API uses Statements instead of claims.
  • Cleaner, flatter structure in response data.
  • A number of improvements in how Statement data and metadata are presented.


The REST API conforms to modern industry standards, as opposed to the Wikibase calls in the Action API. Developers familiar with REST APIs will find the Wikibase REST API much easier to use.

Wikibase REST API is versioned (see info.version field in the Open API document), so functionality stays stable. Breaking changes are generally avoided, but in case of a breaking change it will be indicated in the change of the version in the API URL.

Check out our comparison of old and new functionality to get a feel for the contrast between the Action and REST API.

Libraries

Image for: Libraries
[edit]

Wikibase: How to enable the API

Image for: Wikibase: How to enable the API
[edit]

Wikibase REST API is available on every Wikibase instance updated in December 2024 or later. In older versions, Wikibase REST API has been enabled by modifying the wgRestAPIAdditionalRouteFiles variable in LocalSettings.php.


See also

Image for: See also
[edit]