Wikidata:Request a query
Shortcuts: WD:RAQ, w.wiki/LX
Request a query This is a page where SPARQL queries [Q114898838] can be requested. Please provide feedback if a query is written for you. You can also request help to rewrite queries that don't work anymore, due to the WDQS graph split. For sample queries, see Examples and Help:Dataset sizing. Property talk pages include also summary queries for these. For help writing your own queries, or other questions about queries, see Wikidata talk:SPARQL query service/queries and Wikidata:SPARQL query service/query optimization. Help resources about Wikidata Query Service (Q20950365) and SPARQL: Wikidata:SPARQL query service/Wikidata Query Help and Category:SPARQL. To report an issue about the Query Service (interface, results views, export...) please see Wikidata:Contact the development team/Query Service and search. |
| On this page, old discussions are archived. An overview of all archives can be found at this page's archive index. The current archive is located at 2026/04. |
SpBot archives all sections tagged with {{Section resolved|1=~~~~}} after 2 days.
|
Herohero
[edit]Add a column with a link to Herohero https://herohero.co Ablervases (talk) 14:09, 15 March 2026 (UTC)
- @Ablervases: Same as above! If you want a new property, then you can add your wish at Wikidata:Property proposal. --sk (talk) 19:29, 16 March 2026 (UTC)
Find a specifc subset of occupations
[edit]I am looking for a query to find Wikidata items of a list of occupations. I only know the occupations by label, and I know that they are occupations. Not all occupations are modeled equally in Wikidata, so some paths may lead over "subclass of" towards occupation and some over "instance of".
My first intuition is to retrieve the first 10 items with that label and do a Breadth-first search over their classes and superclasses until I find occupation.
But maybe there is a query that can do the same / similar, but more efficiently? My current attempt does work for an example, but not for the list (#commented out) yet.
I am trying to find the approach that is the least burden on Wikidata, so if it might be better to just outright dump all subclasses and instances of occupations at once and then search locally, that might also be an approach.
SELECT DISTINCT ?item ?itemLabel WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
# VALUES ?term { "baker" "smith" } # eventually will contain ~2000 occupations
{
SELECT DISTINCT ?item WHERE {
?item rdfs:label "baker"@en.
# ?item rdfs:label ?itemLabel .
# FILTER(LCASE(STR(?itemLabel)) = ?term)
{
?item p:P31 ?statement1.
?statement1 (ps:P31/(wdt:P279*)) wd:Q12737077.
}
UNION
{
?item p:P279 ?statement2.
?statement2 (ps:P279/(wdt:P279*)) wd:Q12737077.
}
}
LIMIT 100
}
}
Thanks in advance and best regards, TimBorgNetzWerk (talk) 10:37, 18 March 2026 (UTC)
Query items created by a certain user
[edit]Is there any way to query for all items of a P31 created by a specified user on Wikidata? -wd-Ryan (Talk/Edits) 17:41, 18 March 2026 (UTC)
- @Wd-Ryan: I think this is not possible with Wikidata Query Service. If you want this, then you can program it. You can get the data from the Wikidata-API for all edits of a user. And then scan via API all this changes and find the P31 creating edits. - Show API-Documantaion and API-Sandbox. - For example my last 500 edits. --sk (talk) 13:05, 25 March 2026 (UTC)
Find items given by their corresponding English language Wikipedia article name
[edit]I have some Wikipedia article names in ?name and want to find the Wikidata items for them. I found the opposite query at https://stackoverflow.com/a/67377047 and tried to rephrase it, but to no avail:
SELECT ?item ?itemLabel ?itemDescription ?name ?article WHERE
{
VALUES ?name {"2025 Africa Cup of Nations final" "2026 Kazakh constitutional referendum"}
?article schema:name ?name .
?article schema:isPartOf <https://en.wikipedia.org/> .
?article schema:about ?item .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Thanks for any pointers.--Harmonica (talk) 06:28, 21 March 2026 (UTC)
- Is a bit of string mangling okay?
SELECT ?name ?item WHERE {
VALUES ?name {"2025 Africa Cup of Nations final" "2026 Kazakh constitutional referendum"}
bind(iri(concat("https://en.wikipedia.org/wiki/", replace(?name, " ", "_"))) as ?article)
?article schema:about ?item.
}
- On further consideration, I realised that it's about string language. If you can add languages to the strings inline, do so:
SELECT ?item ?itemLabel ?itemDescription ?name ?article WHERE
{
VALUES ?name {"2025 Africa Cup of Nations final"@en "2026 Kazakh constitutional referendum"@en}
?article schema:name ?name .
?article schema:isPartOf <https://en.wikipedia.org/> .
?article schema:about ?item .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
- Alternatively, this will be a lot slower. I had to go to QLever to even have it complete:
SELECT ?item ?itemLabel ?itemDescription ?name ?article WHERE
{
VALUES ?name {"2025 Africa Cup of Nations final" "2026 Kazakh constitutional referendum"}
bind(strlang(?name, "en") as ?en_name).
?article schema:name ?en_name .
?article schema:isPartOf <https://en.wikipedia.org/> .
?article schema:about ?item .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
- Tagging the string literals with @en is not a problem. I just wasn't aware of the need to do that. Thank you!--Harmonica (talk) 06:29, 22 March 2026 (UTC)
Wikispecies page linked to a items with a specific property
[edit]I'm looking for a query that can find items with the property instance of (P31)family name (Q101352) and a link to wikispecies (such items should almost always link to a disambiguation page). Circeus (talk) 15:19, 29 March 2026 (UTC)
I figured it out myself in the end
SELECT ?sitelink ?item ?itemLabel WHERE {
?sitelink schema:about ?item ;
schema:isPartOf <https://species.wikimedia.org/> .
?item wdt:P31 wd:Q101352.
}
LIMIT 100
Circeus (talk) 13:28, 30 March 2026 (UTC)
Query all video game pages given certain conditions
[edit]I'm in the process of cleaning up various enwiki video game List articles, and am looking for a way to automate / speed up the process of pulling the various bits of information into the table. An example page is as follows: https://en.wikipedia.org/wiki/List_of_role-playing_video_games:_2026_to_2027.
All of the pages I'm working on have the following information:
- Release date (some pages only use release year, but I can simplify that myself)
- Name of game in English (preferably a EN wikilink to the appropriate page, if possible)
- Platforms game released on that year (if there were multiple release dates that year, then each release date should have the appropriate platforms)
- Game genres (some games filter this data, but I can simplify that myself)
- Setting (I'm not sure if there's a single Wikidata property that covers this field)
- Game developer (preferably a EN wikilink to the appropriate page, if possible)
- Game publisher (preferably a EN wikilink to the appropriate page, if possible)
- Country of origin
The goal is to be able to filter this query as necessary for the specific context in mind.
- Every query should be able to be restricted to a single, configurable year
- Some queries will be for only games of specific genres (such as RPG, Action-RPG, etc)
I have no idea how possible all of this is, especially pulling the specific EN wikilinks. Any help with this is appreciated 13akoors (talk) 17:34, 5 April 2026 (UTC)

