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/npark/E26000001 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/administration/npark/E26000001 geosparql: asWKT MULTIPOLYGON (((-3.9269751760570366 50.74104810325746, -3.9012038828196776 50.738205518946955, -3.879128679154025 50.72969105763499, -3.8763102610879487 50.726113734828445, -3.881313708989102 50.72006567810511, -3.8608007240927193 50.716835267743704, -3.8475990288302073 50.7197423688138, -3.8080140040955692 50.716238644058436, -3.7706528113203617 50.72579759030872, -3.7638778896710203 50.725865051165265, -3.7564019842592216 50.720797811039084, -3.7375480837355397 50.72353636501529, -3.724225379884333 50.715618419712676, -3.724292421124927 50.709710507845244, -3.6934281819273735 50.699725074844366, -3.679647420024651 50.69064101594654, -3.671409433261834 50.69116608645261, -3.6690464222429835 50.68498271353523, -3.6539373231578467 50.67298367647111, -3.6462516283224446 50.67143759221155, -3.6350689965814205 50.63850765512981, -3.6394779364449272 50.63422693115258, -3.6388386097016765 50.624662246924885, -3.63165999172745 50.61856998394823, -3.6641611689181324 50.605309038601234, -3.6984784010761995 50.604920863205756, -3.7028541153490515 50.5977248791712, -3.7087866960831204 50.59676378360778, -3.6927937183965835 50.58836501733286, -3.6879500101593106 50.58176014244313, -3.6821418283790748 50.58127124934958, -3.6757003371992596 50.56483624034876, -3.676950304179868 50.55434038137416, -3.6930297786064243 50.54391951407882, -3.7052190584192037 50.54142656295449, -3.7283133986634907 50.52944171590648, -3.7667221156857758 50.50565705983679, -3.7657713241860433 50.49343496391949, -3.7705651167880925 50.48270684794709, -3.786772332547405 50.47285510093793, -3.7923872952001663 50.44839906322512, -3.805464888000374 50.42929905186617, -3.819100961315034 50.42181742441551, -3.8377863667022596 50.417442091348114, -3.8742041371646057 50.3944812422577, -3.896025330631062 50.3924338017528, -3.91818176682752 50.39668184829432, -3.9302031063879763 50.393231415804244, -3.9613411225395168 50.40833204965922, -3.9711355272158917 50.40968927340821, -3.977626532563002 50.42681232779487, -3.9851533321269312 50.430236089175104, -3.9816739449454706 50.43612011116553, -3.986457324483217 50.439508621156314, -3.982642924850466 50.44222789122459, -3.9858711864198297 50.449162260012194, -4.003370425404939 50.458524337537106, -4.005650702489077 50.45296674411695, -4.0137733314961785 50.44923449056419, -4.027541370389831 50.460918548836645, -4.0366082296456645 50.4634902331288, -4.039240514129399 50.45551045805377, -4.027967314685207 50.45157761558392, -4.036927663271482 50.44584139203892, -4.031935989546097 50.44069607370865, -4.035462088897555 50.43903292921505, -4.048324353279318 50.44454526420515, -4.055646828324203 50.4406707106776, -4.064012967517576 50.440629267399785, -4.0688303722832 50.456217328128, -4.076896505366551 50.45860512533216, -4.078772282197693 50.45652951172401, -4.082387189699072 50.46113836929119, -4.090332578988318 50.46292790438098, -4.098817884214642 50.460565277206754, -4.09986248908859 50.453419241155416, -4.107432726802468 50.451107335310176, -4.108560107802928 50.463233148153904, -4.1143600394584565 50.47042400132805, -4.103250707952672 50.469981265739925, -4.0995178296086 50.47299356049634, -4.094003881072398 50.48178412677871, -4.097612484188492 50.49031136774991, -4.1118243138757 50.49035232127582, -4.105980401543593 50.49462508599374, -4.107929168003072 50.50020126875104, -4.121880967078895 50.50801923233043, -4.1413886355268446 50.507175359518406, -4.147350487264624 50.500334086793366, -4.156778154112812 50.506873171419045, -4.1368016244334544 50.512008666869185, -4.125360911404767 50.52492958893172, -4.130716705915208 50.53153156812195, -4.121655620506612 50.53338545884631, -4.120544153074739 50.53638376187102, -4.130837958730939 50.547186778962, -4.123758995193055 50.549517849954015, -4.121513865801089 50.55555923663289, -4.12517114896619 50.55571615773346, -4.1256252031160825 50.55996663551615, -4.129174767447806 50.55908415105179, -4.125036365855952 50.564434531044185, -4.1373484616210865 50.58401897774319, -4.1525805695711995 50.59170559916824, -4.163837310126081 50.59345867612909, -4.16577536604123 50.601420320482006, -4.142726282963058 50.62393292570366, -4.128045337060946 50.62890336206146, -4.118551840599411 50.6284450697909, -4.122948082896939 50.63482840353318, -4.114491698782257 50.64821077791812, -4.1054490231662095 50.654815591659435, -4.098172942750724 50.65188215647299, -4.089911235568341 50.654759447448974, -4.086907264681075 50.67578473972396, -4.077283891928231 50.693101163888926, -4.028909497597807 50.728021239752124, -4.013805437288346 50.732576011350986, -4.004547308113017 50.732244071943306, -4.000886303078087 50.72900800876181, -3.9701206217447207 50.740068873848344, -3.947184620855534 50.7381113877038, -3.9269751760570366 50.74104810325746)))
http://opendatacommunities.org/id/geography/administration/npark/E26000001 geosparql: asWKT POLYGON ((-3.9653850548166254 50.740149798428575, -3.947163232578143 50.73811911684335, -3.9269542744591286 50.7410559126792, -3.9011835534467445 50.73821355829244, -3.8800075787658033 50.73119662087682, -3.8811659627792356 50.7200003490611, -3.861353553291051 50.716877776382994, -3.847579956098476 50.719751011946634, -3.8079957509269535 50.71624747672908, -3.770635215287457 50.725806546815804, -3.7563846821950135 50.7208068018161, -3.737531068121376 50.72354545173169, -3.7242085929108035 50.71562757415435, -3.7242756797157766 50.7097196419606, -3.7110868291621864 50.7039153898724, -3.6934118902027864 50.69973440595077, -3.6714227600293436 50.68835895061548, -3.65770577290578 50.67636387857398, -3.64638654791277 50.67157614504485, -3.641137467351772 50.66173809126647, -3.6408543076454345 50.64840423148958, -3.6350539008975873 50.63851826492591, -3.638767859826795 50.62453333683643, -3.6316453547809244 50.61858700434784, -3.663216325671599 50.60556291511159, -3.6787514547758478 50.60685741793539, -3.700213970287976 50.60392866412329, -3.7067086005994176 50.59670815820181, -3.6821261312024567 50.58128189357426, -3.675684670935266 50.56484721845365, -3.6769574828406544 50.55432334571075, -3.6944228409618103 50.5434084137358, -3.7052022021280577 50.54143785127391, -3.7466620016839816 50.51882884906472, -3.7687247805208104 50.50233694100502, -3.765751527709172 50.49344712576134, -3.7705449492519905 50.48271936099528, -3.7826191116892733 50.47776286877557, -3.789503984392642 50.46809662726556, -3.7908816125944327 50.452749887369066, -3.804893132595518 50.42973724232371, -3.8188328301297356 50.42192289024074, -3.837763500910374 50.41745650593617, -3.8543596143612735 50.40540823038193, -3.8833306944706054 50.392027059101046, -3.910870183882279 50.394213963928365, -3.9180911111103054 50.39669623476848, -3.9317775305363023 50.39337296983411, -3.95800371734324 50.407005565716204, -3.9711100489141042 50.40970370698222, -3.9886311003598314 50.451898896768604, -4.0056256229551455 50.45298002991359, -4.013748033091425 50.44924783668686, -4.031142229231077 50.462724710774275, -4.039214859401411 50.455523469117594, -4.028703261571054 50.45048029164879, -4.055620413025166 50.44068385105128, -4.063982390310343 50.44621882691602, -4.0707409723975045 50.45757892982386, -4.090305904932649 50.46294029034307, -4.108532949530039 50.46324541648507, -4.094729384257016 50.47914202500903, -4.0975855098998935 50.49032332634096, -4.111519014633545 50.50278910103202, -4.121853477944813 50.50803085967061, -4.141360598432788 50.507186964217674, -4.129320281231794 50.52351466395439, -4.130689269159291 50.53154282931795, -4.121628457543873 50.53339671312973, -4.124866789294255 50.54375193084981, -4.12283879733563 50.557991532144115, -4.137321628213197 50.58402889221509, -4.152553458812856 50.59171519977147, -4.163829167349967 50.59348854282995, -4.164632255074781 50.60492144725125, -4.142646109003251 50.623969879577494, -4.12040662930285 50.63020870500728, -4.114466381638168 50.648219429475255, -4.089886576016587 50.65476793017914, -4.085599949895541 50.66514912564868, -4.084428084107926 50.68290524131061, -4.077260082757304 50.69310919804353, -4.029615770572292 50.727648536961546, -4.017883104989415 50.732261910617254, -4.000863938809066 50.729015782136514, -3.9653850548166254 50.740149798428575))
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>