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/E06000008 http://www.w3.org/1999/02/22-rdf-syntax-ns#type geosparql: Geometry
http://opendatacommunities.org/id/geography/administration/ua/E06000008 geosparql: asWKT MULTIPOLYGON (((-2.4658090434983095 53.78079909134634, -2.4628022649794223 53.778557357526346, -2.4601907007471313 53.77772529342223, -2.455643101946698 53.77410965252542, -2.453534023595344 53.77297892079417, -2.4531267134094605 53.77164566465187, -2.4536046259396027 53.77108118379377, -2.452335711325063 53.76963266448128, -2.4463181346224365 53.766574996854025, -2.4480614990430776 53.76589080301897, -2.4489146080339688 53.76438478177617, -2.4511261639966686 53.76280715477939, -2.451968425170863 53.76156451801783, -2.4520056679821387 53.75952502266644, -2.4511464481575986 53.7573396564492, -2.451781313219496 53.75643934025934, -2.4510437673614103 53.75597379326725, -2.450634638422098 53.75629261194046, -2.4502402603458107 53.75600377271338, -2.4483969636652696 53.75609344192496, -2.4465199185485433 53.75528968887806, -2.445473404628486 53.7545709683283, -2.44533670306777 53.75369421884957, -2.4446531559669133 53.753594323106825, -2.4448361312025937 53.75311273804719, -2.4419291416568307 53.751981166281034, -2.44203889908591 53.7514549275308, -2.440068734168163 53.749402966204606, -2.4393712488018306 53.74781643411778, -2.440901832188579 53.746707116321566, -2.4407703317696408 53.74602901300827, -2.4415056700976816 53.74588244583712, -2.4419884808942682 53.745213758999654, -2.441282600584146 53.74339894544929, -2.4418313553245627 53.74238128595224, -2.4409684072391173 53.74162949973666, -2.4408300949008277 53.74015593001663, -2.439962973788973 53.73899872357396, -2.4397630616463175 53.73335850604541, -2.433554036685194 53.72760809877823, -2.432297311446402 53.72035742122971, -2.4326706099675595 53.719660320234546, -2.4338702209133167 53.71916617620123, -2.43269160992181 53.71890707329774, -2.425873835416292 53.714679266957326, -2.4183471727393733 53.71140889845268, -2.419655698791045 53.709828697179326, -2.419967673684275 53.70830589327302, -2.4140161431872493 53.70498937145208, -2.413069342802426 53.70467715698513, -2.4109908619298293 53.70512109935152, -2.408608272734225 53.70312402952622, -2.4055085148657045 53.69896758759743, -2.403011106025341 53.69692676473392, -2.403136379788022 53.69640679502171, -2.4013440839132807 53.69507090659856, -2.400289004900971 53.69257931639386, -2.3983499730831577 53.69154408299962, -2.3912076837887373 53.688548471638654, -2.3847963950218034 53.68822501413332, -2.3831565819259377 53.68856462817174, -2.38089430316237 53.688566456882974, -2.3744257348306133 53.687238665078695, -2.375708468289639 53.68182099432065, -2.3759363772095896 53.675625680988276, -2.374060939944539 53.67137290923902, -2.371238007843063 53.66706464139838, -2.3689741797859165 53.66330288567831, -2.363637512225911 53.65742212243314, -2.3626429631042325 53.655972609849826, -2.362748449964647 53.65538534743025, -2.3661418141200885 53.650633730580076, -2.367070023920246 53.64759463127499, -2.366680209727061 53.64677166181477, -2.3670569781792152 53.64504561754974, -2.3692098916871265 53.64508392189163, -2.3704771617945637 53.64469622637987, -2.372496396281354 53.64227748318466, -2.3701074260553465 53.63806944710468, -2.368499190663858 53.63800252622384, -2.3690026350603177 53.63712010773209, -2.3683560855891432 53.63686412116848, -2.368561208949278 53.6350622197657, -2.370222545928378 53.63324692311731, -2.369835423532771 53.63256673583521, -2.3705286248215365 53.63176468496547, -2.3703298385503744 53.63151810443281, -2.3710014918989177 53.63137494804138, -2.370922309718895 53.63199897986686, -2.3762903871874625 53.631797020013366, -2.376645858925402 53.631125389438886, -2.3791340547687785 53.63085415900422, -2.3838330392939002 53.63126967827492, -2.3850175049233613 53.63180249852992, -2.3859508335466666 53.63299854188912, -2.39784770156072 53.632192011185204, -2.3987307021456497 53.63168838886016, -2.400795464764019 53.62904706145626, -2.4002591709418524 53.62893464837155, -2.4000139470897377 53.62826405697695, -2.4012112739141225 53.624582916206386, -2.403335033297633 53.62436281325258, -2.404546782383311 53.625070569248464, -2.409099779659114 53.625422690991016, -2.413834026298569 53.62467029718112, -2.4162448284726477 53.62367862603777, -2.419010637559712 53.62356464682413, -2.421698333869358 53.62381947177265, -2.424610865785632 53.62553047360184, -2.4258553053016523 53.62584333584765, -2.426356346864959 53.6264994858217, -2.4258850276677935 53.628187333891255, -2.426145646660197 53.6349941578709, -2.430655792667666 53.63844568012293, -2.4326533800910894 53.6413659241175, -2.4387263706001003 53.64602940092908, -2.4422879100161916 53.643766541136685, -2.443033612569169 53.64304205149113, -2.4430796943661184 53.64239383293917, -2.445265792869865 53.64200094979465, -2.4456216938930675 53.64160775869692, -2.445984753288356 53.64162168159158, -2.4458652411034887 53.64190167212429, -2.4467874764659094 53.641428190380495, -2.448560560620158 53.64203267372478, -2.449941472358854 53.641888210347844, -2.449698696206005 53.641528706745355, -2.450272293710528 53.641416025308665, -2.4485756858918073 53.638041886616136, -2.449172454526897 53.63783737917493, -2.447973092495879 53.636697636242765, -2.4492435595968343 53.63556399764591, -2.4496813753630753 53.63336202191881, -2.448393473227577 53.63184602313134, -2.449252013481888 53.63110399746681, -2.450663349991499 53.627742433480925, -2.4521171063986724 53.62821687574956, -2.4519021700236525 53.6277737029131, -2.4534626788703213 53.627924239542985, -2.454918541413551 53.626911053465825, -2.4563558744022194 53.62671687902728, -2.456818266928791 53.625712936054974, -2.4582911338410107 53.62461517761044, -2.4564846104183427 53.62393000401633, -2.4552664106939868 53.62411346210214, -2.4542643398722115 53.62344765452826, -2.4535582918027496 53.62344943461707, -2.4531805563767444 53.62276148131024, -2.4543499053230065 53.622396628415224, -2.4537827556866865 53.62195839013549, -2.4550248959298937 53.62134066505013, -2.4557307790179883 53.62146557513819, -2.4575260163808386 53.620968820396364, -2.459701912941644 53.620026681606475, -2.4634106414794776 53.621987976700915, -2.4634684571477266 53.622304140259004, -2.466590737034103 53.621493800185924, -2.467085117260297 53.62095263704543, -2.470444579729513 53.61987520209544, -2.4730335543913577 53.61656812308113, -2.479197194603851 53.61701992580014, -2.4948289847923593 53.62212731777143, -2.508520974731605 53.62555736274046, -2.511324688962017 53.626978998899546, -2.5148236624902647 53.629220943886146, -2.518332514693442 53.630265573651684, -2.520063406060577 53.6304657233875, -2.524575256320278 53.641270607678436, -2.5240227627968213 53.64257631874111, -2.52214447168881 53.64419522072929, -2.5214954150548903 53.64541687484303, -2.522272082034708 53.64816213057391, -2.5235651652335336 53.65081787006355, -2.525065731319208 53.65249935302062, -2.5252983461926215 53.65369019694429, -2.526615487578784 53.65508474190817, -2.5286241265594005 53.65624079440573, -2.528939387472326 53.660265268257746, -2.532346415135572 53.664886247011054, -2.5291608128699448 53.66719154515462, -2.528343828327 53.66939548035769, -2.5264740919824105 53.67117165280334, -2.5262268001719255 53.67355915851152, -2.5255518285863325 53.67466044355473, -2.524589750749428 53.67507908309034, -2.520920443790741 53.67521281952624, -2.5191729896916395 53.676271105910075, -2.5192430871913905 53.67680473079437, -2.5183480400713147 53.67763915610869, -2.517767435661846 53.680166462910066, -2.5178219244455504 53.68139223144292, -2.518467024033605 53.682396104268044, -2.5174029055842033 53.68488686151377, -2.5179319571551844 53.686654299641845, -2.5169981519815243 53.687442155377326, -2.5165898503878004 53.68896743625721, -2.5154369838982533 53.68978668456413, -2.516010802521511 53.69089789540942, -2.515378006414558 53.691652899448734, -2.5157004237080223 53.69239040156059, -2.5175080020933747 53.693199576982344, -2.5176071801825888 53.693629740744406, -2.5184733711787426 53.69350729275332, -2.520155301153351 53.69443747110236, -2.521163024459839 53.69449059656267, -2.521360794585421 53.69504433042793, -2.5223556440640715 53.69503460236149, -2.5233863561965 53.69546967929512, -2.525298764419552 53.694948044590696, -2.5264672049558556 53.69501030460542, -2.5290603904688194 53.69600553753023, -2.5299939880411046 53.69593940796909, -2.5308602680924297 53.69641827934146, -2.5319341762675096 53.69642699112947, -2.5327197785351956 53.69734749327449, -2.53529534584356 53.698250117188984, -2.5349463779031125 53.69879719531168, -2.5364164984593223 53.6993479088782, -2.5374667141046463 53.701058200568454, -2.5397955795051637 53.70217569249186, -2.5402507594152337 53.70353631380313, -2.540943494469831 53.703930441378624, -2.5410387523948 53.70450167776119, -2.542213771299196 53.7051695678973, -2.542780717725231 53.706616742757454, -2.541579987439742 53.70795699601109, -2.5420206929478155 53.70889157454656, -2.5432635623488027 53.70988002433467, -2.541662874772207 53.71099547336674, -2.5401775738229526 53.71118827490545, -2.5409128127582017 53.71204245531574, -2.538975133646968 53.71335895977414, -2.539899277870958 53.71654379691198, -2.5395992007461183 53.7176084178699, -2.5399025746560318 53.7181077290817, -2.541397902901385 53.71878316759261, -2.540802866465202 53.71965413701156, -2.5412549349071196 53.72004485645039, -2.5421916473392976 53.72018088488442, -2.5437745715039393 53.72130347048437, -2.5445409399225216 53.721027634710445, -2.5463393331603137 53.72123159488683, -2.5470745644609223 53.7217154393667, -2.547335378592525 53.72243058154223, -2.546686735891375 53.72324782101064, -2.5463133461136263 53.72496092529827, -2.550747285254555 53.7265288270115, -2.5550908468799123 53.725253126212216, -2.555998469671951 53.72604162732548, -2.556894302085723 53.72741990312507, -2.555859927370122 53.72898056745265, -2.556538986351514 53.73081281511949, -2.5564962623034364 53.73228970905456, -2.5570749375223607 53.732602503552826, -2.557157436811566 53.73459665532795, -2.5593628001098496 53.735148067772016, -2.5607316547740306 53.73776447654041, -2.5616074343216524 53.737843041846254, -2.563618369031362 53.73925107589341, -2.5632609830821793 53.73984868167851, -2.5635399854974623 53.74075419705218, -2.5628680541628164 53.74152858957738, -2.564593566673816 53.74244356047572, -2.5646626300521365 53.74363149068006, -2.5617538322417173 53.74472190898284, -2.562469757440066 53.74610269036188, -2.561603802753395 53.74688607317769, -2.5591681122841186 53.74753831816732, -2.5581375782625524 53.749070223212904, -2.556253585851619 53.74903046342927, -2.5551233753808615 53.749917370677956, -2.5545407290691293 53.749547975467664, -2.553989239712993 53.7496925890505, -2.5538018656308834 53.75043764115198, -2.5526518099459325 53.75120070577452, -2.5528272668593077 53.752097735266666, -2.552011090977476 53.75300032587331, -2.552080266771502 53.75422240416833, -2.5516406026047784 53.75458484129558, -2.5521638492004786 53.75516038322561, -2.551300019451925 53.75637327890681, -2.549807166811922 53.75715038171466, -2.5499572096359397 53.75749312189919, -2.5492563843405387 53.75806700972685, -2.5476990104813906 53.75878516685082, -2.5467881494754177 53.758723642501664, -2.546574115976201 53.75895024643195, -2.546433334294396 53.75873155102997, -2.545726200415442 53.75941255474502, -2.543852084803481 53.75923318774473, -2.5424356889518442 53.759605409980345, -2.540565558944231 53.75960936834419, -2.539462391241416 53.75993162029836, -2.53907971957065 53.759660091647994, -2.5384577420318784 53.75989121204519, -2.5365694075191074 53.759547359053904, -2.53634185114203 53.75907106491582, -2.5323477436707384 53.758671857246846, -2.5317031903104863 53.75952322564821, -2.5298112517427587 53.759850682941284, -2.527779151352062 53.75939581692537, -2.5271762722644553 53.75970856224365, -2.525689188452812 53.75966118229306, -2.524206215925525 53.760425341507585, -2.5232517046529988 53.76039357099649, -2.520772635498096 53.76218854230956, -2.5198413767178423 53.76232107937825, -2.518697441464515 53.76389985540984, -2.5155990227508975 53.76470063070452, -2.515224766336302 53.76523975580083, -2.5155128358128143 53.76559802788856, -2.5148375164918164 53.76618966436495, -2.511256066247259 53.76671546652858, -2.5094140547899215 53.76920134251244, -2.507664909556217 53.76958445122131, -2.50469264437297 53.769702226466315, -2.500690066539442 53.76866106106799, -2.4985447921697204 53.76866102018212, -2.4866951313570085 53.77277954701996, -2.4849752692737606 53.77297710234478, -2.484343363604265 53.772780090104796, -2.48127467711873 53.7737784345432, -2.480827826652206 53.773977100695305, -2.4779548972584164 53.77992882362117, -2.477004796772412 53.78045394801178, -2.4770888230813384 53.781033267970045, -2.4737082507065224 53.77988458311663, -2.469717105478221 53.78177700499094, -2.467048706957987 53.781468358319245, -2.4658090434983095 53.78079909134634)))
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>