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.5694937840530383 51.67339738022853, -0.5657179767309185 51.672686721591674, -0.5658809916234607 51.67148668564314, -0.5671273913186299 51.6719095983645, -0.5705600402879096 51.67156639173015, -0.570827868685514 51.671069350576275, -0.5696769578859324 51.670288239268444, -0.5695687840802683 51.6696972257122, -0.5682136057408751 51.669442194467216, -0.569958088165706 51.66824371899046, -0.5707551051459335 51.66879184356069, -0.5725351692860022 51.669392080609846, -0.5728607178579431 51.66899129367722, -0.5748069839700733 51.66944510793864, -0.5743741692328811 51.66813806550613, -0.5758058200045839 51.66756884192689, -0.5762624794538096 51.66711062317703, -0.5745662103858455 51.666847064205314, -0.5727911341185928 51.666054746401876, -0.5738236294745807 51.66420679789641, -0.5726068530420764 51.66413949591991, -0.5708524257895944 51.66510472311892, -0.569590823103474 51.664737912593445, -0.5679353600834537 51.66308740552378, -0.5667190970604113 51.663275056326896, -0.5684144106605423 51.66201022394359, -0.56888859185741 51.66115835087595, -0.5683935433498333 51.66088129082652, -0.5711812854843923 51.6591174204807, -0.5708772812893431 51.65894343187671, -0.5722920867150663 51.65751648561663, -0.5816532468984907 51.65306735122729, -0.5835018797656955 51.65448023741678, -0.582569436494467 51.65503017683989, -0.5831192541081903 51.65542009545819, -0.5822653995083736 51.656143101068906, -0.5800602375746517 51.65724110090246, -0.5795526248020636 51.657321102131455, -0.5786584232397274 51.65634419755562, -0.5737761271175844 51.65754839465552, -0.5731871227696008 51.65807532786303, -0.573259863680322 51.65926726578538, -0.5746447162900327 51.658604279728095, -0.5759057491802213 51.66025714949562, -0.5744116045222227 51.66070216318813, -0.5752955648202664 51.66306900787737, -0.5775299260653658 51.66506118262393, -0.5783463987847075 51.66433774215614, -0.5806040075966827 51.66501175143933, -0.5796634194682706 51.66581365233348, -0.584292552153391 51.666820563152825, -0.5835051968183051 51.66761456859346, -0.5810269863267232 51.67073036497663, -0.5806696125157345 51.67066172877497, -0.5791413335778053 51.674058197477684, -0.5750156820679273 51.67280131506596, -0.5725782090505339 51.6731093666225, -0.571467303406398 51.672823432532915, -0.5694937840530383 51.67339738022853)))
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');