Book page

SPARQL queries user guide

SPARQL queries user guide

For support, please contact:

ESTAT-DATA-METADATA-SERVICES@ec.europa.eu

Last update : 20-02-2024

 

1. Introduction

The purpose of this document is to provide a short overview of how to use Sparql query language to query Eurostat's statistical classifications.

 

1.1  What is SPARQL?

SPARQL is a query language used to retrieve data stored in RDF (Resource Description Framework) format. SPARQL allows users to express queries that can retrieve specific information from RDF graphs.
SPARQL is the principal approach for querying Eurostat’s classifications, which are represented in RDF.

 

1.2  How to query Eurostat's classifications?

There are two ways to query Eurostat’s classifications:

via ShowVoc, where you can create queries within a selected classification (stored in ShowVoc)

NACE 2 example
  1. Go to ShowVoc: https://showvoc.op.europa.eu/#/datasets
  2. Select a dataset to browse
  3. Go to the Sparql page (on the right of the page)
  4. Write your query, or copy-paste one from our sample queries
  5. Click Submit to run the query
  6. Export the query results in XLS, CSV

via the Cellar SPARQL endpoint, Cellar, the digital dissemination repository of the Publications Office (OP) reachable via URL: https://publications.europa.eu/webapi/rdf/sparql where you can:

  • Create queries within a classification
  • Create federated queries across Eurostat classifications stored in the Triple store (Cellar)
  • Create federated queries  across LOD classifications stored remotely Example: NACE – ISIC (hosted by FAO in Caliper)
SPARQL query editor
  1. Go to SPARQL endpoint: https://publications.europa.eu/webapi/rdf/sparql
  2. Write your query, or copy-paste one from our sample queries
  3. Click Run Query to run the query
  4. Export the query results in XLS, CSV

The SPARQL endpoint also can be accessed by the SPARQL editor: https://yasgui.triply.cc/

SPARQL access example
  1. Go to : https://yasgui.triply.cc/
  2. Enter the SPARQL endpoint: https://publications.europa.eu/webapi/rdf/sparql
  3. Write your query, or copy-paste one from our sample queries
  4. Click Run Query to run the query
  5. Export the query results in XLS, CSV

 

2. Sample queries for reuse

If you are new for querying online datasets with SPARQL, you can try out one of our sample queries below, which will directly performed via Yasgui editor: https://yasgui.triply.cc/.

Please note that you can customize your SPARQL query depending on your needs. Different examples are added inside the queries in comments (prefix by #). For example, the placeholder "<[scheme_uri]>" which is the classification URI, might needs to be replaced as appropriate. 

To retrieve all Eurostat's  classification's URI's use the query provided below:

 

2.1 Queries within a single classification (available both in ShowVoc and Cellar)

 

2.2 Queries on correspondences of a single classification (available only in Cellar)

 

2.3 Queries across classifications (available only in Cellar)