SPARQL-endpoint

The Joinup API: a SPARQL-endpoint

Advanced Joinup users can make use of the SPARQL endpoint to retrieve Joinup information in an automated way. Using the endpoint requires knowledge of the SPARQL query language, the linked data equivalent of SQL.

If you are not familiar with Linked Open Data, both this article and the W3C page describing the SPARQL language specification are good resources to start with.

The SPARQL-endpoint itself can be found here.

As Joinup uses the ADMS-AP data model, it can be very useful to have the specification of ADMS-AP available to know how entities relate to one another.

Let's get started with some example SPARQL queries:

Simple listing of all collections

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?collection_id ?title
WHERE {
  ?collection_id a dcat:Catalog .
  ?collection_id dct:title ?title
}

The number of solutions linked to each EIRA ABB

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?eira_abb_name count(?solution) as ?number_solutions
WHERE {
  ?solution a dcat:Dataset .
  OPTIONAL {
    ?solution dct:type ?eira_abb_uri .
    ?eira_abb_uri skos:prefLabel ?eira_abb
  }
  BIND ( IF( BOUND(?eira_abb), ?eira_abb, "No ABB linked!" ) AS ?eira_abb_name)
}
GROUP BY ?eira_abb_name
ORDER BY DESC(?number_solutions)

The number of distributions linked to each licence

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?licence_name count(?distribution) as ?distribution_count
WHERE {
  ?distribution a dcat:Distribution .
  OPTIONAL {
    ?distribution dct:license ?license_uri .
    ?license_uri rdfs:label ?licence
  }
  BIND ( IF(BOUND(?licence), ?licence, "No licence specified") AS ?licence_name )
}
GROUP BY ?licence_name
ORDER BY DESC(?distribution_count)

Prefixes

The following namespaces can come in quite handy when writing SPARQL queries against Joinup.

PREFIX adms: <http://www.w3.org/ns/adms#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX spdx: <http://spdx.org/rdf/terms#>
PREFIX v: <http://www.w3.org/2006/vcard/ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

Content negotiation

All Joinup content described by ADMS-AP (collections, solutions, releases, distributions, contact information, licences) can not only be retrieved through the endpoint, they also support content negotiation. The persistent URI redirects to the public URL (human readable), so content negotiation is supported on both the URI (data.europa.eu/w21) and the Joinup URL.

An example using curl:

curl -L -H "Accept: text/turtle" http://data.europa.eu/w21/37e87bee-0e8d-4c2a-a762-d7df6427b838