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.3219479813592248 52.07430190693035, 0.3246739055380437 52.072783265722954, 0.3257144923332924 52.07115755056674, 0.3250459345116435 52.069945950035844, 0.3279020493377196 52.06832843944847, 0.3319664825517503 52.062827309666005, 0.3356739477448556 52.06026021362102, 0.3375215150508392 52.05982519923327, 0.3395426121419973 52.05751983417234, 0.3417730078498516 52.05629118986648, 0.3413488745061004 52.05482032568323, 0.3440578178410948 52.05323500708717, 0.3438568764239803 52.05101331760211, 0.3459593119941615 52.04971699022463, 0.3520746900515924 52.04704652411468, 0.3633238100710012 52.04469821519201, 0.3638356364025899 52.04361961081371, 0.3561552901095215 52.039893112006595, 0.3530075902465294 52.04034900893905, 0.3465200177385816 52.03837591920852, 0.3447745699580737 52.03957343174053, 0.3408135511913082 52.03869898094742, 0.3365944096107336 52.035864612843845, 0.3317850489966233 52.03330526669258, 0.3251685208380649 52.027629479165725, 0.3234795397851473 52.02660166996315, 0.3127084692629456 52.02390091697975, 0.3065796860663454 52.02601297254214, 0.2917273359663523 52.03164270611943, 0.2897020448316048 52.033806149313826, 0.2885878801824588 52.03616948072703, 0.285561272889412 52.0384053548309, 0.2820362454958931 52.040853138450274, 0.2811093675832658 52.04275324258744, 0.2817372091815984 52.04880569587501, 0.2809502939781569 52.050765132524134, 0.2817383326073034 52.05695295766789, 0.2748953117265684 52.063782917837955, 0.2813497873015935 52.06461224006183, 0.2826185559368181 52.06339975521923, 0.2863373620414865 52.065995747331705, 0.2852429624738806 52.067879328805546, 0.2904872852182741 52.07044919305526, 0.2937937044049285 52.071271548010564, 0.3001872977036361 52.07534285432669, 0.3050816771134898 52.081566279674426, 0.3087023895449462 52.08028411630398, 0.3110650033252396 52.076943837712044, 0.3167687927085894 52.07610524477105, 0.3219479813592248 52.07430190693035))) geosparql: asWKT POLYGON ((0.322 52.074, 0.344 52.051, 0.364 52.044, 0.341 52.039, 0.324 52.027, 0.313 52.024, 0.292 52.032, 0.286 52.038, 0.282 52.057, 0.275 52.064, 0.286 52.066, 0.305 52.082, 0.322 52.074))
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');