add cart choropleth column cross cube error file folder geo help home lock obs poi rdf remove search slice spreadsheet success table unlock warning

[this is a icon-] developer tool

SPARQL 1.1 Query: Results

Edit query
Query results
s p_blank o_blank geosparql: Geometry geosparql: asWKT POLYGON ((-3.6110490627559 56.01123572137157, -3.60386192134732 56.012625057948576, -3.60362641870271 56.01216366823475, -3.604168394509303 56.01202634124529, -3.604050373904407 56.00917932345049, -3.602862150214454 56.009207714371975, -3.602697188302506 56.00835519136248, -3.599483435694493 56.007674891141804, -3.594581185875172 56.008137244874945, -3.593747080255517 56.00735892517704, -3.594435574922193 56.00667114500784, -3.594242841958433 56.00549647246569, -3.597459575290791 56.005329030403544, -3.600398607364988 56.005870175538, -3.600485272667778 56.00364535313928, -3.613148609962722 56.002421425122456, -3.614176852524953 56.004311534265554, -3.615297365967155 56.004260917020474, -3.61811031426773 56.00701157545887, -3.615104978081516 56.00683200106393, -3.615378429197752 56.006587233283874, -3.612637962138941 56.00568193515527, -3.613403239363711 56.00575942130879, -3.613623845231385 56.00528027419457, -3.613060061455874 56.004451957135124, -3.611078656065758 56.00522585937067, -3.609738560008399 56.004924038447285, -3.610126648179607 56.00718610353364, -3.611708546765308 56.0081988269056, -3.612766933120264 56.00822794090587, -3.609630085546298 56.00958003096508, -3.610051513056689 56.011030828752084, -3.6110490627559 56.01123572137157))
SPARQL API: The Basics

The most flexible way to access the data is by using SPARQL, a query language, analagous to SQL for relational databases, for retrieving and manipulating data from graph databases like ours. We support SPARQL 1.1 query syntax. Many online tutorials are available.

To submit a SPARQL query from your code, you issue an HTTP GET or POST to our endpoint:, with the query itself as a url-encoded parameter called query.

For example, to run the following simple SPARQL query and get the results as JSON:

SELECT * WHERE {?s ?p ?o} LIMIT 10

Option 1: POST (recommended)

Issue a POST to the endpoint, with the query in the body, and an Accept header of sparql-results+json:

Accept: application/sparql-results+json
Content-Type: application/x-www-form-urlencoded


Option 2: GET

Issue a GET to the following URL (note the .json extension - see the formats section for more detail on this):


Scroll down to the end of this page for examples of both of these methods in a few different languages.

Results formats

As with other aspects of our API, to get the data in different formats, you can use either (a) a format extension or (b) an HTTP Accept header. Available result formats depend on the type of SPARQL query. There are four main forms:

SELECT queries return tabular results, and the formats available reflect this:

Format Extensions Accept Headers
XML .xml application/xml,
JSON .json application/json,
Text .txt, .text text/plain
CSV .csv text/csv

CONSTRUCT and DESCRIBE queries return graph data, so the results are available in the same formats as our resource APIs:

Format Extensions Accept Headers
RDF/XML .rdf application/rdf+xml
N-triples .nt, .txt, .text application/n-triples,
Turtle .ttl text/turtle
JSON-LD .json application/ld+json,

ASK queries return a boolean result:

Format Extensions Accept Headers
XML .xml application/xml,
JSON .json application/json,
Text .txt, .text text/plain
Results pagination

We accept page and per_page parameters for paginating the results of SELECT queries (we automatically modify your query to apply LIMIT and OFFSET clauses). For other query types (i.e. DESCRIBE, CONSTRUCT, ASK), pagination like this doesn’t make so much sense, so these parameters are ignored.

For requests made through the website (i.e. HTML format), the page size is defaulted to 20. For requests to our sparql endpoint for data formats (i.e. non-HTML), there will be no defaults for these parameters (i.e. results are unlimited. For performance reasons we generally advise LIMITing your query if possible).

Parameter Substitution

You can parameterise your SPARQL by including %{tokens} in your queries, and providing values for the tokens in the request parameters.

Note that the following tokens are reserved and cannot be used as parameters for substitution:

  • controller
  • action
  • page
  • per_page
  • id
  • commit
  • utf8
  • query
Cross Origin Resource Sharing

Our servers are configured to allow access from all domains. This means that if you’re writing JavaScript to request data from our server in to a web page hosted on another domain, your browser should check this header and allow it.

If you need to support very old browsers, you can additionally pass a callback parameter and the results will be wrapped in that function. For example:

This help topic on the jQuery website has more details.


Using cURL

Here’s a couple of examples running a query using the widely available cURL command line program.

Request the results as XML, using a POST:

curl -X POST -H "Accept: application/sparql-results+xml" -d "query=SELECT%20*%20WHERE%20%7B%3Fs%20%3Fp%20%3Fo%7D%20LIMIT%2010"

Request the results as JSON, using a GET:

curl -X GET -H "Accept: application/sparql-results+json"*%20WHERE%20%7B%3Fs%20%3Fp%20%3Fo%7D%20LIMIT%2010

Using JavaScript

This example HTML page uses jQuery to issue a POST to our SPARQL endpoint, requesting the results as JSON.

<!DOCTYPE html>
	<script src=''></script>
<script type='text/javascript'>

	var query = 'SELECT * WHERE {?s ?p ?o} LIMIT 10';
	var url = '';
		method: 'POST',
		dataType: 'json',
		url: url,
		data: {query: query},
		success: function(data) {
			alert('success: ' + data.results.bindings.length + ' results');