SPARQL endpoint GUI

The SPARQL endpoint is: https://api.euskadi.eus/sparql/

The SPARQL endpoint can be queried via GET or POST and the expected result differs depending on the accepted mime-type (the Accept HTTP header).

If [accept] header is HTML (for example) using a web browser, a SPARQL GUI is presented. Using this GUI anyone can issue SPARQL queries to the [triple-store].

  • Using a web browser enter: https://api.euskadi.eus/sparql/
  • Enter a SPARQL query.

Below is a series of example sparql queries. They are queries on the datasets currently available on the sparql endpoint:

Test 1: How many datasets are there in Open Data Euskadi?

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (COUNT(?dataset) AS ?cantidad_datasets) 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
} 

Test 2: Datasets modified in 2021, sorted by modification date (oldest first)

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?dataset ?title ?date_modified 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dct:modified ?date_modified .
  ?dataset dct:title ?title .
  FILTER (?date_modified < "2022-01-01T00:00:00"^^xsd:dateTime && ?date_modified > "2021-01-01T00:00:00"^^xsd:dateTime)
}
ORDER BY ?date_modified

Test 3: Available formats of dataset distributions

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT DISTINCT ?format_value 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:distribution ?distribution .
  ?distribution dct:format ?format .
  ?format rdf:value ?format_value .
}

Test 4: Datasets that have distributions in CSV format

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT DISTINCT ?dataset 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:distribution ?distribution .
  ?distribution dct:format ?format .
  ?format rdf:value "text/csv"
}

Test 5: Coronavirus datasets

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT DISTINCT ?dataset 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:keyword ?keywords .
  FILTER CONTAINS(?keywords, "coronavirus") .
}

Test 6: Topics covered by currently available datasets

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>

SELECT DISTINCT ?tema 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:theme ?tema .
}

Test 7: Datasets on urban planning arranged chronologically

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX sector: <https://datos.gob.es/kos/sector-publico/sector/>

SELECT ?dataset ?date_modified 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:theme sector:urbanismo-infraestructuras .
  ?dataset dct:modified ?date_modified .
  ?dataset dct:description ?description .
}
ORDER BY ?date_modified

Test 8: Datasets on urban planning that contain the word "biosphere" in the description ordered chronologically

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX sector: <https://datos.gob.es/kos/sector-publico/sector/>

SELECT ?dataset ?description ?date_modified 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dcat:theme sector:urbanismo-infraestructuras .
  ?dataset dct:modified ?date_modified .
  ?dataset dct:description ?description .
  FILTER CONTAINS(?description, "Biosfera") .
}
ORDER BY ?date_modified

Test 9: Datasets covering a time range in the data itself between 2018 and 2022

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX time: <http://www.w3.org/2006/time#>

SELECT ?dataset ?title ?beggining_time ?end_time 
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dct:title ?title .
  ?dataset dct:temporal ?temporal .
  ?temporal time:hasBeginning ?beggining .
  ?beggining time:inXSDDateTime ?beggining_time .
  ?temporal time:hasEnd ?end .
   ?end time:inXSDDateTime ?end_time .
  FILTER (?end_time < "2022-01-01T00:00:00"^^xsd:dateTime && ?beggining_time > "2018-01-01T00:00:00"^^xsd:dateTime)
}

Test 10: Datasets that are obtained with a periodicity of 3 months

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX time: <http://www.w3.org/2006/time#>

SELECT ?dataset ?title  
FROM <http://id.euskadi.eus/graph/DCATOpenDataEuskadi>
WHERE { 
  ?dataset rdf:type dcat:Dataset .
  ?dataset dct:title ?title .
  ?dataset dct:accrualPeriodicity ?periodicity .
  ?periodicity rdf:value ?periodicity_value .
  ?periodicity_value time:months "3"^^xsd:integer .
}

Test 11: Basic federation of SPARQL endpoints

PREFIX dcat:<http://www.w3.org/ns/dcat#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX sector: <https://datos.gob.es/kos/sector-publico/sector/>
PREFIX sector_gob: <http://datos.gob.es/kos/sector-publico/sector/>

