Dataset Southampton
Published 29th July 2011
Type SPARQL Endpoint
Users 5

SPARQL Endpoint

Use the SPARQL 1.1 query language to perform structured queries against a dataset. Useful for performing precise queries against a dataset whose structure you understand.

Documentation

Endpoint URL

http://api.kasabi.com/dataset/southampton-postcodes/apis/sparql
Login to test this query using our experimental API explorer

Authentication

You will need your API key (on your dashboard) in order to authenticate to this API. You have two options for authentication:

  • By URL Parameter -- add the apikey parameter to your request URL, with your key as the value
  • By Request Header -- add a custom HTTP header called X_KASABI_APIKEY to your HTTP request, with your key as the value

For more information on Kasabi authentication options read the authentication documentation. Your API key will need to be authorized to use this service.

Parameters

This API supports the following request parameters:

Parameter NameParameter Value(s)Required?Notes
queryURL encoded SPARQL queryYesThis is the query to execute against the dataset
outputShort name for desired response formatNoSupports selecting response format using url parameter rather than HTTP Accept header.

HTTP Response Codes

Clients should be prepared to receive any valid HTTP response code. The following table lists the most frequently used codes

CodeMeaning
200 OKSuccessful Request
400 Bad RequestMissing or malformed SPARQL query
401 Not AuthorizedAPI key is not authorized to access the data

Please also review our additional notes on response codes.

Response Formats

Query Type Response Format Accept Header output parameter Notes
SELECT or ASK application/sparql-results+json application/sparql-results+json json Return results in SPARQL JSON results format
SELECT or ASK application/sparql-results+xml application/sparql-results+json xml Return results in SPARQL XML results format
CONSTRUCT or DESCRIBE application/rdf application/rdf rdf (or xml) Return results as RDF/XML
CONSTRUCT or DESCRIBE application/rdf application/rdf rdf (or xml) Return results as RDF/XML
CONSTRUCT or DESCRIBE application/json application/json json Return results as RDF/JSON
CONSTRUCT or DESCRIBE text/turtle text/turtle turtle Return results as Turtle
CONSTRUCT or DESCRIBE text/plain text/plain ntriples Return results as NTriples

Sample Queries

Find me GPs, their names and postcodes in the SO17 postcode district.

Query: 
select ?GP ?GPname ?postcode where { ?postcode <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/within> <http://data.ordnancesurvey.co.uk/id/postcodedistrict/SO17> . ?site <http://data.ordnancesurvey.co.uk/ontology/postcode/postcode> ?postcode . ?site <http://www.w3.org/ns/org#siteOf> ?GP. ?GP a <http://data.kasabi.com/dataset/nhs-organization/def/GeneralPractice> . ?GP <http://www.w3.org/2000/01/rdf-schema#label> ?GPname . }
Login to test this query using our experimental API explorer Permalink to this sample query

What are the types of crime committed in postcode district SO17, and how many were committed..

Query: 
select ?crimetype (count(?crimetype) as ?number) where { ?postcode <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/within> <http://data.ordnancesurvey.co.uk/id/postcodedistrict/SO17> . ?crime <http://commons.psi.enakting.org/def/nearest-postcode> ?postcode . ?crime a <http://crime.rkbexplorer.com/id/ReportedCrime> . ?crime <http://crime.rkbexplorer.com/id/crime-type> ?crimetype . } group by ?crimetype
Login to test this query using our experimental API explorer Permalink to this sample query

How many cases of antisocial behaviour were reported for each ward in the month of June?

Query: 
select ?wardlabel (COUNT(?crime) as ?number) where { ?crime <http://commons.psi.enakting.org/def/period> <http://time.psi.enakting.org/interval/2011-06-01T00:00:00ZP1M> . ?crime <http://commons.psi.enakting.org/def/nearest-postcode> ?postcode . ?crime <http://crime.rkbexplorer.com/id/crime-type> <http://crime.rkbexplorer.com/id/anti-social-behaviour> . ?postcode <http://data.ordnancesurvey.co.uk/ontology/postcode/ward> ?ward . ?ward <http://www.w3.org/2000/01/rdf-schema#label> ?wardlabel . } group by ?wardlabel order by ?number
Login to test this query using our experimental API explorer Permalink to this sample query
11th Aug 2011

Find me GPs in Portswood and the bustops in a 100 metre radius 

Query: 
select ?gp ?gppostcode ?bustop where { ?gp a <http://data.kasabi.com/dataset/nhs-organization/def/GeneralPractice> . ?gp <http://www.w3.org/ns/org#hasSite> ?gpsite . ?gp <http://data.kasabi.com/dataset/nhs-organization/def/status> "Active" . ?gpsite <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/within><http://data.ordnancesurvey.co.uk/id/7000000000017711> . ?gpsite <http://data.ordnancesurvey.co.uk/ontology/postcode/postcode> ?gppostcode . ?gppostcode <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/easting>?gpeast . ?gppostcode<http://data.ordnancesurvey.co.uk/ontology/spatialrelations/northing> ?gpnorth . ?bustop a <http://transport.data.gov.uk/def/naptan/BusStopPoint> . ?bustop <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/easting> ?bteasting . ?bustop <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/northing> ?btnorthing . FILTER ( ( (?gpeast - ?bteasting)*(?gpeast - ?bteasting)+(?gpnorth - ?btnorthing)*(?gpnorth - ?btnorthing) ) < 10000) }
Login to test this query using our experimental API explorer Permalink to this sample query
Create a sample query