The SPARQL API is different from the other Europeana APIs in that it allows you to explore connections between Europeana data and outside data sources, like VIAF, Iconclass, Getty Vocabularies (AAT), Geonames, Wikidata, and DBPedia. If you are looking for a way to delve into the structured metadata of Europeana (for instance, to ask the question "What are all the French 18th-century painters with at least five artworks available through Europeana'), this is the API for you. If you want to simply search Europeana in an unstructured way (for instance 'give me all results for the word 'cat'), then using the Search API is a better choice. SPARQL is part of Europeana's Linked Open Data initiative.
Before start using this API, we recommend reading the introduction page for an overview of the EDM model and reading the Terms of Use. If you want to get started with this API, go directly to the Getting Started section or try it out directly on the Console.
If you want to learn more about SPARQL, we recommend the How to SPARQL and Wikibooks SPARQL tutorial. We also recommend reading the Finding Europeana audio with SPARQL and SPARQL for humanists as they were the inspiration for us to provide this API.
Update
The SPARQL API is powered by a separate database (Virtuoso) which reflects the current state of the Europeana datasets as of July 2017. We are working on a monthly update for this endpoint so that it is kept in sync with the main Europeana APIs.
Discussion
Besides our main discussion channels, we have a dedicated Europeana LOD Google Group for a discussion on this topic.
Getting Started
Things to know before starting
<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" .
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?
https://sparql.europeana.eu/
A first query
1. Add your prefixes by selecting them in the SPARQL editor as described above.
Example of Step 1: Add your Prefixes
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.
Example of Step 2: create a SELECT clause
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
Example of step 3: define your 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
example of step 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.
Example of how to use ORDER BY
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.
More examples of SPARQL Queries
Example 1: List of data providers which contributed content to Europeana
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT ?DataProvider
WHERE { ?Aggregation edm:dataProvider ?DataProvider }`
Example 2: List of datasets from Italy
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT DISTINCT ?Dataset
WHERE {
?Aggregation edm:datasetName ?Dataset ;
edm:country "Italy"
}
Example 3: Objects provided to Europeana from the 18th and from France
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT DISTINCT ?ProvidedCHO ?year
WHERE {
?Aggregation edm:aggregatedCHO ?ProvidedCHO ;
edm:country "France" .
?Proxy ore:proxyFor ?ProvidedCHO ;
edm:year ?year .
FILTER (?year > "1700" && ?year < "1800")
}
ORDER BY asc(?year)
LIMIT 100
Example 4: Listing of edm:Agent
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT ?Agent
WHERE { ?Agent rdf:type edm:Agent }
LIMIT 100
Example 5: Objects provided to Europeana linking to edm:Place
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT DISTINCT ?ProvidedCHO
WHERE {
?Place rdf:type edm:Place .
?Proxy ?property ?Place ;
ore:proxyIn ?Aggregation .
?Aggregation edm:aggregatedCHO ?ProvidedCHO
}
Example 6: List certain attributes of an item using Dublin Core terms
Try this on the wikidata query service
#Get information of Europeana item using federated query
PREFIX dc: <http: 1.1="" dc="" elements="" purl.org="">
PREFIX edm: <http: edm="" schemas="" www.europeana.eu="">
PREFIX ore: <http: ore="" terms="" www.openarchives.org="">
SELECT * WHERE {
BIND(<http: 91622="" data.europeana.eu="" provider="" proxy="" raa_kmb_16000200042758=""> as ?p854)
SERVICE <http: sparql.europeana.eu=""> {
{
?p854 <http: created="" dc="" purl.org="" terms=""> ?created .
?p854 <http: 1.1="" dc="" elements="" identifier="" purl.org=""> ?identifier .
?p854 <http: 1.1="" dc="" elements="" publisher="" purl.org=""> ?publisher .
?p854 <http: 1.1="" dc="" elements="" purl.org="" rights=""> ?rights .
?p854 <http: 1.1="" dc="" elements="" purl.org="" title=""> ?title .
?p854 <http: 1.1="" dc="" description="" elements="" purl.org=""> ?description .
}
}
}
</http:></http:></http:></http:></http:></http:></http:></http:></http:></http:></http:>
Example 7: Objects provided to Europeana linking to skos:Concept from the Getty target vocabulary
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
SELECT DISTINCT ?ProvidedCHO
WHERE {
?Concept rdf:type skos:Concept .
FILTER strstarts(str(?Concept), "http://vocab.getty.edu/aat/") .
?Proxy ?property ?Concept ;
ore:proxyIn ?Aggregation .
?Aggregation edm:aggregatedCHO ?ProvidedCHO
}
LIMIT 100
Example 8: Use a federated query
to extract Europeana's DC:subjects for a certain item and translate them to other vocabulary URIs
Try this on the Sophox query service
# Find Commons category suggestions for a Commons file using subjects stored in Europeana
# 1.) Bind identifier of the photo to variable
# 2.) Read subjects in Finnish of photo defined by identifier from Europeana
# 3.) Translate subjects to YSO ontology using Finto-service.
# 4.) Translate YSO items to Wikidata items using Wikidata and read Commons categories
SELECT * WITH {
SELECT * WHERE {
# 1.) Bind identifier of the photo to variable
BIND("HK19700502:254" as ?identifier)
# 2.) Read subjects in Finnish of photo defined by identifier from Europeana
SERVICE <http: sparql.europeana.eu=""> {
?europeana <http: 1.1="" dc="" elements="" identifier="" purl.org=""> ?identifier .
?europeana <http: 1.1="" dc="" elements="" purl.org="" subject=""> ?subject .
}
}
} AS %europeana
WHERE {
INCLUDE %europeana .
# 3.) Translate subjects to YSO ontology using Finto-service.
SERVICE <http: api.finto.fi="" sparql=""> {
?yso skos:prefLabel ?subject ;
skos:inScheme <http: onto="" www.yso.fi="" yso="">
}
# 4.) Translate YSO items to Wikidata items using Wikidata and read Commons categories
BIND(REPLACE(STR(?yso), "http://www.yso.fi/onto/yso/p", "") as ?yso_number)
SERVICE <https: query.wikidata.org="" sparql=""> {
?wikidata wdt:P2347 ?yso_number .
?wikidata wdt:P373 ?commonscat
}
}
</https:></http:></http:></http:></http:></http:>
Credits
The initial pilots were set up by Ontotext under the framework of the Europeana Creative project and using the Ontotext GraphDB semantic repository (which has been replaced by Virtuoso).