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.723877744205561 51.21141453522681, 0.7169760894709628 51.211200911131606, 0.7162351988066857 51.20943996949607, 0.7120933205632933 51.20606343796927, 0.7102831561190358 51.20398457523601, 0.7097819325290949 51.199617825476096, 0.7023510007120204 51.200748554746674, 0.6994112117167608 51.19995301210983, 0.701837933364529 51.1973390334612, 0.6992995537191851 51.19630486400444, 0.6962202015360309 51.19421640822198, 0.6933490639998033 51.19542302909046, 0.6907669616838893 51.1944193640446, 0.6876677064285217 51.192299665729514, 0.6837463536948963 51.191126052613704, 0.681860108279075 51.187974613415136, 0.6837153591625669 51.18675021955992, 0.684934438675924 51.18438195950475, 0.6840942579275321 51.18130096722784, 0.6849473974185611 51.17869556211391, 0.6783737247401752 51.179138637793095, 0.6750951654754461 51.179676890199964, 0.6693559441683028 51.182480205851014, 0.6625460326981047 51.183603233128615, 0.6606983504646887 51.18456898442882, 0.6579462210057299 51.18732710474979, 0.6556871973044135 51.188286833549455, 0.6568040161774237 51.18996224755752, 0.6603285006398896 51.193254903824496, 0.6612165158445885 51.196593090212374, 0.6608165637005955 51.199886829476384, 0.6642675250853242 51.2015396212704, 0.6687437064977344 51.205889637616536, 0.6712105479166536 51.206952186255265, 0.6725971793909614 51.21133931078019, 0.6726962276979779 51.213592769604084, 0.6757166795556456 51.216191362227576, 0.6758254019051188 51.21737429856486, 0.6814437719217752 51.21703246896359, 0.6826421651625331 51.21845574209424, 0.6883995409352984 51.216418596352, 0.6938805310275483 51.21750399916834, 0.6948620524344 51.2181991215695, 0.697980643540954 51.21596053773348, 0.7019435558943975 51.21672440117613, 0.7057720585100725 51.21936922008993, 0.7111359213205657 51.22439326968022, 0.7150898948477532 51.22372413032599, 0.7210800108979869 51.22064383566917, 0.7221843595770141 51.217952262817995, 0.7215943030380831 51.213971676361105, 0.723877744205561 51.21141453522681))) geosparql: asWKT POLYGON ((0.724 51.211, 0.708 51.2, 0.684 51.191, 0.685 51.179, 0.678 51.179, 0.662 51.184, 0.657 51.19, 0.673 51.214, 0.682 51.218, 0.702 51.217, 0.711 51.224, 0.721 51.221, 0.724 51.211))
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');