Wikimedia Belgium bewikimedia https://be.wikimedia.org/wiki/Wikimedia_Belgium MediaWiki 1.47.0-wmf.19 first-letter Media Special Talk User User talk Wikimedia Wikimedia talk File File talk MediaWiki MediaWiki talk Template Template talk Help Help talk Category Category talk TimedText TimedText talk Module Module talk Translations Translations talk Wikidata Query 0 1948 39059 31078 2026-09-09T10:52:59Z Geertivp 171 see also 39059 wikitext text/x-wiki '''Wikidata Query''' allows you to search in the [[Wikidata]] database. It is using [[SPARQL|SPARQL queries]]. Queries can be written via query builder, examples, a simple GUI, or a SPARQL code editor. Since 2025, Wikidata Query has 2 instances, filtered for performance reasons: * [https://query.wikidata.org/ Classic Wikidata Query] (standard Wikibase replica, without scholarly articles) * [[Wikidata Query/Scholarly|Wikidata Query scholarly]] (filtered for scholarly articles) == Functionality == * query builder, examples, a simple GUI, or a SPARQL code editor * multilingual wikibase label service * geographical service * choose the output format (table, image grid, graph, geographical map) * code formatter * short URL code == Starting a simple query == * Go to [https://query.wikidata.org/ Classic Wikidata Query] * Click on "Filter" * Enter {{Q|Q107006}} * Replace "Claudia_Cardinale" by "item" * You could choose another filter property * Now you can add other attributes via "Show" * Execute the query * Format the query by clicking on the diamond * Get the short URL code via Link -> Short URL to query == Wiki projects by Wikimedia Belgium == This is a list of projects organised by Wikimedia Belgium:<syntaxhighlight lang="sparql"> SELECT ?wikiproject ?wikiprojectLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?wikiproject wdt:P31 wd:Q16695773. ?wikiproject wdt:P664 wd:Q18398868. } </syntaxhighlight>See https://w.wiki/$cN It has been created by starting Wikidata Query, then entering the search items "wikiproject" and "WMBE" in the Filter section. ==Missing Labels== With [[Wikidata]] it frequently happens that labels are missing for certain languages. With Wikidata Query and [[d:Help:QuickStatements|QuickStatements]] you can create labels in other languages. This increases knowledge sharing amongst languages. It invites other languages to document "foreign" items. Then descriptions can be added for each of the newly created items. Example: imagine that you want to create missing lables for Belgian persons. *Copy the following text into https://query.wikidata.org <syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?itemDescription WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P27 wd:Q31. SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,de,pt,es,no". } FILTER(NOT EXISTS { ?item rdfs:label ?lang_label. FILTER(LANG(?lang_label) = "nl") }) } ORDER BY ?itemLabel </syntaxhighlight> *Download the results. *Generate a [[d:Help:QuickStatements|QuickStatements]] transaction file, e.g. using Excel *Now you can automatically create labels. Tip: Use the Lxx command ==Missing Descriptions== <syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?sexLabel ?beroepLabel ?domainLabel ?ambtLabel ?itemDescription WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P27 wd:Q31. optional{ ?item wdt:P21 ?sex.} optional{ ?item wdt:P106 ?beroep.} optional{ ?item wdt:P101 ?domain.} optional{ ?item wdt:P39 ?ambt.} SERVICE wikibase:label { bd:serviceParam wikibase:language "nl,fr,en,de,pt,es,no". } FILTER(NOT EXISTS { ?item schema:description ?itemdesc. FILTER(LANG(?itemdesc) = "nl") }) } order by ?itemLabel </syntaxhighlight> Tip: Use the Dxx command === Geographical service === * [[d:Wikidata:Events/Belgium/Wikimedia_Belgium/Erfgoed/Pajottenland-Zennevallei|Geographical queries]] == See also == * [[Wikidata Query logic]] * [[Wikimedia Commons Query]] * [[Federated Query]] == Related tools == * [[ListeriaBot]] * [[Pywikibot]] ==External links== * [[wikipedia:Wikidata|Wikidata]] in Wikipedia * [[wikidata:Wikidata:SPARQL_query_service/A_gentle_introduction_to_the_Wikidata_Query_Service|A gentle introduction to the Wikidata Query Service]] * [[wikidata:Wikidata:SPARQL query service/queries|d:Wikidata:SPARQL query service/queries]] * [[wikidata:Wikidata:SPARQL query service/queries/examples|d:Wikidata:SPARQL query service/queries/examples]] * [[wikidata:Special:PrefixIndex/User:Geertivp/training|d:Special:PrefixIndex/User:Geertivp/training]] [[Category:Wikidata Query]] o1zq8mnmtapt4mnlj9ph6t6obz089ji Wikidata Query logic 0 12561 39058 39024 2026-09-09T10:52:48Z Geertivp 171 subclass queries 39058 wikitext text/x-wiki [[File:Rdf mapping-vector.svg|thumb|600x600px|Wikidata Query logic schema]] The '''Wikidata Query logic''' is based on the ''RDF Dump Format''/''LoD specifications''. It describes the logic of [[SPARQL]] queries, that are built and executed via the [[Wikidata Query]] or related tools. The model describes how the data is structured, and how queries can be constructed. == Query logic choices == === Object versus subject based === You can basically choose between two types of queries, depending on the item values you base your query on: * ''object based queries'' (default), that search subjects having certain statements (this is the Wikidata standard query) * and ''subject based queries'', to search related objects based on a subject item. === With or without qualifiers === You can query with and without qualifiers: * When you want to execute ''straight queries'', without qualifiers, you can use the simple (straight) WDT property type filter. This is the Wikidata standard query. You can find this filter to the left of the schema. * When you want to ''query with qualifiers'', you need to use the P, PS, and PQ property type filters. You can split WDT type filters into a combination of P and PS type queries. Then you go through intermediate WDS statements. Please look at the center of the schema. You can apply PQ qualifiers to get more information, or to add addional filters. Here you have the additional possibility to query for reference and value nodes. == Example queries == === Straight queries without qualifiers === ==== Straight object based query ==== An object based query is searching for all subjects that have a link with the object. It only uses WDT property type filters. This is the standard Wiki Data query type, as automatically built when you start to filter for an item number. List all persons where Guido Gezelle is relevant to them, and have an nlwiki page.<syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item wdt:P3342 wd:Q336977. { ?articleplus schema:about ?item; schema:isPartOf <https://nl.wikipedia.org/>. } } </syntaxhighlight>[https://w.wiki/TbVM Try!] ==== Straight subject based query ==== A subject based query starts from the subject, and ''cascades'' through its data connections. Basically it is the above query where the WDT statement is reversed. List all relevant persons of Guido Gezelle, having an nlwiki page.<syntaxhighlight lang="sparql">SELECT ?item ?itemLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } wd:Q336977 wdt:P3342 ?item { ?articleplus schema:about ?item; schema:isPartOf <https://nl.wikipedia.org/>. } }</syntaxhighlight>[https://w.wiki/TbVP Try!] ==== Query with OR VALUES statement ==== Photographer in Suriname, not Dutch, with or without a photo.<syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?beroepLabel ?workplaceLabel ?image WHERE { VALUES ?workplace { wd:Q7646305 wd:Q3001 wd:Q738313 } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item wdt:P31 wd:Q5; wdt:P106 wd:Q33231, ?beroep; wdt:P937 ?workplace. MINUS { ?item wdt:P27 wd:Q29999. } OPTIONAL { ?item wdt:P18 ?image. } } </syntaxhighlight>[https://w.wiki/U8EW Try!] === Queries with qualifiers === ==== Object based query with qualifiers ==== An object based query is searching for all subject that have a link with the object. List all persons where Guido Gezelle is relevant to them, and have an nlwiki page, with an indication of their role.<syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?roleLabel ?startdt ?enddt WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item p:P3342 ?s. ?s ps:P3342 wd:Q336977. OPTIONAL { ?s pq:P3831 ?role. } OPTIONAL { ?s pq:P580 ?startdt. } OPTIONAL { ?s pq:P582 ?enddt. } { ?articleplus schema:about ?item; schema:isPartOf <https://nl.wikipedia.org/>. } } </syntaxhighlight>[https://w.wiki/TdL7 Run!] ==== Subject based query with qualifiers ==== A subject based query starts from the subject, and ''cascades'' through its data connections. List all relevant persons of Guido Gezelle, having an nlwiki page, with an indication of their role.<syntaxhighlight lang="sparql">SELECT ?item ?itemLabel ?roleLabel ?startdt ?enddt WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } wd:Q336977 p:P3342 ?s. ?s ps:P3342 ?item. OPTIONAL { ?s pq:P3831 ?role. } OPTIONAL { ?s pq:P580 ?startdt. } OPTIONAL { ?s pq:P582 ?enddt. } { ?articleplus schema:about ?item; schema:isPartOf <https://nl.wikipedia.org/>. } }</syntaxhighlight>[https://w.wiki/TdLC Run!] ==== Subject based query with filter on qualifiers ==== List all persons that have started writing to Guido Gezelle in the 5 last years of his life, and have an nlwiki page.<syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?roleLabel ?startdt ?enddt WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } wd:Q336977 p:P3342 ?s. ?s ps:P3342 ?item; pq:P3831 wd:Q3589290, ?role; pq:P580 ?startdt. FILTER(?startdt >= "1894-01-01T00:00:00Z"^^xsd:dateTime) OPTIONAL { ?s pq:P582 ?enddt. } { ?articleplus schema:about ?item; schema:isPartOf <https://nl.wikipedia.org/>. } } ORDER BY (?startdt) </syntaxhighlight>[https://w.wiki/TdM4 Run!] == Queries with subclass == === Heritage register in country === <syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?instanceLabel ?jurisdictie ?jurisdictieLabel ?landLabel WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item (wdt:P31/(wdt:P279*)) wd:Q15097084, ?instance; wdt:P17 wd:Q31, ?land. OPTIONAL { ?item wdt:P1001 ?jurisdictie. } } </syntaxhighlight>[https://w.wiki/UKEH Run!] === Heritage register in jurisdiction === <syntaxhighlight lang="sparql"> SELECT ?item ?itemLabel ?instanceLabel ?jurisdictieLabel ?landLabel WHERE { VALUES ?jurisdictie { wd:Q9337 wd:Q231 wd:Q240 wd:Q89959 } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } ?item (wdt:P31/(wdt:P279*)) wd:Q15097084, ?instance; wdt:P1001 ?jurisdictie. OPTIONAL { ?item wdt:P17 ?land. } } </syntaxhighlight>[https://w.wiki/UKEJ Run!] == See also == * [[mw:Wikibase/Indexing/RDF_Dump_Format|RDF Dump Format]] (RDF/LoD specifications) * [[Federated Query]] * [[Pywikibot SPARQL queries]] * [[Wikimedia Commons Query]] [[Category:Wikidata Query]] qxqqkbubfxbqg3s5awony7gw0qsjiqq