Jump to content

Wikidata Query

From Wikimedia Belgium

Wikidata Query allows you to search in the Wikidata database. It is using 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:

Functionality

[edit]
  • 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

[edit]
  • Go to Classic Wikidata Query
  • Click on "Filter"
  • Enter (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

[edit]

This is a list of projects organised by Wikimedia Belgium:

SELECT ?wikiproject ?wikiprojectLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?wikiproject wdt:P31 wd:Q16695773.
  ?wikiproject wdt:P664 wd:Q18398868.
}

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

[edit]

With Wikidata it frequently happens that labels are missing for certain languages.

With Wikidata Query and 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.

 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
  • Download the results.
  • Generate a QuickStatements transaction file, e.g. using Excel
  • Now you can automatically create labels.

Tip: Use the Lxx command

Missing Descriptions

[edit]
 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

Tip: Use the Dxx command

Geographical service

[edit]
[edit]
[edit]