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.7954024699396647 56.031432173328604, -3.795325880392668 56.0297900017697, -3.795760001982428 56.02924443190449, -3.795397399160628 56.027482323574596, -3.7956991222365213 56.02721987112578, -3.7975940805562383 56.027026223812676, -3.7977697915208313 56.02785133627279, -3.7987078071004836 56.028930437057724, -3.8002300017622996 56.02899706455646, -3.7978731195023667 56.03016620015548, -3.7995440424585545 56.03084257203639, -3.8004634545821965 56.030649615608716, -3.800506256483361 56.03122411373936, -3.8013590289930717 56.03102824148152, -3.802752765116233 56.031559733897645, -3.8029930932912377 56.032239179480385, -3.8094329086610577 56.03094968556616, -3.8070611920268713 56.029995966208496, -3.8082590715248634 56.02952909240087, -3.8104231346585653 56.03050380995383, -3.8135361981920264 56.03049401611727, -3.814854626005583 56.03157095270986, -3.8159904144839696 56.03114985786035, -3.8177191885787116 56.03241841170501, -3.8187882948785123 56.03228582744586, -3.820712454243556 56.03156548821465, -3.822858463405331 56.0331693007316, -3.82043640571326 56.033820037316985, -3.818667941191818 56.034161449349796, -3.8133321232604627 56.03540363652769, -3.813552603813773 56.035633949029986, -3.8167044757019646 56.037124223303245, -3.8152134663532196 56.037255800290154, -3.813088483580172 56.03597893671017, -3.809808182710398 56.03663830076836, -3.8095344369327973 56.03620518744188, -3.8070653789300333 56.03660982613018, -3.8020887431905717 56.037284722334554, -3.797915121570325 56.03818251592714, -3.797139611301377 56.03769028075094, -3.795350366347488 56.03493872406604, -3.7939708746857153 56.03411172360528, -3.796485224357837 56.034126966640706, -3.7954024699396647 56.031432173328604))
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');