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 MULTIPOLYGON (((-0.4606728043812731 52.2860186568307, -0.4613092684388999 52.28368475641319, -0.4655675654792308 52.284805635868686, -0.4674558643540691 52.283573201311, -0.4686028352098929 52.28100492462319, -0.4728054705643512 52.277087052008184, -0.4768449764071304 52.27619784567911, -0.4760331164623653 52.27486656643355, -0.4730663062114104 52.27354699849463, -0.4698552374904645 52.272814014527505, -0.4707337296348401 52.27100827227644, -0.4744888426799826 52.269977892842135, -0.4774834647759426 52.267611388036116, -0.4808788602552363 52.26761734758278, -0.4853669648533548 52.2691459521789, -0.4881413171464172 52.26763589729969, -0.4925341602607201 52.26636132974238, -0.4965554259222241 52.26566719930996, -0.4941269639974936 52.26337947510232, -0.4989964331088373 52.26181493147663, -0.5014535137954238 52.25943018344603, -0.5049319376700332 52.26165552198, -0.5100654273511005 52.25555958870975, -0.5098545341038109 52.25345747645891, -0.5130955086569481 52.25322947339634, -0.5152503962072322 52.26100520921733, -0.518305266862561 52.263520636363936, -0.5154615995522452 52.26587300234899, -0.5191776179759359 52.266192068437825, -0.5202600076552376 52.26845612447097, -0.5244263321963756 52.26695994902727, -0.5259598442058012 52.26840059700948, -0.5298931721599341 52.27071088333287, -0.531190162743437 52.27040243245115, -0.532523698519464 52.27253911987602, -0.5341650049646377 52.27761522279061, -0.5343146511347675 52.28156869135119, -0.5381466443288581 52.28482420005463, -0.5411510596874716 52.28789314058283, -0.5419694000981642 52.28994242931832, -0.540604767392274 52.29149184010838, -0.5168661194193688 52.31295216524629, -0.51360187536583 52.31208037931241, -0.5089406616380989 52.30987098918068, -0.5013405605365672 52.30961212272309, -0.4964053158002271 52.30841652218246, -0.493751438974296 52.305744714807986, -0.4908873300178737 52.304435017836305, -0.4909130396317826 52.30346250656107, -0.4987335346204098 52.300336123937825, -0.4961362042440269 52.29786648864878, -0.4886150816191745 52.29508935242801, -0.4873691326060118 52.29559129755979, -0.4779086446484062 52.29440698462797, -0.4747238692770985 52.29367356748455, -0.4754996270256384 52.29187726451491, -0.4722912181018908 52.29124058116213, -0.4651729809785732 52.288844728140695, -0.4606728043812731 52.2860186568307)))
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');