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 (((-2.922615162056894 53.474983216225375, -2.914377633166293 53.46500516794063, -2.9049245094520977 53.46524521084104, -2.9059288118969353 53.47017872290091, -2.8914403892494236 53.463115561487186, -2.8684317878233947 53.44994748272357, -2.8734161031154786 53.43651874533677, -2.868346978284319 53.4264378305137, -2.8687139084691795 53.415569446617674, -2.8711629876066374 53.41238485651499, -2.884096712300838 53.416876051797, -2.892364304582738 53.41182853467201, -2.890542343174609 53.40692610088485, -2.8816732731373076 53.40802373612355, -2.8753540258435484 53.40100490541507, -2.856219859498804 53.394960108128885, -2.8373451222356576 53.3998680077274, -2.8336499344948938 53.38894098322208, -2.8219548716422733 53.38066707334555, -2.84443159479495 53.38205712085052, -2.856189302794325 53.378750113333204, -2.8534958455484496 53.36351448449813, -2.8404056273744143 53.3473310654553, -2.81880693875443 53.34800072855086, -2.8187799089058094 53.339771535622084, -2.832457337582251 53.33728947205984, -2.8257569131569893 53.33181396801964, -2.8364103209301534 53.32701801645988, -2.8549727517735475 53.32747167328005, -2.8781584345565956 53.33419880629802, -2.9098693708225123 53.34954026884841, -2.922438467243119 53.3572523278341, -2.9457360206853 53.3671902652609, -2.969299951499328 53.37580431904332, -2.984972614830215 53.38650334251767, -3.0017631356622196 53.41104897252118, -3.0086206910678572 53.43785547563869, -2.975307287264877 53.44324704302676, -2.9730116953415293 53.44992098835524, -2.972565433078903 53.45840190155515, -2.96984181113753 53.4659773542737, -2.9601789408359904 53.46800146089589, -2.956306598299554 53.47299343509463, -2.922615162056894 53.474983216225375)))
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');