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.9116745216007005 56.09565542922543, -3.9117076227129495 56.09502586681257, -3.9127465655764238 56.093607888971256, -3.915256445071923 56.09397336836049, -3.916138155096391 56.0936002177544, -3.9160297427282056 56.092712243436544, -3.9154983379428354 56.09237002027602, -3.9162466017934237 56.09190009749964, -3.917963065794097 56.09182850531522, -3.9190845903558813 56.09182508283963, -3.9198069985829926 56.09207247864443, -3.920745907334847 56.09186610968492, -3.9223056686904325 56.09123074900716, -3.9232156276771377 56.08981468686257, -3.921533057059805 56.088951234261344, -3.921518257581578 56.08833139039191, -3.9198126561101687 56.088295036062874, -3.9194851574719762 56.08785080725342, -3.92000405871867 56.08711843711091, -3.9210959152691394 56.087468363761246, -3.921794828804538 56.08745748301221, -3.9233366504549454 56.086562543090515, -3.9234458594661006 56.086242289129345, -3.925476961695385 56.08652861354517, -3.926883648331868 56.086021354649226, -3.9274364339707932 56.0854982476947, -3.926049075896116 56.08378551814717, -3.9262883062731166 56.08320000038592, -3.9291653659547943 56.0833444507591, -3.9288822727517982 56.08456594079171, -3.930117972821441 56.08496575102459, -3.928722466449051 56.08518160330911, -3.9284481232655826 56.08551687106101, -3.9295441330282546 56.086597087886, -3.9303790565812537 56.086622880437154, -3.930771279548503 56.0875198678229, -3.9299542597513333 56.0878790388449, -3.931057824156092 56.088811566789296, -3.9333734202595654 56.08939808768444, -3.9319003846803047 56.090550743634616, -3.9338106250148814 56.09402555400062, -3.932659585269776 56.09418366288373, -3.9322423834316633 56.093395251547165, -3.9325613854993873 56.09219390659968, -3.931804826289389 56.09153176460978, -3.931185888019512 56.09267340366574, -3.9291560383305124 56.09425545430173, -3.930114152827876 56.094807692682146, -3.9289178843208115 56.09562765229659, -3.9279744725558072 56.095166351622176, -3.9261296159463943 56.09662858232854, -3.92306422600545 56.095030167342685, -3.922424500589075 56.09522786816063, -3.9177740081808463 56.09610898791413, -3.9172086595869477 56.095453555685744, -3.915116523947303 56.09594032398286, -3.9144673577704596 56.09516062157789, -3.913491111364416 56.09565424150206, -3.913223782407182 56.096098720238814, -3.912570486416474 56.09621668139105, -3.9116745216007005 56.09565542922543))
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');