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 (((0.0753693951504255 51.43199083083797, 0.0632281947741456 51.42420331495948, 0.0582257294310433 51.42488297584224, 0.0397748482258741 51.44099634619814, 0.0306119831290832 51.44431732462183, 0.0293852601429619 51.441705437173795, 0.0215090836021026 51.442735354210534, 0.0224278257409255 51.448126033108906, 0.0195619578167705 51.451705118024115, 0.0115105474408386 51.45668522634293, 0.0093056105175933 51.46403689651552, 0.0181492810074551 51.47385363931756, 0.0121145840778962 51.47317313850896, -0.0140436035165298 51.472675629309876, -0.0171358783651108 51.4693403346949, -0.0227772107400153 51.47446446197471, -0.0242298586589571 51.48534128042317, -0.0178584835953299 51.483218688560655, -0.0046031828606428 51.48468183284657, 0.0024734079481083 51.489945239860894, -0.0022402236032033 51.50013985396806, -0.0009877512284907 51.50404772066389, 0.0038186626554795 51.50497691195731, 0.0157263918015395 51.49589445014766, 0.0290454012018176 51.4939165280047, 0.04009045613565 51.49548824402259, 0.0599730130710432 51.49472417466289, 0.0762345331368603 51.49589157182861, 0.0824310813814985 51.498861713994295, 0.0920520994393599 51.5090081154771, 0.1187994350028844 51.51132077913224, 0.1241884303972963 51.476823861726714, 0.1184818897133539 51.47891994390148, 0.1117998535633301 51.47319508455789, 0.1082529586937322 51.47612675854989, 0.0982511856509054 51.47546263702323, 0.0823223736483523 51.46664130895239, 0.082904988729318 51.45983502367061, 0.0860482438869002 51.455619913383195, 0.0874066833398033 51.44324664757257, 0.0828367202461669 51.44328837753334, 0.0753693951504255 51.43199083083797)))
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');