-
Wikidata has several ways to access the data, as can be seen here: https://www.wikidata.org/wiki/Wikidata:Data_access One of them is the Wikidata Query Service, which is based on a language called SPARQL. One student asked me if it was possible to use SPARQL in the project, is it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, there is no problem to use SPARQL, and indeed, SPARQL is a very flexible and powerful language to obtain data from Wikidata. As an example, the following query, retrieves the capitals of all the autonomous communities of Spain. SELECT ?city ?cityLabel ?com ?comLabel WHERE {
# Get the values that are instances of (P31) Spanish Autonomous Community (Q10742)
?com wdt:P31 wd:Q10742 .
# Get the values that are capitals of (P1376) of ?com
?city wdt:P1376 ?com .
# Service that generates labels
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} The previous query can be run directly here: https://w.wiki/95DU |
Beta Was this translation helpful? Give feedback.
Yes, there is no problem to use SPARQL, and indeed, SPARQL is a very flexible and powerful language to obtain data from Wikidata. As an example, the following query, retrieves the capitals of all the autonomous communities of Spain.
The previous query can be run directly here: https://w.wiki/95DU