SPARQL Endpoint

The SPARQL interface is a service which allows queries in data stored in RDF in the SPARQL language. It offers developers/professionals great power and flexibility when creating applications and performing searches.

Stored Information

All of the information that can be searched can be found uploaded to a semantic database. In this type of database the information is stored in graphs.

The semantic database has two graphs:

How to use it

All queries are sent using GET requests, which return data according to the parameters specified in the reference.

The base address of our SPARQL point is the following:

To this address, the parameter "query" must be added, followed by the query you wish to make.

For example, if you want to conduct the following search, select distinct ?type where {?x a ?type} LIMIT 100, which returns the different types uploaded in our SPARQL point:

  1. It should be coded substituting the spaces for “+”, in the following way: select+distinct+?type+where+{?x+a+?type}+LIMIT+100
  2. Once coded, and if you know the address of our SPARQL point, it is run as follows:{?x+a+?type}+LIMIT+100

If you don’t add the parameter “query” to theSPARQL point base address in the search you’re conducting, it will give you a 'page not found' error.

By default, the response format is HTML, but another can be specified via the parameter “format”. This parameter may have the following values:


If no graph is specified while performing a search, information on all available graphs will be returned.

You can look up all the available graphs using:

select distinct ?uri where { graph ?uri { ?s a ?t } }

If you want to look up which graph the information belongs to, you can specify with the variable ?gto find in which graph each?x can be found:

select distinct ?g ?type where { graph ?g { ?x a ?type. } } limit 100

You can get the results for only one using:

select distinct ?type where { graph <> { ?x a ?type. } } limit 100

Now, you only see the ?x that you’ll find in the specified graph

To send these requests you can also use a form. These types of forms offers help to the developer by providing a text area that uses colours to highlight the syntax, identify syntax errors, it has an auto-complete function and it allows the option of conducting searches, among other things.


To obtain all the classes in the SPARQl point

This query is very useful, because you can see all the types of information that’s stored.

In addition, to block information that’s not useful, you can specify your graphs.

First, specify the graph from the Catalogue:

select distinct ?tipo where
graph <> {
?x a ?tipo.

Now use both graphs at the same time thanks to the VALUES

select distinct ?tipo where
graph ?grafo {
?x a ?tipo.
values ?grafo { <> <> }

The final result is:


To obtain all of the Catalogue data sets

Now that you know the types, you're going to ask for all data sets, which correspond to this:

select distinct ?dataset where
?dataset a <>

The result is a list of URLs from all of the data sets.

To obtain all the properties the data sets have

If you want to get more information from the data sets, but you only know their URIs, ask for all of their properties:

select distinct ?propiedad where
?dataset a <> . ?dataset ?propiedad ?valor .

These are all the properties they have:


To obtain all entities that publish data

Use the property to get all the entities that publish data.

select distinct ?publicador where
?x a <> .
?x <> ?publicador.

The result is a set of URLs of all publishers.


To obtain the properties of the entities that publish data

With the URIs you don't know the names of the entities, so you're going to ask for the properties of these URIs

select distinct ?propiedad where
?x a <> .
?x <> ?publicador.
?publicador ?propiedad ?valor.

These are all of the publisher properties:


To obtain the names of the entities that publish data

Ask for the URI and the property

select distinct ?publicador ?label where
?x a <> .
?x <>
?publicador. ?publicador <> ?label.

The result is a very long list:

publisherlabel"Gobierno de Aragón""Gobierno de las Islas Baleares""Comunidad Autónoma de Canarias""Junta de Castilla y León"

To obtain the names of the ten entities that have the most published data sets and view how many there are

To conduct this search, you have to group the results, put them in order and limit the total to 10.

select distinct ?label count(?x) as ?num {
?x a <> .
?x <> ?publicador.
?publicador <> ?label.
group by (?label)
order by desc(?num)
limit 10

The result is:

"Gobierno de Aragón"2659
"Comunidad Autónoma de País Vasco"2208
"Centro de Investigaciones Sociológicas"2107
"Ayuntamiento de Málaga"651
"Ayuntamiento de Gijón"627
"Xunta de Galicia"315
"Generalitat Valenciana"313
"Ayuntamiento de Madrid"231
"Instituto Nacional de Estadística"205
"Junta de Castilla y León"196