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.972991285277553 55.8665161515148, -3.968432709241351 55.86683816186989, -3.967479152859966 55.866124326696706, -3.964262768524225 55.866152215895326, -3.963074589943853 55.86705265960751, -3.962800496301129 55.86605227596791, -3.957580113370068 55.86583886049406, -3.956684555521337 55.86513001033916, -3.958305810132074 55.86405463332824, -3.957607967395151 55.86375152042141, -3.956305437641497 55.86444929385072, -3.95538618529258 55.864401606286734, -3.95463092919629 55.863441337042964, -3.956790518934596 55.86284982311691, -3.955643167698615 55.86196040636176, -3.953755577996953 55.863194626274826, -3.952646341596104 55.86274492418844, -3.954221183650118 55.86196502937847, -3.953404716195553 55.8609804543118, -3.955821071359874 55.859459236582026, -3.952971610172185 55.85903719287726, -3.95287890280741 55.85789281509916, -3.954665180102249 55.85776112978554, -3.955213622976823 55.859022010207056, -3.957637132908694 55.859329657505015, -3.960730895222445 55.85813410419767, -3.959108985035781 55.8568456778382, -3.961206719144571 55.85647642545825, -3.96209627321611 55.857252598496856, -3.96334242583591 55.85684832790528, -3.963905774930235 55.85818012427219, -3.964793702325959 55.85741105424926, -3.964868352083382 55.85794008371029, -3.967526479968746 55.85742129471675, -3.970124093538046 55.85570817263525, -3.970840730131327 55.855346206093245, -3.972108656687435 55.85608977050718, -3.976747507087492 55.85650959363799, -3.974895564254441 55.85716841515191, -3.975002279610051 55.85769692488975, -3.977923487532756 55.85858463102773, -3.977663064096237 55.86037720360452, -3.975849724052763 55.86117021636119, -3.976298206841489 55.86154003109569, -3.975277623683182 55.86186240613671, -3.974738424668688 55.86131387635016, -3.971218444994941 55.86122653746327, -3.969526084448358 55.862139947395114, -3.970728199285409 55.863220490831935, -3.971293928260922 55.863031684201715, -3.973764695102792 55.86416934996929, -3.974832257214475 55.864107282404255, -3.974908425851813 55.864663245419024, -3.971856161161805 55.86529635235253, -3.972991285277553 55.8665161515148))
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');