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 ((-4.598836842828119 55.447976413061575, -4.599352511682237 55.446680057107336, -4.599827144109909 55.44620255084608, -4.600128836282657 55.44490260461126, -4.5999640467751375 55.444437836989685, -4.601045200656119 55.44404630576007, -4.605724871444731 55.442832069985684, -4.605078898371911 55.44166829865345, -4.60380984244881 55.44217266843544, -4.6024932301681565 55.44252013043722, -4.6014962822694665 55.44152614793336, -4.602018101661263 55.43936940929142, -4.602882505273498 55.440075061261744, -4.603587631440001 55.43981747824546, -4.604175252144119 55.44046160709977, -4.6048313379764325 55.44019023871219, -4.604110780691226 55.439615631954574, -4.604105761914285 55.439212392936696, -4.606272883043953 55.437714744885255, -4.606246647232563 55.437077097984655, -4.607904840078762 55.435857044110925, -4.609109685950911 55.434463214758374, -4.61017065306769 55.43544732015055, -4.612264826149254 55.438189137406276, -4.614077422502861 55.439777380970845, -4.615393432895441 55.44054924773, -4.61686083758942 55.4412189838802, -4.615636967690748 55.441362023050694, -4.615383049200048 55.44182588466714, -4.613857604304262 55.44219108722423, -4.614101602862463 55.44348925216651, -4.615191152423627 55.44346595662101, -4.616090665974883 55.44393452302997, -4.615455988267891 55.44452959541403, -4.616282376170626 55.444898806928485, -4.616361718025866 55.44538250655472, -4.615350025772445 55.44610527576444, -4.616397926015478 55.44701473332159, -4.614597254818325 55.44773065103976, -4.613961607981765 55.448326409312195, -4.612546933183682 55.448311505354226, -4.611135231391826 55.4486272740916, -4.610480582353066 55.44892303991021, -4.610348264713441 55.448908785439684, -4.606502902102291 55.450312155088426, -4.605303407525443 55.44987029549421, -4.605616330791394 55.44909958082624, -4.604624741081767 55.44893193815673, -4.602732030247977 55.44828908457785, -4.602421576114763 55.44765748674443, -4.603377460189411 55.44704388142131, -4.600285337103653 55.44607086740016, -4.600050255835452 55.446661449437435, -4.60156376943352 55.447160400944405, -4.600713355027771 55.447536413335776, -4.600184680789076 55.44833643013337, -4.598836842828119 55.447976413061575))
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');