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
http://opendatacommunities.org/id/geography/administration/lonb/E09000011 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/administration/lonb/E09000011 geosparql: asWKT MULTIPOLYGON (((0.0753431550912862 51.431990777230524, 0.0748359228257787 51.43083074879884, 0.0743047383562405 51.431490330235725, 0.0733278115065356 51.43177372950302, 0.0730350886084387 51.43137874894334, 0.0734714278180729 51.431259550779295, 0.0716365367665401 51.42943496247251, 0.0669350155080585 51.42672208185275, 0.0664041013369518 51.42633757889314, 0.0665794444511273 51.42601524182632, 0.0647144736241984 51.42561729834185, 0.0633421099770503 51.424274583540836, 0.0617081805522964 51.423734973292795, 0.0608999244479546 51.42507921449303, 0.0585965479329062 51.424590978420895, 0.0563912846515151 51.42615759491093, 0.051049015851951 51.431529943446144, 0.0477848914561561 51.43375340696228, 0.0451469807062741 51.43621946639108, 0.0451828477187109 51.43660281383897, 0.0433116390573901 51.43774520823307, 0.0421846683496523 51.439480639797075, 0.0398141789498976 51.44098598017131, 0.0355435221910105 51.44244598089114, 0.0334705217540713 51.443591718230245, 0.0305856944049817 51.44431707655325, 0.0293589651101684 51.44170526267685, 0.0277675030669924 51.4415106567634, 0.025416198197835 51.44173830836781, 0.0214828870067013 51.44273516962249, 0.0205968318623052 51.4442109086218, 0.0214964407934503 51.44444451646319, 0.021210037428165 51.44669134581036, 0.0229423445126153 51.447204651836145, 0.0221313986053101 51.44871866152462, 0.0219275764092144 51.44895862036867, 0.0150637493536863 51.4500318446176, 0.0148759487233062 51.45060433274004, 0.0151227709547957 51.45022690582101, 0.0198715808833579 51.4507351110793, 0.0195359466804762 51.45170491397509, 0.0183316240520364 51.45158262174696, 0.0175138883176911 51.455039138135284, 0.0140305362903002 51.4557267326359, 0.0115161786784882 51.45661525233513, 0.0099474139029279 51.459340925104954, 0.0090970555998752 51.46587428140256, 0.0132454141721062 51.46683195180097, 0.0126911411110183 51.46735759521898, 0.0130689246209117 51.46812183714403, 0.0126017504147206 51.46980697518286, 0.0134811402459409 51.46989706022697, 0.0163305896835293 51.468981255425135, 0.0165329765848621 51.46913150649097, 0.0166942620193693 51.46949112669632, 0.0153575917484328 51.4715698953, 0.0149848584722279 51.4730799091717, 0.0181235572098231 51.47385319984573, -0.0003591330301333 51.471834516575456, -0.0081434985614601 51.47275654118851, -0.0125188913159415 51.47234074134311, -0.0140694883644863 51.4726754675593, -0.0145286028020849 51.4719179133202, -0.0151844793174256 51.47176899422596, -0.0131289919470357 51.46893653549096, -0.0150901755775237 51.468036309855854, -0.0165589820593603 51.46922754851677, -0.016949395028992 51.46905605842804, -0.017273911653008 51.469410454369424, -0.0191179940535042 51.469948850321295, -0.0192726722109005 51.47050004134594, -0.0186717112341979 51.47064541576861, -0.0193192191478339 51.47198545801482, -0.0202450633410069 51.472184584417235, -0.0200506240767554 51.47308328089279, -0.0217724386734811 51.474026011888, -0.0226727250509885 51.47398546011542, -0.0229305848497229 51.47508147903329, -0.0227676067679672 51.47535392610696, -0.0211540170851642 51.475237690088704, -0.0204735924979228 51.47568749268896, -0.0206397197545933 51.47646704265204, -0.0198688065445586 51.47688410408136, -0.019554786657285 51.47668633857653, -0.0188419906814057 51.47731727893432, -0.0189807143965673 51.4782036123677, -0.0183724892785164 51.47937767797599, -0.0168866362910832 51.480065669104434, -0.0156815887928658 51.48168286064459, -0.0150255721976126 51.48176620694227, -0.017864481821593 51.48252462975792, -0.0178848185740237 51.483218311075454, -0.0163328615280621 51.48323612888948, -0.0163290035641892 51.48295998789736, -0.0154579321647721 51.48281935200368, -0.0152660205474414 51.48312725095493, -0.0111125743690052 51.48305417246094, -0.0099146020664363 51.48360848577113, -0.0072666003341358 51.48379195859051, -0.0046294419442864 51.4846814549614, -0.003365122559661 51.484872118166656, -0.0020451423985162 51.48564460266395, -0.0023105157986787 51.485900947890116, -0.0016878356445091 51.48623834544858, -0.0016956215814065 51.4858976562891, 0.0001314246121459 51.48686738260121, 0.0016387929768576 51.488495396433585, 0.0019627883240528 51.48846019736567, 0.0024470618659426 51.48994471345911, 0.0023634877648945 51.49300272276806, 0.0019547856520202 51.492913507036455, 0.0015581981851814 51.49402099470952, 0.0009543650287609 51.494411705647224, 0.001242144219634 51.49479885392745, 0.0008621635182394 51.49549596217567, -0.0002861062696058 51.49523316789181, -0.0010391588190741 51.49639350597874, -0.0022671028842289 51.50013920804588, -0.0023028658991926 51.501298113240665, -0.0018730194479146 51.50130966922326, -0.0019218224983925 51.50190490568072, -0.0015416626759048 51.502032397253686, -0.0020207269997223 51.50214847427952, -0.0017014768553165 51.502925416328985, 0.0008252812910245 51.504523477904215, 0.0032972381430941 51.50486796254078, 0.0051458118344653 51.50430674170102, 0.0081523961869293 51.50173280272159, 0.011487552249051 51.498877149145656, 0.0153909914337107 51.49611262297114, 0.0156998818144995 51.495893838313265, 0.0191984550084745 51.494766214793955, 0.0217029117667142 51.49445417811552, 0.0215768672256202 51.49401483800271, 0.0219800637610262 51.49394581032523, 0.0223039166207472 51.49429636902152, 0.024379319235196 51.493862146790605, 0.0290190782445743 51.49391595982273, 0.0402481777672712 51.49545131113006, 0.0577076819166276 51.49445828340847, 0.0580282022493901 51.49405878666631, 0.0580905379289442 51.49445065513574, 0.0588314396809908 51.4944592368425, 0.0589394178427996 51.49420194887244, 0.0591651361994732 51.494479448302435, 0.0640562134967026 51.494513103189604, 0.0641104741948814 51.49472522925275, 0.0703267793807947 51.495166913953824, 0.0759257876400698 51.49609936442052, 0.0762073557563411 51.495891199756144, 0.0824037603584234 51.49886132054716, 0.0838098003339356 51.500412542016704, 0.0866308344251697 51.503524488922785, 0.0875906305819637 51.50396963352096, 0.0879269070056224 51.50555627076444, 0.0920247031180862 51.50900751837688, 0.0945902961516858 51.50895363235905, 0.0973170432066647 51.50949032134668, 0.1002439180380399 51.50967715561765, 0.1068781540511808 51.509410668946984, 0.1134883888479629 51.51015232961586, 0.1201856950783372 51.511439853568454, 0.1205351571069195 51.51104307720287, 0.1214484493011029 51.48763980331472, 0.1220736663237354 51.48556368900247, 0.1221349362128396 51.48223077645016, 0.124160725617541 51.47682355508119, 0.1207309263259805 51.47851154220727, 0.1184543153532366 51.47891959568857, 0.1119756790331806 51.473074207841144, 0.1082255916651352 51.47612648053849, 0.1061624990159059 51.47501424357252, 0.1056361120693819 51.47546700986364, 0.1051911210738954 51.47524574895326, 0.1048914455276202 51.47552443430128, 0.1033770156579209 51.47459837443148, 0.1024703946440957 51.47492399268669, 0.1020017971788546 51.4744729017696, 0.1001992986354233 51.475234497033, 0.098223943663842 51.47546234863465, 0.0965490161284144 51.47322883102691, 0.094471688706078 51.473274053181726, 0.0931711209696502 51.4729519646675, 0.0912641669032835 51.47206242585404, 0.0890478590512743 51.47041842095563, 0.0857631473044769 51.46943286729121, 0.0847967473508698 51.468731554250944, 0.0832182596069365 51.466478963669026, 0.0822955470988501 51.46664108932871, 0.0821757297801811 51.46473674153988, 0.0826299146916277 51.46361352060902, 0.0822309029873953 51.460983941384676, 0.0828782910403532 51.45983481082092, 0.0786371194231795 51.45929318013943, 0.0814198169218273 51.457774432766826, 0.0856839465883999 51.45664551908672, 0.0867962092528561 51.450451283381135, 0.0880392258325358 51.447506401427546, 0.0872811741677808 51.445746566870724, 0.0862943055244913 51.44531174482294, 0.0873801483173789 51.443246578910994, 0.0863205108307555 51.44323667612448, 0.084711979404138 51.44261152212461, 0.0832160863300636 51.44354272285452, 0.0828102335138226 51.443288317628046, 0.0828258328110514 51.44284104343164, 0.0844155246157332 51.44201066852503, 0.0817854573466801 51.43996204263368, 0.0808516326092067 51.44040575435497, 0.0787900388367468 51.43813389834459, 0.0790361116506991 51.437977597236106, 0.0778199503089365 51.436447887765226, 0.0765445448719957 51.436879640388966, 0.0749603403525447 51.43586185644797, 0.0765031455450457 51.43485512837412, 0.0758895795441354 51.43445954657901, 0.0763882613852407 51.434003804633946, 0.0756546977214572 51.433627338658724, 0.0760800568105753 51.43329966006249, 0.0746527075038013 51.432151430756555, 0.0753431550912862 51.431990777230524)), ((-0.0171060977091606 51.48043110933014, -0.0178753577287915 51.48088007315222, -0.0184008704133645 51.480848500326786, -0.0204180427975278 51.48023061115621, -0.0203674041798792 51.479935688812866, -0.0230709275377545 51.47962871178291, -0.0231613257851619 51.48073727837153, -0.0264086808328232 51.481509574491845, -0.0258191115640644 51.482188471006864, -0.0252012917384894 51.48502163897611, -0.0247311470807264 51.485493723164076, -0.0226137979427268 51.48453734918814, -0.0188186214113593 51.48350566858846, -0.0181898625346104 51.48199595034268, -0.0165217228680918 51.48163862231175, -0.0171060977091606 51.48043110933014)), ((-0.020483670950859 51.476761047573966, -0.0205911508685803 51.47667290278564, -0.0205784118610071 51.47672699102688, -0.020483670950859 51.476761047573966)))
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:http://opendatacommunities.org/sparql, 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:

POST http://opendatacommunities.org/sparql HTTP/1.1
Host: opendatacommunities.org
Accept: application/sparql-results+json
Content-Type: application/x-www-form-urlencoded

query=SELECT+%2A+WHERE+%7B%3Fs+%3Fp+%3Fo%7D+LIMIT+10

Option 2: GET

Issue a GET to the following URL (note the .json extension - see the formats section for more detail on this):

GET http://opendatacommunities.org/sparql.json?query=SELECT+%2A+WHERE+%7B%3Fs+%3Fp+%3Fo%7D+LIMIT+10

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,
application/sparql-results+xml
JSON .json application/json,
application/sparql-results+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,
text/plain
Turtle .ttl text/turtle
JSON-LD .json application/ld+json,
application/json

ASK queries return a boolean result:

Format Extensions Accept Headers
XML .xml application/xml,
application/sparql-results+xml
JSON .json application/json,
application/sparql-results+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:

http://opendatacommunities.org/sparql.json?callback=myCallbackFunction&query=SELECT+%2A+WHERE+%7B%3Fs+%3Fp+%3Fo%7D+LIMIT+10

This help topic on the jQuery website has more details.

Examples

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" http://opendatacommunities.org/sparql

Request the results as JSON, using a GET:

curl -X GET -H "Accept: application/sparql-results+json" http://opendatacommunities.org/sparql?query=SELECT%20*%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>
<html>
<head>
	<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
</head>
<body>
<script type='text/javascript'>

	var query = 'SELECT * WHERE {?s ?p ?o} LIMIT 10';
	var url = 'http://opendatacommunities.org/sparql.json';
	$.ajax({
		method: 'POST',
		dataType: 'json',
		url: url,
		data: {query: query},
		success: function(data) {
			alert('success: ' + data.results.bindings.length + ' results');
			console.log(data);
		}
	});
</script>
</body>
</html>