Skip to content

Querying via SPARQL API

The ORR has separate repository and SPARQL APIs. The SPARQL API provides the standards-based mechanism to search ORR's semantic content.

SPARQL is the query language for the Resource Description Framework. (The acronym is recursive: SPARQL Protocol And RDF Query Language). It is analogous to SQL for relational databases, allowing queries to be placed for semantic resources. The Wikipedia entry for SPARQL1 contains good background information, and the W3C documentation2 provides a good technical read.

SPARQL queries can be done programmatically against the ORR SPARQL endpoint at [orr-host]/sparql (MMI ORR example: https://mmisw.org/sparql; COR example: http://cor.esipfed.org/sparql).

Note

[orr-host]/sparql is for programmatic access; it is not a graphical user interface.

A web page with a user interface is available at [orr-host]/ont/sparql (COR example: http://cor.esipfed.org/ont/sparql/, as shown below).

SPARQL search page

The Querying Linked Data with SPARQL video provides additional information about querying with SPARQL.

Some SPARQL examples

The following example queries3 are against the MMI ORR SPARQL endpoint, but conveniently exposed through the GUI at https://mmisw.org/ont/sparql. Click the Execute link to open and execute the query in that GUI.

List all IOOS categories - Execute

PREFIX ioos: <http://mmisw.org/ont/ioos/category/>
SELECT ?p 
WHERE { ?p a ioos:Category } 
ORDER BY ?p

List all IOOS core variables - Execute

PREFIX ioos: <http://mmisw.org/ont/ioos/core_variable/>
SELECT ?p 
WHERE { ?p a ioos:Core_Variable } 
ORDER BY ?p

List IOOS platform terms - Execute

PREFIX ioos: <http://mmisw.org/ont/ioos/platform/>
SELECT DISTINCT ?cat ?platform ?definition
WHERE {
  ?platform a ioos:Platform .
  ?platform ioos:Definition ?definition .
  ?cat skos:narrowMatch ?platform .
} 
ORDER BY ?cat ?platform

List IOOS platform categories - Execute

PREFIX ioos: <http://mmisw.org/ont/ioos_test/platform_category/>
SELECT DISTINCT ?p 
WHERE { ?p a ioos:Platform } 
ORDER BY ?p