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.

Sparql query examples

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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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 <https://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:<https://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:<https://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:<https://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:<https://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:<https://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 
  	}
} 

Test 1: How many authors are there in Euskariana?

PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT (COUNT(?author) AS ?amount_authors) 
FROM <https://id.euskadi.eus/graph/euskariana>
WHERE { 
  ?author rdf:type edm:Agent .
} 

Test 2: How many digital objects (Provided Cultural Heritage Object) are there in Euskariana?

PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT (COUNT(?work) AS ?amount_works) 
FROM <https://id.euskadi.eus/graph/euskariana>
WHERE { 
  ?work rdf:type edm:ProvidedCHO .
} 

Test 3: Digital objects and their author that contain "Bilbao" in their title

PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>

SELECT DISTINCT ?obra_literal ?autor_literal
FROM <https://id.euskadi.eus/graph/euskariana>
WHERE { 
  ?obraObject rdf:type edm:ProvidedCHO .
  ?obraObject  dc:creator ?autor .
  ?obraObject dc:title ?obra_literal .
  ?autor  skos:prefLabel ?autor_literal .
  FILTER CONTAINS(?obra_literal, "Bilbao")  .
}
ORDER BY asc(?autor_literal)

Test 1: Municipal indicators list

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?nombre_indicador
FROM <https://id.euskadi.eus/graph/Udalmap>
WHERE {
  ?medicion rdf:type ?indicador .
  ?indicador rdfs:label ?nombre_indicador
} 

Test 2: Indicator values that contain the word "agro" ordered by year

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?nombre_indicador 
FROM <https://id.euskadi.eus/graph/Udalmap>
WHERE {
  ?medicion rdf:type ?indicador .
  ?medicion <http://purl.org/linked-data/sdmx/2009/measure#obsValue> ?value .
  ?medicion <http://purl.org/linked-data/sdmx/2009/dimension#refPeriod> ?year .
  ?indicador rdfs:label ?nombre_indicador .
  FILTER CONTAINS(?nombre_indicador, 'agro') .
} 

Test 3: Indicator values that contain the word "agro" of municipalities of Alava (and its link to WikiData), ordered by year

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX gn: <https://www.geonames.org/ontology#>
PREFIX territorio: <http://vocab.linkeddata.es/datosabiertos/def/sector-publico/territorio#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX measure: <http://purl.org/linked-data/sdmx/2009/measure#>
PREFIX dimension: <http://purl.org/linked-data/sdmx/2009/dimension#>

SELECT DISTINCT ?nombre_indicador ?year ?value ?location_name 
WHERE {

        GRAPH <https://id.euskadi.eus/graph/Udalmap>{
            ?medicion rdf:type ?indicador .
            ?medicion measure:obsValue ?value .
            ?medicion dimension:refPeriod ?year .
            ?medicion wgs:location ?location .
            ?indicador rdfs:label ?nombre_indicador .
         FILTER CONTAINS(?nombre_indicador, 'agro') .
        }

        GRAPH <https://id.euskadi.eus/graph/NORA>{
            ?location gn:officialname ?location_name .
            ?location territorio:provincia ?provincia .
            ?provincia rdfs:label 'Araba'@eu .
        }

        GRAPH <https://id.euskadi.eus/graph/NORA-links>{
            ?location owl:sameAs ?location_wikidata .
        }
 }
ORDER BY ?nombre_indicador ?location_name ?year

Test 4: Indicator values that contain the word "agro" of municipalities of Alava (and its link to WikiData), ordered by year, along with their area (obtained from DBPedia)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX gn: <https://www.geonames.org/ontology#>
PREFIX territorio: <http://vocab.linkeddata.es/datosabiertos/def/sector-publico/territorio#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX measure: <http://purl.org/linked-data/sdmx/2009/measure#>
PREFIX dimension: <http://purl.org/linked-data/sdmx/2009/dimension#>
PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT DISTINCT ?nombre_indicador ?year ?value ?location_name ?area 
WHERE {
        GRAPH <https://id.euskadi.eus/graph/Udalmap>{
            ?medicion rdf:type ?indicador .
            ?medicion measure:obsValue ?value .
            ?medicion dimension:refPeriod ?year .
            ?medicion wgs:location ?location .
            ?indicador rdfs:label ?nombre_indicador .
         FILTER CONTAINS(?nombre_indicador, 'agro') .
        }

        GRAPH <https://id.euskadi.eus/graph/NORA>{
            ?location gn:officialname ?location_name .
            ?location territorio:provincia ?provincia .
            ?provincia rdfs:label 'Araba'@eu .
        }

        GRAPH <https://id.euskadi.eus/graph/NORA-links>{
            ?location owl:sameAs ?location_wikidata .
        }

        SERVICE <https://dbpedia.org/sparql> {
            ?location_dbpedia owl:sameAs ?location_wikidata .
            ?location_dbpedia dbo:areaTotal ?area .
        }

 }