SELECT ?dataset ?dataset_gob 
WHERE { 
    GRAPH <http://id.euskadi.eus/graph/DCATOpenDataEuskadi> {
      ?dataset rdf:type dcat:Dataset .
      ?dataset dcat:theme sector:medio-ambiente .
  }

    SERVICE <https://datos.gob.es/virtuoso/sparql> {
      ?dataset rdf:type dcat:Dataset .
      ?dataset_gob dcat:theme sector_gob:medio-ambiente .
  }
}

Test 1: Describe the resource of the General Administration of the Basque Country

DESCRIBE <http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi>

The expected result is (Prefixes not shown for brevity):

<http://id.euskadi.eus/id/public-sector/government/GovernmentalAdministrativeRegion/euskadi> <http://schema.org/mainEntityOfPage> <http://www.euskadi.eus> ;
owl:sameAs <http://datos.gob.es/recurso/sector-publico/territorio/Autonomia/Pais-Vasco> .

Test 2: Metadata

PREFIX graph:<http://id.euskadi.eus/graph/>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>

SELECT DISTINCT ?loddistribution ?otherdistribution 
WHERE {
  ?maindistribution dcat:distribution  ?loddistribution .
  ?maindistribution dcat:distribution ?otherdistribution .
  ?loddistribution sd:namedGraph graph:bopv-european-legislation-identifier-eli .
  GRAPH graph:bopv-european-legislation-identifier-eli  {
    	?sub ?pred ?obj 
  	}
} 

Test 3: ELI legal resources ordered by date

PREFIX schema: <https://schema.org/> 
PREFIX eli: <https://data.europa.eu/eli/ontology#> 
PREFIX graph:<http://id.euskadi.eus/graph/>

SELECT  DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
	GRAPH graph:bopv-european-legislation-identifier-eli {
		?legalresource eli:date_publication ?datePub .
		?legalresource eli:is_realized_by ?legalexpresion .
    	?legalexpresion eli:title ?title .
		?eliformat eli:embodies ?legalexpresion .
		?eliformat schema:mainEntityOfPage ?legeguneaurl .
	}
}
ORDER BY ASC (?datePub)

Test 4: ELI legal resources between two dates

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <https://schema.org/> 
PREFIX eli: <https://data.europa.eu/eli/ontology#> 
PREFIX graph:<http://id.euskadi.eus/graph/>

SELECT  DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
	GRAPH graph:bopv-european-legislation-identifier-eli {
		?legalresource eli:date_publication ?datePub .
		?legalresource eli:is_realized_by ?legalexpresion .
    	?legalexpresion eli:title ?title .
		?eliformat eli:embodies ?legalexpresion .
		?eliformat schema:mainEntityOfPage ?legeguneaurl .
	}
     FILTER (?datePub > "1936-01-01"^^xsd:date  && ?datePub < "1938-01-01"^^xsd:date)
}

Test 5: ELI legal resources between two dates and title contains a string

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <https://schema.org/> 
PREFIX eli: <https://data.europa.eu/eli/ontology#> 
PREFIX graph:<http://id.euskadi.eus/graph/>

SELECT  DISTINCT ?datePub ?legeguneaurl ?title
WHERE {
	GRAPH graph:bopv-european-legislation-identifier-eli {
		?legalresource eli:date_publication ?datePub .
		?legalresource eli:is_realized_by ?legalexpresion .
    	?legalexpresion eli:title ?title .
		?eliformat eli:embodies ?legalexpresion .
		?eliformat schema:mainEntityOfPage ?legeguneaurl .
	}
     FILTER (?datePub > "2020-01-01"^^xsd:date  && ?datePub < "2021-01-01"^^xsd:date)
     FILTER regex (str(?title), "^Orden", "i")
}

Test 6: ELI predicates

PREFIX graph:<http://id.euskadi.eus/graph/>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX dcat: <http://www.w3.org/ns/dcat#>

SELECT ?pred
WHERE {
  GRAPH graph:bopv-european-legislation-identifier-eli  {
    	?sub ?pred ?obj 
  	}
}