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/fire-authority-area/E31000017 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/fire-authority-area/E31000017 geosparql: asWKT MULTIPOLYGON (((-0.759334355371896 51.103258667086784, -0.753480625154965 51.08645570403715, -0.780786867339954 51.07937520758129, -0.797762668956316 51.06355585585283, -0.842847938780207 51.06688680224234, -0.852810665975321 51.04484331421389, -0.896993022347724 51.02201011240132, -0.893346603868747 51.00274297972444, -0.907864072205695 50.99424110945185, -0.931847093916724 50.94558042338184, -0.942110076037333 50.94289408017729, -0.924013246727792 50.92419903320868, -0.940245264612523 50.918054106995, -0.957581415861758 50.89062968216906, -0.938608211079719 50.873721057157105, -0.926450175239615 50.8640917147338, -0.935602590211281 50.843330212615406, -0.974459710588325 50.84230349757457, -0.981422216475294 50.834927192951774, -1.001188973401264 50.84366851845731, -1.019909486427343 50.84319684642837, -1.024128915429888 50.82632257697788, -1.024282323390089 50.826436835914535, -1.036285679338795 50.8353744394474, -1.044118558739089 50.8321357124557, -1.044268001406612 50.79563688292968, -1.044288533084416 50.790624408444216, -1.032997489389758 50.79554431728053, -1.03059165362861 50.79659237540814, -1.030567495792213 50.79552419032943, -1.030382826704367 50.78735407094189, -1.088532379127485 50.77777072964659, -1.094166005657611 50.78106994960211, -1.10967383572101 50.79154222704109, -1.110216171394021 50.796158840076664, -1.111436650085923 50.80654497132722, -1.089591966485669 50.809604114953274, -1.092582588312032 50.815149886102056, -1.100254678713477 50.82672035877116, -1.084568972251682 50.824835796822164, -1.076609243753573 50.83679623011617, -1.044133733190348 50.83389577339511, -1.082258886279974 50.8380151406435, -1.089231916124515 50.82861805955181, -1.10627581898956 50.83786101805447, -1.103279760233893 50.8464002066853, -1.114115433068616 50.844927393743056, -1.117705957010156 50.844439115675605, -1.112976060135965 50.836144320810476, -1.112958960523431 50.8360831773332, -1.113069299826446 50.83609095213989, -1.127473271058429 50.83710511639493, -1.15459203706401 50.84504346196891, -1.154648883189552 50.84506009590571, -1.156512698397723 50.844561606459344, -1.176210193088541 50.839290844346735, -1.152543644495414 50.83583158888474, -1.149883393471633 50.82718109118438, -1.149469093108301 50.82684734345687, -1.123816695782176 50.80617097885623, -1.136779437985345 50.80196368932482, -1.123665612198355 50.804082576610085, -1.119290112400994 50.79622779612365, -1.117515052413603 50.793040469238846, -1.134427708994204 50.78588642958498, -1.111903383059095 50.78956006629172, -1.129937094686388 50.779643846740946, -1.142035658801106 50.77368617826449, -1.150382840665449 50.776523441234545, -1.190614955909755 50.790185153204725, -1.198716608023987 50.79680029409992, -1.213692389000728 50.809021903465926, -1.213866171928011 50.809163678989464, -1.214102604031771 50.80935656278669, -1.217610667130382 50.810224414550945, -1.220312958821833 50.81089283321505, -1.290176622034557 50.834380646663746, -1.306408539401428 50.840679663846444, -1.300211553414522 50.87946417842315, -1.304408399627389 50.87728062204263, -1.312788621743399 50.87291942749831, -1.313446634819472 50.84904577075101, -1.362931474356724 50.87871997842424, -1.365184601643137 50.88006971266198, -1.383314663480699 50.88959224832771, -1.384836812567398 50.90399016107699, -1.371845033447278 50.91245474602213, -1.387933280840344 50.9068913254956, -1.387199922304539 50.89922051358046, -1.395306282398685 50.88317909118564, -1.395341321531156 50.883109729094684, -1.395377696567663 50.88322277828443, -1.399022356490325 50.89454762827678, -1.400821780849574 50.890284467189716, -1.432492930239423 50.90486475274399, -1.439729814468905 50.908194005697965, -1.45088312731367 50.90412284310098, -1.465312103629583 50.910624527283446, -1.467142839146643 50.91144921176825, -1.478724513707883 50.925233651687975, -1.473464355467955 50.914801771630266, -1.476316997305351 50.91069488012869, -1.451137517104651 50.90134696362998, -1.432584121201723 50.89734317383425, -1.42184978298907 50.895025192706775, -1.376783763842939 50.85389067467449, -1.352706948086201 50.84814235163717, -1.360514113108216 50.842912342844635, -1.349481555816294 50.846481370181145, -1.334567605959618 50.837457485557714, -1.336525025729696 50.82727871493224, -1.319304291213012 50.82444955780672, -1.323571801639226 50.81841444893632, -1.326091336119992 50.816602619853114, -1.323232206446733 50.81815738613744, -1.314567589081281 50.81536716234092, -1.315518975745335 50.82116675164082, -1.312332690496571 50.8207294590214, -1.308512053525859 50.81613038015852, -1.309547117460676 50.81363128281763, -1.323148922006553 50.80427136905078, -1.324686922445631 50.80384470388143, -1.327738432891254 50.80111203345175, -1.332774870804592 50.79764431620346, -1.352593051303913 50.78399111940403, -1.355018967603706 50.78400122183733, -1.375033261247185 50.78500744374233, -1.377108232807028 50.784090999233044, -1.411892029870193 50.78422422420524, -1.388424195302156 50.77909191938444, -1.395651632165388 50.775897922001455, -1.434148797164765 50.767967816816785, -1.501532406609345 50.754049253786114, -1.519543469653041 50.75416707197269, -1.535048330532141 50.76387008537789, -1.525926418943405 50.744521500315614, -1.536915899405754 50.74251732585955, -1.531124623424288 50.73705434485651, -1.555599308059669 50.72226271613272, -1.575773699110043 50.716408031247056, -1.554861561632964 50.708430684843805, -1.553912782570653 50.711610293292246, -1.551044405013826 50.70706269948403, -1.553787780510502 50.70700354819099, -1.577403800162045 50.715310562923534, -1.586092128110259 50.71930029302677, -1.593532734896378 50.720979533742565, -1.594754637188251 50.72140885916227, -1.597090343573108 50.72178222646427, -1.642035497658666 50.731911357332294, -1.690036293348879 50.736597037950176, -1.692131261831786 50.736929996511584, -1.68181879042593 50.75185004051183, -1.744168706259461 50.74745538355848, -1.738959612147747 50.7632705282655, -1.748846305928644 50.779494382332835, -1.785495894991632 50.76475202582139, -1.803904948633869 50.79596520366835, -1.811893458321428 50.808642046477914, -1.803400823335899 50.83033920323791, -1.790614909120991 50.836314114293295, -1.802472945979674 50.842962523927184, -1.807110235570596 50.863315361201835, -1.830008717863079 50.85527379173386, -1.853538823427006 50.863460104624025, -1.848555520865733 50.88988735103234, -1.816541915468266 50.90394814072537, -1.810658078311182 50.92720337741653, -1.841840014719171 50.931680368341524, -1.873644310129571 50.917225883809394, -1.920840998807433 50.96140730530297, -1.955465569404935 50.97826632677305, -1.956820883665626 50.98982992739019, -1.949935962967562 50.98231058119697, -1.927875889347916 50.99769722943976, -1.88674131035357 50.99952773037544, -1.874481618000704 51.00633056802831, -1.87398354093787 50.98444103194593, -1.853381119493312 51.00467953579542, -1.835812607603754 51.009422256991634, -1.815421750153378 50.98592264473797, -1.800313953014855 50.991394794558175, -1.754401901580303 50.9778920907341, -1.719617297320083 50.97678045436492, -1.661659986156679 50.94527788750282, -1.634964970447212 50.959242197364446, -1.619750855324422 50.958566917529126, -1.602922945130668 50.978521922501734, -1.619642135996474 50.98299642279465, -1.628884970612418 50.99903175977968, -1.597339215938175 51.00975259454345, -1.599396703033924 51.023729370071976, -1.632375738441113 51.03277970305615, -1.634940052495705 51.04056077536103, -1.627728520240518 51.07801134212505, -1.637310798389317 51.09216546731336, -1.626249809294042 51.117338372399516, -1.662975409069405 51.12719198845571, -1.654044156137639 51.156282554679905, -1.672367760285678 51.17854390145771, -1.668835377215983 51.19077226140976, -1.694096939864844 51.20404323405812, -1.689694635398714 51.21482766590791, -1.633540812889257 51.2175159516704, -1.607426095170338 51.252770058890476, -1.577636024318759 51.25563105933237, -1.545159791202756 51.245098486842146, -1.53603491067282 51.248530033901275, -1.529820215594683 51.260514115167126, -1.540512620470621 51.26083347385005, -1.542583897033048 51.2812507302883, -1.522807390001478 51.28705800345352, -1.519511072866735 51.295938576028, -1.533561842206401 51.31622357468233, -1.527507270706108 51.33846595309168, -1.498298911652545 51.32937608845881, -1.429692811728732 51.336530279599785, -1.444109657375655 51.35492839676825, -1.428438612304449 51.35669016075148, -1.411067744983193 51.37285242738021, -1.349531967030001 51.36710561122547, -1.251139539482923 51.37204052381024, -1.176894263700053 51.357324048189646, -1.138589959302205 51.35719106686387, -1.115790901019724 51.360466159265194, -1.115457179244687 51.37421490379811, -1.086619074648572 51.383915572353715, -1.050015971975623 51.35814793143697, -0.986123738526687 51.36284828294155, -0.986740047565712 51.35985561919783, -0.923694802306396 51.36601048971188, -0.877856206001983 51.35259126384908, -0.837349290866197 51.35287121572011, -0.77546619487941 51.33195889759873, -0.76290310793293 51.31873052400005, -0.744167095389216 51.30929492336228, -0.731093821335322 51.280362085693895, -0.729325682483082 51.25611191421018, -0.745540367598984 51.230456385312, -0.776088998468955 51.241955663866904, -0.801740030665178 51.23903875763952, -0.804749560937524 51.245064741887255, -0.848912157243959 51.210715723939295, -0.825443281284904 51.18135650022045, -0.834203913593524 51.14758166397173, -0.798395593324209 51.15252747198925, -0.769280580621463 51.117142372064315, -0.745525557722852 51.11218846148585, -0.749272678162608 51.10324590082273, -0.759334355371896 51.103258667086784), (-0.759334355371896 51.103258667086784, -0.759443812790577 51.10357274665408, -0.768913287861277 51.103270016564444, -0.759334355371896 51.103258667086784)), ((-1.097127748826326 50.820608149905446, -1.093696389974645 50.81502648967875, -1.101644664866831 50.81367879661512, -1.097127748826326 50.820608149905446)), ((-0.969104646024294 50.83453302341433, -0.951027637743203 50.82397797162716, -0.957057026705638 50.80734201927088, -0.960861192470005 50.81159456947803, -0.970203743465833 50.81031570956202, -0.961788975938461 50.807855292792816, -0.973369393809487 50.80906209280823, -0.968970757589179 50.80274089213697, -0.952744876802913 50.80106772186613, -0.95918448348509 50.79490944169258, -0.96680621534982 50.78761813729278, -0.951307461561992 50.78690621832312, -0.958888504141154 50.78116646255362, -0.936808152741299 50.786810176301486, -0.937429690535146 50.777413162160535, -0.939911012929577 50.77761583388685, -1.021563021672506 50.786261535845334, -1.024590091083355 50.79547446628644, -1.024744934487408 50.795945626460785, -0.994897651966094 50.79813502187987, -0.986794950836363 50.8269018625603, -0.969104646024294 50.83453302341433)))
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>