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/ua/E06000002 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/administration/ua/E06000002 geosparql: asWKT MULTIPOLYGON (((-1.201012931975216 54.57766798075507, -1.201728985693263 54.57755414957446, -1.2003385726602145 54.57695670065781, -1.200235425794112 54.57687472944775, -1.2001517311918286 54.576824630800076, -1.198308769307144 54.575954393590834, -1.198225046526783 54.57591406594734, -1.196247270973283 54.575198508068404, -1.1944194914088626 54.57441294570652, -1.1942269660869025 54.57431908132888, -1.1940176911501483 54.57434443377572, -1.1921179025894895 54.5746438291094, -1.1920704538265825 54.57465106070727, -1.1903609524666712 54.5749074719831, -1.1865572181129 54.57264590736323, -1.1848369424757665 54.569781841239916, -1.1835399138394471 54.56920878257896, -1.17773141473709 54.56846121582897, -1.1764155861412962 54.56651826049299, -1.175727970102603 54.56104316585666, -1.1722794257426628 54.55928866974114, -1.1707155129744216 54.55740324874004, -1.1693863700642793 54.556839608450986, -1.166630196296576 54.55422161022596, -1.1700268994536749 54.5533156786308, -1.1743270152152159 54.55261177129596, -1.179179319448813 54.5502002607691, -1.1896917484320209 54.5481977378937, -1.1918044286057856 54.54744530320486, -1.1956688016327528 54.54519103947958, -1.1990493629825227 54.544484545169574, -1.1914196694914911 54.53930578119771, -1.179191683413431 54.53255501436705, -1.1677911523921163 54.526952693095524, -1.1643486616005554 54.525663575134224, -1.1613066145223436 54.52496670346643, -1.1627850955059742 54.52331793596011, -1.1649810250264658 54.521930166117755, -1.161804803727081 54.520184504640994, -1.1615265431096553 54.518458788654094, -1.1597267143911938 54.51582387062612, -1.1559359078485467 54.51627833730766, -1.153206630904049 54.51611631854012, -1.1482313983275747 54.5143882365795, -1.1473159156614077 54.515251678916584, -1.1424850662154824 54.515944657143, -1.1399454945257548 54.51579536317131, -1.1373550912302535 54.514982497110694, -1.1394542780101031 54.50925464639505, -1.1411059289593812 54.507754719533246, -1.1428482179650628 54.504789566616665, -1.144064124716572 54.503806901170236, -1.1462485099192432 54.50309979395668, -1.1461836498838893 54.50280904173633, -1.1466801066512164 54.50135927845321, -1.1480456391336589 54.50111275279827, -1.1526542135789064 54.50189920855791, -1.1582826395794457 54.50235997725914, -1.163099921243827 54.50352942315902, -1.164060063220173 54.503399405954504, -1.1641796461997795 54.50313608400456, -1.1653560346152108 54.503534230525844, -1.1660196530980016 54.50309658451821, -1.1666249333396905 54.50371099294706, -1.166963770404085 54.50337182051769, -1.1689591070833234 54.50352130430007, -1.1706399981627897 54.50233572917939, -1.171779251222921 54.50266437681058, -1.1722959082947124 54.50253934348301, -1.1727140105900964 54.50286843567285, -1.1735276895990732 54.50249206202303, -1.1745085933636072 54.502933795781516, -1.173894943814524 54.5031964495853, -1.1741957117376427 54.503826708553625, -1.1734579505397142 54.504036492143136, -1.173850531174125 54.504704215962064, -1.1755360622913813 54.504675285901065, -1.1761303238408314 54.504300992098955, -1.1793658335080155 54.50598648995037, -1.1799981980754155 54.506182240704646, -1.1811494678936496 54.505759586746095, -1.1850806838977552 54.5072725498286, -1.1897119596739953 54.50628004550746, -1.1954718676390543 54.506619566844016, -1.1967438592234105 54.506175914991964, -1.2021327514418476 54.50694050149934, -1.2037724622766037 54.50688122577496, -1.2068532806640027 54.50793047243393, -1.2084875832876942 54.508877640942224, -1.2140935735606586 54.51002495808584, -1.2189642832181102 54.51013835386575, -1.2201231102050019 54.51092856659132, -1.2275987914016642 54.51198397097362, -1.2305912867438193 54.51186917120713, -1.2304286056479885 54.51099097204338, -1.2317150321735115 54.511414326406495, -1.233391465784142 54.510556872814654, -1.234852662992991 54.51030368398487, -1.2364758307479913 54.51072642188361, -1.2377653034850133 54.51065369283572, -1.2386755907010127 54.51129032158107, -1.2402675681658561 54.51147642773835, -1.2414477585412946 54.51205183811147, -1.242154929310787 54.51156382640408, -1.2436486969646399 54.51138710452096, -1.2452244054543844 54.511545281454254, -1.2467675897740294 54.511284374591575, -1.2487738554838808 54.51195739444985, -1.2498118877286428 54.51170049868502, -1.25063144702471 54.511989580616174, -1.2512257796747268 54.513104920294325, -1.2562897734177816 54.5123830726363, -1.2563619385753673 54.511389554259296, -1.2590526121135746 54.512661565886006, -1.2638493793500583 54.51253353051386, -1.26415024550906 54.51298387046404, -1.2662298860456984 54.51355552000686, -1.2672536419274463 54.51443430511808, -1.2678145791076485 54.51433887091304, -1.2681729378001902 54.514682541597544, -1.2699291236747046 54.514602408648244, -1.2727890473524428 54.51508602173171, -1.2733092217063482 54.5147539334934, -1.2742536812969962 54.514892664340536, -1.2768024219018455 54.51655793712937, -1.2775656721553437 54.51654632583757, -1.2783528758331915 54.51719180111646, -1.278905846587086 54.51719509825701, -1.278563288022835 54.517437525065944, -1.2792468205860816 54.51748382593524, -1.2793174343763187 54.51786438225266, -1.2807919656264313 54.51790190747574, -1.2822359187410988 54.518368873407724, -1.2819884177964378 54.51970645860011, -1.2807363405001966 54.52054653290882, -1.281926136437959 54.5224660456571, -1.282750414215786 54.52295439208526, -1.2820459209275483 54.52409789713618, -1.282443876847765 54.525370129547134, -1.282057709532412 54.52641839915118, -1.283007100906381 54.52655439363459, -1.2833753422924465 54.527496625513606, -1.283884344874766 54.52763979718366, -1.2835016312025416 54.52787301568394, -1.2842948672266028 54.5279289222708, -1.2842609658628887 54.52881127064649, -1.2847651693562951 54.529047938724155, -1.2850602799977566 54.53028541302651, -1.284687463134666 54.530490751966816, -1.284639346549506 54.532886456486885, -1.2854184599931475 54.53623778769846, -1.284643060373345 54.53665386077754, -1.28480506351193 54.537023272162486, -1.2839499191503931 54.53810650829236, -1.2835447704481293 54.53794149014131, -1.2819467658553985 54.5386464666914, -1.2787723051887299 54.54240305504812, -1.2788600824555174 54.545231807981004, -1.278622181134828 54.545748974339375, -1.2777771791775185 54.546064771078434, -1.2779970516839285 54.547096873946245, -1.2769230290493292 54.54716413428002, -1.2771999139520753 54.547854269979005, -1.2761828051381185 54.54880261369283, -1.2755841477630754 54.551707220919795, -1.2741203786862147 54.552036357205516, -1.2735922331131782 54.5526973222409, -1.271767978428432 54.55355902299052, -1.2710286825784123 54.554433524747566, -1.270598575790884 54.55601175297515, -1.271162512746757 54.557167229982866, -1.2752572176141903 54.55863876638552, -1.2778510351493675 54.560528071221924, -1.280838738686766 54.5641334455532, -1.2817556056374926 54.5647213684721, -1.2815788870835587 54.5646959550698, -1.2817591861921707 54.565261428650004, -1.2781360736391882 54.5661943096999, -1.273833671289613 54.566787770825755, -1.2691631181717054 54.567028385223544, -1.2658391109893454 54.5679016052069, -1.2622245943660728 54.569612303258026, -1.260394486121606 54.571681650921626, -1.2601269529739862 54.572953748913655, -1.2571453028444477 54.58712572513303, -1.2555362044421805 54.589154133011455, -1.2533337941698144 54.59027020323335, -1.2516939176721622 54.590664452763285, -1.2492049078215868 54.5906913627603, -1.2461626369021193 54.59026351601052, -1.2398002461571997 54.587210416523156, -1.2343075674339243 54.58519594727193, -1.2300143133422892 54.58409565966955, -1.2301481718971103 54.58372534700173, -1.2298220645433364 54.58403424083041, -1.2296828097548889 54.583625280396575, -1.2293394381169183 54.58394671595317, -1.2285523192930279 54.583592963021474, -1.226674816817814 54.58354504037828, -1.2209985944264448 54.58245177960272, -1.2156951204234592 54.58105423598794, -1.215324002198939 54.58064198206967, -1.2159052763845102 54.580506465688536, -1.219865948494853 54.58018426142284, -1.2197688648597342 54.57886884692618, -1.2124473030057978 54.580186533624904, -1.2091984563137348 54.57985710311454, -1.2048007022683183 54.5799756832253, -1.203584208985625 54.57713942483797, -1.2069600384495187 54.57673065540602, -1.2037586519349452 54.57691955418225, -1.203448657591126 54.57726888958573, -1.2041948634355775 54.57986206031381, -1.2028019295688743 54.58028517779682, -1.2022934358043187 54.57899037274571, -1.201012931975216 54.57766798075507)), ((-1.1970529183135858 54.58177319311209, -1.1943211232424331 54.579852458984575, -1.1986732918604064 54.57803988001123, -1.200934758625485 54.57768040799573, -1.2021483381988336 54.57897412872524, -1.2024593678548174 54.58039705291139, -1.1984460192773807 54.58165930760334, -1.1973730033764742 54.58130439768545, -1.1970529183135858 54.58177319311209)), ((-1.2002729194060529 54.57692848884699, -1.1995736146567109 54.57662798960397, -1.2002503513521465 54.576902718523776, -1.2002729194060529 54.57692848884699)))
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>