Things to know before starting
- Europeana data is represented as a triple:
<subject> <predicate> <object>
Each subject, predicate and an object represent a node within Europeana’s network of resources. These statements are usually represented as URIs to which certain labels might correspond.
For instance
<http://data.europeana.eu/item/2021604/C2D27CB79870761BE291A3FACAB963F62D7CA39B> <http://purl.org/dc/terms/creator> "Moltzheim, A. de" .
- A SPARQL query requires the declaration of PREFIXes that are shortcuts to the labels of given predicates.
- The different packages of information contained in the Europeana data are described using several classes in the Europeana Data Model (EDM). We invite you to consult our Data structure page and the EDM documentation if you need more details on the model.
- When formulating a query don’t forget to adjust the LIMIT value which indicates the number of results to be returned by the query. Note that the query may take longer if the number of results asked is high.
- If you set a LIMIT value but still want to be able to select the range of results you will get within the dataset, adjust the OFFSET value.
Where is the endpoint available?
http://sparql.europeana.eu/
A first query
1. Add your prefixes by selecting them in the SPARQL editor as described above.
For instance a selection of the namespaces dc, edm and ore will give you:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
2. Then SELECT the things you want to find and define names for these variables.
We want all the results with a title, a creator, a media URL and a year.
SELECT ?title ?creator ?mediaURL ?year
3. Define the variables
WHERE {
?item edm:type "SOUND" ;
ore:proxyIn ?proxy;
dc:title ?title ;
dc:creator ?creator .
?proxy edm:isShownBy ?mediaURL .
?EuropeanaProxy edm:year ?year .
}
In this example you restrict the results to the resources with the edm:type SOUND.
4. Define a LIMIT
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
SELECT ?title ?creator ?mediaURL ?date
WHERE {
?CHO edm:type "SOUND" ;
ore:proxyIn ?proxy;
dc:title ?title ;
dc:creator ?creator ;
dc:date ?date .
?proxy edm:isShownBy ?mediaURL .
}
LIMIT 100
You obtain all the first 100 SOUND resources which have a title, a creator, a media URL and a year.
How to define more complex queries
You can start defining more complex queries which will group, list, filter or order your results. The commands COUNT, GROUP BY and ORDER BY can be used for this purpose.
For instance we want to order our results by year (ascending order)
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
SELECT ?title ?creator ?mediaURL ?date
WHERE {
?CHO edm:type "SOUND" ;
ore:proxyIn ?proxy;
dc:title ?title ;
dc:creator ?creator;
dc:date ?date .
?proxy edm:isShownBy ?mediaURL .
FILTER (?date > "1780" && ?date < "1930")
}
ORDER BY asc (?date)
LIMIT 100
You will notice that this type of query takes longer as we are asking to the database to not only return results but also to order them.