ORDER BY ?nombre_indicador ?location_name ?year

Test 1: In which town is Lehendakaritza located?

PREFIX dir: <https://id.euskadi.eus/def/directory#>
PREFIX callejero: <http://vocab.linkeddata.es/datosabiertos/def/urbanismo-infraestructuras/callejero#>
PREFIX gn: <https://www.geonames.org/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <https://schema.org/>
PREFIX nora: <https://id.euskadi.eus/def/nora#>

SELECT * 
WHERE {
  GRAPH <https://id.euskadi.eus/graph/Directory> {
     ?equipment dir:equipmentOf ?organization .
     ?equipment schema:location ?portal .
     ?portal callejero:via ?street .
     ?organization rdfs:label ?org_label .
     FILTER CONTAINS(?org_label, "Lehendakaritza") .
  } 

  GRAPH <https://id.euskadi.eus/graph/NORA> {
     ?street nora:localidad ?localidad .
     ?localidad gn:officialname ?localidad_name .
  } 
} 

Test 2: Which sub-organizations belong to the organization of Iñigo Urkullu?

PREFIX person: <http://www.w3.org/ns/person#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <https://schema.org/>

SELECT * 
WHERE {
  GRAPH <https://id.euskadi.eus/graph/Directory> {
     ?person rdf:type person:Person .
     ?person rdfs:label ?person_label .
     ?person schema:memberOf ?organization .
     ?organization schema:subOrganization ?subOrg .
     ?subOrg rdfs:label ?subOrg_label .
     FILTER CONTAINS(?person_label, "Urkullu") .
  } 
} 

Test 3: Get the resumes of people who work in entities that include the term "Empleo" in their name

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <https://schema.org/>
PREFIX dir: <https://id.euskadi.eus/def/directory#>

SELECT ?org_label ?person_label ?cv_url WHERE { 
  GRAPH <https://id.euskadi.eus/graph/Directory> {
     ?organization rdf:type schema:GovernmentOrganization .
     ?organization rdfs:label ?org_label .
     ?person schema:memberOf ?organization .
     ?person rdfs:label ?person_label .
     ?person dir:curriculum ?cv_url .
     FILTER CONTAINS(?org_label, "Empleo") .
  } 
} 

Test 1: Get the number of municipalities of Araba

PREFIX esadm: <http://vocab.linkeddata.es/datosabiertos/def/sector-publico/territorio#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT  (COUNT(?municipioAraba) as ?count) 
  WHERE {
     ?municipioAraba esadm:provincia ?provincia .
     ?provincia rdfs:label "Araba"@eu .
  } 

Test 2: Get the country and the autonomous community of Bizkaia

This transitive query takes advantage of automatic reasoning to get entities that are not directly related to each other.

PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>

SELECT ?country 
  WHERE {
     <https://id.euskadi.eus/public-sector/urbanism-territory/province/48> geosparql:sfWithin ?country .
  } 

Test 3: Federated query

This query demonstrates the usefulness of existing links. From this basic query, data from WikiData, DBPedia, etc. can be combined, exploiting the power of Linked Data.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX gn: <https://www.geonames.org/ontology#>

SELECT ?entity ?euskoLabel ?wikidataEntity ?wikidataLabel ?dbpediaEntity ?dbpediaLabel

WHERE {
    GRAPH <https://id.euskadi.eus/graph/NORA> {
    	?entity gn:officialname ?euskoLabel .
    }
    GRAPH <https://id.euskadi.eus/graph/NORA-links> {
    	?entity owl:sameAs ?wikidataEntity .
    }
    SERVICE <https://query.wikidata.org/sparql> {
       ?wikidataEntity rdfs:label ?wikidataLabel . 
    } 
    SERVICE <https://dbpedia.org/sparql> { 
       ?dbpediaEntity owl:sameAs ?wikidataEntity .
       ?dbpediaEntity rdfs:label ?dbpediaLabel . 
    } 
}
LIMIT 500