Labels
Retrieve human-readable names for entities. Wikidata stores labels in many languages, and the label service makes it easy to get readable names instead of Q-numbers.
Understanding Labels
Wikidata entities are identified by Q-numbers (like Q42 for Douglas Adams), but humans prefer names. The wikibase:label service automatically retrieves labels, descriptions, and aliases for any variable ending in "Label", "Description", or "AltLabel".
Basic Label Examples
SELECT ?person ?personLabel
WHERE {
?person wdt:P31 wd:Q5 ;
wdt:P106 wd:Q1930187 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 10
The SERVICE block requests labels in English. The variable ?personLabel is automatically populated with the English label for ?person. If no English label exists, it falls back to the Q-number.
SELECT ?city ?cityLabel
WHERE {
?city wdt:P31 wd:Q515 ;
wdt:P17 wd:Q142 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr,de". }
}
LIMIT 20
Language codes can be comma-separated for fallback. This query gets French cities and tries English labels first, falling back to French then German if needed. This is useful for entities that may not have labels in your primary language.
Labels, Descriptions, and Aliases
SELECT ?person ?personLabel ?personDescription ?personAltLabel
WHERE {
VALUES ?person { wd:Q42 wd:Q80 wd:Q937 }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
The label service populates three types of variables: Label (the main name), Description (a short description), and AltLabel (alternative names/aliases, separated by commas). Just add the suffix to any entity variable.
Manual Label Retrieval
SELECT ?person ?name
WHERE {
?person wdt:P31 wd:Q5 ;
wdt:P106 wd:Q36180 ;
rdfs:label ?name .
FILTER(LANG(?name) = "en")
}
LIMIT 10
You can also retrieve labels directly using rdfs:label with a LANG() filter. This gives more control but requires explicit filtering. The label service is usually more convenient for simple cases.
Key Entities Used in Examples
| Entity | ID | Description |
|---|---|---|
| human | wd:Q5 | Any human being |
| journalist | wd:Q1930187 | Person who collects and writes news |
| city | wd:Q515 | Large human settlement |
| France | wd:Q142 | Country in Western Europe |
| Douglas Adams | wd:Q42 | English author |
| Tim Berners-Lee | wd:Q80 | Inventor of the World Wide Web |
| Albert Einstein | wd:Q937 | German-born physicist |
| writer | wd:Q36180 | Person who uses written words |