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/md/E08000012 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/administration/md/E08000012 geosparql: asWKT MULTIPOLYGON (((-2.8188068624973526 53.347984936099124, -2.8189772236968604 53.34527456860989, -2.819868580559349 53.343662138797896, -2.8180001898271723 53.34296567353627, -2.8198404915749595 53.34118497895915, -2.818709516459341 53.340714493041574, -2.8187798127646078 53.339755798125495, -2.8203769971011985 53.33987153171409, -2.8202097703397846 53.34039137327246, -2.8223285181038276 53.34067791896119, -2.8234828500078426 53.33737196814115, -2.827326371166922 53.33785678635425, -2.8310654783919884 53.337756208975875, -2.8310829267035564 53.337258963154156, -2.8324573018736077 53.33727364292825, -2.831530617014992 53.33511115956667, -2.826654161745764 53.33164483460798, -2.8266610514723687 53.33164104656724, -2.8288296250660308 53.33096082793503, -2.8330311246944384 53.32849647421813, -2.836410305532376 53.32700224653214, -2.8405200438142812 53.32678905821445, -2.8549728405875094 53.32745582751484, -2.8649276181679144 53.33012922985503, -2.8718703787051845 53.33246080278919, -2.8781586241081936 53.334182803528144, -2.9026888101927857 53.344609628864255, -2.9032266156967204 53.34483811532144, -2.9048965835649825 53.34567043338481, -2.9073755488069972 53.34746286961953, -2.907041626394706 53.34772337308374, -2.908243962727712 53.34810615895172, -2.9098695074352325 53.34952389656427, -2.914441059732767 53.3521299164632, -2.9159185536135253 53.35370334898911, -2.918920864237965 53.35491444372769, -2.9224462313264534 53.35724053221431, -2.923650625889037 53.35734898725088, -2.9301413443466116 53.36058133720734, -2.9457360624106954 53.36717347125042, -2.9637756226635976 53.37345359352647, -2.967647972147331 53.37559128900984, -2.969007637957642 53.37595779131131, -2.9692998485452704 53.375787286026785, -2.972563782686739 53.37758821382133, -2.972922810706154 53.37810307958874, -2.9736645445486647 53.378197681663266, -2.973573970328192 53.37870901074956, -2.9746515061063628 53.37876043092871, -2.9786307216511476 53.381186349200796, -2.98306706965208 53.38470231603597, -2.983431829742028 53.386048527920906, -2.98414639549912 53.38612988394714, -2.983999957721037 53.386756712100365, -2.984502221524461 53.38636874163588, -2.9849725436993215 53.386486217561945, -2.986504430703992 53.38823265217612, -2.986265628281418 53.388568163673845, -2.9869481780086415 53.388824063517276, -2.987950655026729 53.38997268478349, -2.986685283067159 53.39006944665554, -2.986805136944912 53.39037404974926, -2.988135985531843 53.39024801050154, -2.9880725212983 53.3910773526961, -2.9889102347035292 53.3916690417806, -2.9950610892215233 53.400908898956494, -2.9950104951137635 53.401704851386356, -2.995887432845218 53.40228626873738, -2.999601985435304 53.407712453132866, -2.9999529167427728 53.407667269774144, -3.0018457728038235 53.410308520706344, -3.001763434625431 53.41103197524618, -3.001751834207569 53.41149674757068, -3.0024650537829096 53.411502453716174, -3.0026126045866035 53.41265541293019, -3.0031308837767874 53.41256111511951, -3.0051648479310193 53.41931810049574, -3.005425312918131 53.42072716979916, -3.0048466152280633 53.42094507902082, -3.0047387835601227 53.421414309437026, -3.0051340476933466 53.42152065650106, -3.0047419019312698 53.42180171120269, -3.005674824448571 53.4223071659256, -3.005933173775665 53.42560297809619, -3.006499286283733 53.42567731265537, -3.00606083294907 53.426100799213316, -3.0065681454980724 53.42585202600673, -3.0063506938565574 53.426267338372, -3.0069358446546897 53.42638285765983, -3.006349403881393 53.42729568049872, -3.007155116562585 53.43323775435762, -3.0087561730944032 53.438365017023585, -3.007547049063632 53.43835185965652, -3.0054491290916507 53.439144343110065, -3.005091143322596 53.438964934079294, -2.9999769591664993 53.4399759631904, -3.000215303701472 53.44038383373319, -2.993992437663857 53.44150992490226, -2.9926951639512933 53.44030181163036, -2.991663077857436 53.440718544669615, -2.9910576856782773 53.440194994961146, -2.9904552410393186 53.44057121774631, -2.979831007020302 53.44252585380192, -2.9790874147511768 53.443317623804774, -2.9776081942742008 53.44282992359246, -2.9749152576905065 53.44330772245342, -2.976264021931633 53.44526883692341, -2.9749730218972923 53.446491094696135, -2.9748595554791644 53.447385528298405, -2.9733789183465693 53.44729596956113, -2.973731937573082 53.44969764337689, -2.973024476964299 53.44970700285084, -2.971585692324883 53.45224817504778, -2.971649350121917 53.456221658272845, -2.9734074959955508 53.460134524694, -2.9738240529548317 53.46274056200651, -2.9672833462116808 53.467747470071714, -2.9619192006167836 53.46829419471376, -2.960116206802619 53.46796982810386, -2.960137528754684 53.4676433661237, -2.959302996966717 53.46764917187067, -2.9586097945338357 53.468772895405145, -2.95807875077877 53.468737616529104, -2.956307599667147 53.472977498138846, -2.955628697673068 53.47273841539317, -2.955628458808854 53.472390560222166, -2.9551190916593044 53.4723820529996, -2.9548460015148557 53.47263405307439, -2.947880593931993 53.473023990948406, -2.947159750338579 53.47211553879116, -2.9461252095641157 53.47294525755349, -2.939829576597917 53.47331135631338, -2.939835893249915 53.47359715846558, -2.933397525821719 53.47384542266694, -2.933359197537047 53.473129250646245, -2.927186537288441 53.47395669212526, -2.928255264043325 53.47342881026062, -2.927624721767806 53.473326771980936, -2.9226161582374592 53.47496735009598, -2.920041765467679 53.4732488211833, -2.9210873686306558 53.47262502867043, -2.9186586377909967 53.46829584071294, -2.9157583493129593 53.46883580512928, -2.9143785413670136 53.46498931081751, -2.9137686112658825 53.46485648914094, -2.9125041442372672 53.46524366629875, -2.905963744194136 53.46496985570107, -2.904925387628114 53.46522943028362, -2.9039406607385976 53.46751641767349, -2.9059297823713974 53.47016288358758, -2.900316015479411 53.46914288595223, -2.895150803871577 53.46716196413593, -2.8948894156352996 53.46597828252688, -2.8953051118864064 53.46590148123378, -2.8946968844037397 53.46491450080244, -2.8939969326822497 53.46465554682967, -2.8938511363738186 53.46395274832042, -2.8930379605090564 53.46338712807088, -2.8918120559631566 53.4633279919459, -2.8911705200999473 53.46268379555978, -2.889979099349296 53.462396044211076, -2.8901030015567635 53.46148005528889, -2.889539370547549 53.46103126001265, -2.88779969039402 53.46052731580101, -2.883406811402597 53.45808795998343, -2.8820213593129473 53.45773416760211, -2.878426276634951 53.455902673625005, -2.8751222805350505 53.45474047858405, -2.8741576116910585 53.453893583629416, -2.8720894759100424 53.45320669932165, -2.8696420885377947 53.4505386575644, -2.867856129276589 53.44927884161795, -2.8682456724924665 53.44468180909677, -2.8700547129537792 53.44361788440399, -2.8706986125784097 53.44241676626391, -2.8700471174536135 53.44133301375316, -2.870843736339479 53.437957282847705, -2.873416665529255 53.43650294180526, -2.8719556954760033 53.435507790222296, -2.87266146260702 53.43520240410336, -2.8687891190519883 53.43294660973703, -2.869386322522038 53.43271032865193, -2.8689087360615835 53.43151018821771, -2.8693039602981627 53.43125929152285, -2.8685971433122583 53.430841901741104, -2.8674775434551574 53.428709788802784, -2.8661779194939743 53.428007333844995, -2.8681452181153717 53.42691083300754, -2.8685643799510077 53.42628395999902, -2.869455399898795 53.426069802968385, -2.8700986087719396 53.42513836595833, -2.8682241086548674 53.42391424537215, -2.8688856741788946 53.42322000840208, -2.867682505788397 53.4197105508854, -2.8663080950465716 53.41916050866286, -2.8659276836200287 53.418285940059285, -2.8687142196962583 53.41555382501788, -2.8710464121003505 53.41239163972988, -2.881331432019428 53.41612471718704, -2.884097111567491 53.41686019467198, -2.8882354257408114 53.414510390666756, -2.8892863715232298 53.41339240298771, -2.88974438849296 53.41349511819633, -2.891110501985141 53.41234331190489, -2.8923646363963043 53.41181256022866, -2.892411522172828 53.410746167555416, -2.8916805380807857 53.40989137268982, -2.890542604278313 53.406910219316245, -2.8816843446412213 53.40816692357374, -2.8814138928493276 53.40716218721394, -2.8753542189283907 53.40098916615531, -2.872746843228748 53.40168339719147, -2.8718655925228433 53.400366607266, -2.870455828785738 53.39930815664103, -2.866403421030779 53.39846480108855, -2.856220021634685 53.394944577599134, -2.849741955334966 53.3973063645576, -2.8480397003750335 53.396939160067625, -2.8450144983202694 53.39804013496934, -2.837587416511628 53.399921724704804, -2.8371940632145214 53.39972579855228, -2.8366180533656795 53.39819642090902, -2.8349664735752267 53.39656925018173, -2.8345170926157217 53.39635312809882, -2.834019806265975 53.396610016156394, -2.8332823212627396 53.3957370293748, -2.8333224902700227 53.39486750673249, -2.8322260334304716 53.39301266276147, -2.8320087084808305 53.39196521151657, -2.832870335586903 53.39073670966671, -2.8327126286772604 53.389898222247155, -2.8336499817018277 53.38892538505295, -2.8315470115777055 53.38757198482277, -2.8299372193820007 53.38705461659014, -2.828707272764141 53.38589099284562, -2.8261532166627985 53.38490646004086, -2.8250640696536227 53.38370767638769, -2.8227043644657934 53.38210688541044, -2.8219546542025635 53.38065133225129, -2.8230169418720497 53.38015147241948, -2.8241970434510457 53.38007323595763, -2.8251124185700833 53.38053518606501, -2.8279208279838763 53.38030806325238, -2.829067281558066 53.38097344626451, -2.830884615038854 53.38096440234174, -2.832442482382725 53.38160163748396, -2.8349795773557633 53.38119013462063, -2.841722008410907 53.381561713019046, -2.844813036346446 53.38202432386401, -2.8465987466343545 53.381856206691204, -2.8479420337428345 53.38113837087831, -2.8518470447107624 53.38087772691552, -2.8561651029252246 53.37879911868406, -2.8539947461605943 53.37701246570722, -2.852404898967727 53.37222550241825, -2.8520251029370645 53.36939042583749, -2.853615140867441 53.366225763351736, -2.853495933342573 53.36349845717171, -2.84696679886324 53.35464689798077, -2.8404056398807307 53.34731524181822, -2.832169807431526 53.34664750665161, -2.8287118241200613 53.346952939945545, -2.8232002091245945 53.34803836482445, -2.822497858890122 53.34775735389113, -2.8188068624973526 53.347984936099124)))
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>