cURL examples to query Wikidata

Reading time: 1 minutes

The SPARQL endpoint is and it has a Web form to fire queries. However (“instance of”) tells you what the entity is.

The repository doesn’t have named graphs, or at least the SPARQL endpoint rejects graph queries. The classes of entities (rdf:type) are not described in the repository.

To find the HTML page of an entity (such as, simply replace /entity/ with /wiki/.

By default the SPARQL endpoint returns the results in SPARQL Results XML format but

  • adding -H "Accept: application/json" to the cURL command gets them in JSON Query Results
  • adding -H "Accept: text/csv" to the cURL command gets them in CSV format (the most readable).

Don’t forget to URL encode the query 😉

The list of entity types

Description of an entity (East Antarctica)

describe queries return all the triples in which the selected entity is subject (position 1/3). Certain SPARQL endpoints (such as this one) also return the triples in which the entity is object (position 3/3). The query result being a graph and not a table like for SPARQL Results, the default format is RDF/XML. JSON and Turtle (text/turtle) can also be requested.