Wikidata Query Service/User Manual

= Introduction = Wikidata Query Service (WDQS) is the software package and public service designed to provide a SPARQL endpoint which allows to query against Wikidata data set.

Please note that the service is currently in beta mode, which means some details of the data set or the service provided can be changed without prior warning. This page or other relevant documentation pages will be updated accordingly, it is recommended to watch them if you are using the service.

You can see examples of the SPARQL Queries on the SPARQL Examples page.

Data set
The data set is the data from Wikidata.org, represented in RDF as described in RDF dump format documentation. Please note the service data set does not exactly match the data set produced by RDF dumps, mainly for performance reasons - there is a small set of differences described in RDF format documentation.

Extensions
The following are extensions to standard SPARQL capabilities supported by the service:

Label service
WDQS allows to fetch the label of the entity queried, with language fallback, using the specialized service with the URI 

Extended dates
The service supports date values of type  in the range of about 290B years in the past and in the future, with one-second resolution. All times are in UTC timezone.

Wikimedia service
Wikimedia runs the public service instance of WDQS, which is available for use at http://query.wikidata.org/.

The runtime of the query on the public endpoint is limited by 30 seconds. That is true both for GUI and public SPARQL endpoint. If you need to run longer queries, please contact the Discovery team.

GUI
The GUI at the home page of http://query.wikidata.org/ allows to edit submit SPARQL queries to the query engine. The results are displayed as HTML table. Note that every query has the unique URL which can be bookmarked for later use. Going to this URL will put the query in the edit window, but will not run it - you still have to click "Execute" for that.

One can also generate a short URL for the query via an URL shortening service by clicking "Generate short URL" link on the right - this will produce the shortened URL for the current query.

"Add prefixes" button generates the header containing standard prefixes for SPARQL queries. The full list of prefixes that can be useful is listed in RDF format documentation.

The GUI also features simple entity explorer which can be activated by clicking on "*" symbol next to the entity result. Clicking on entity Q-id itself will take you to the entity page on wikidata.org.

SPARQL endpoint
SPARQL queries can be submitted directly to the SPARQL endpoint with GET request to https://query.wikidata.org/bigdata/namespace/wdq/sparql?query={SPARQL}. The result is returned as XML by default, or as JSON if either  query parameter or header   are provided.

Missing features
Below is the list of features which are currently not supported:
 * Geolocation search. While the coordinates themselves are part of the data set, the operations on these coordinates - like comparison, search within radius, etc. - are not yet supported.
 * Redirects are only represented as owl:sameAs triple, but do not express any equivalence in the data and have no special support.
 * SERVICE requests to outside URLs are not allowed in queries.