Questions tagged [wikidata]

Wikidata is a free, collaborative, multilingual database, collecting structured data to provide support for Wikipedia, Wikimedia Commons, and the other wikis of the Wikimedia movement. One can retrieve all data using Wikidata Query Service (Wikidata SPARQL endpoint) or Wikidata API (Wikidata MediaWiki API extension). If you are completely new both to SPARQL and MediaWiki API, please consider to ask your question on opendata.stackexchange.com.

Wikidata is a free, collaboratively edited knowledge base operated by the Wikimedia Foundation. It is intended to provide a common source of certain data types (for example, birth dates) which can be used by Wikimedia projects such as Wikipedia. This is similar to the way Wikimedia Commons provides storage for media files and access to those files for all Wikimedia projects.

Concepts:

Wikidata is a document-oriented database, focused around items. Each item represents a topic (or an administrative page used to maintain Wikipedia) and is identified by a unique number, prefixed with the letter Q — for example, the item for the topic Politics is Q7163. This enables the basic information required to identify the topic the item covers to be translated without favouring any one language.

Information is added to items by creating statements. Statements take the form of key-value pairs, with each statement consisting of a property (the key) and a value linked to the property.

Wikidata statement

Further reference:

887 questions
0
votes
1 answer

Fail to retrieve a wikidata item through SPARQL

I tried to search and get the ID of a item with a certain label: Teodor Bogdanov. I can search this name successfully through wikidata website. However, I failed to do so by searching through SPARQL. The code is here. I also copied it here: SELECT…
0
votes
0 answers

WikiData SPARQL query gives different numbers with and without labels

I am trying to download from Wikidata the journals with their OpenAlex id. This query tells me that there are about 85k SELECT (COUNT (?entity) as ?entries) WHERE { ?entity wdt:P31/wdt:P279? wd:Q737498. ?entity wdt:P10283 ?xopenalex_id…
user1043144
  • 2,680
  • 5
  • 29
  • 45
0
votes
0 answers

Limiting diversity of attributes in Wikidata / SPARQL Query

I want to create a dataset of 100 paintings querying from Wikidata. With my current query, for each painting I retrieve the artist (creator), the movement, the year it was painted (inception) and so on. I would like to fix a limit to the number of…
tim_76
  • 74
  • 6
0
votes
0 answers

Retrieve Wikidata Item Wiki url with SPARQL

I'm using this approach to retrieve the Wikipedia url for a Wikidata item for multiple languages, using Sparql: SELECT ?item ?en ?url_en ?es WHERE { { ?item wdt:P31 wd:Q6256. } UNION { ?item wdt:P31 wd:Q1250464. } UNION { ?item wdt:P31…
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
0
votes
0 answers

SPARQL Wikidata Query to retrieve url for multiple languages

I wrote this Sparql query to retrieve item labels in multiple language SELECT ?item ?en ?es ?it WHERE { { ?item wdt:P31 wd:Q6256. } UNION { ?item wdt:P31 wd:Q1250464. } UNION { ?item wdt:P31 wd:Q3624078. } UNION { ?item wdt:P31…
loretoparisi
  • 15,724
  • 11
  • 102
  • 146
0
votes
1 answer

How to pass python variable to sparql query?

I would expect/hope something like this works: import requests my_variable = 'wd:Q1968435' url = 'https://query.wikidata.org/sparql' query = """ SELECT ?item ?itemLabel WHERE { ?item wdt:P31 "+my_variable+". …
0
votes
1 answer

Get Wikidata sitelinks counts for all items with at least one sitelink

Is there a simple way to get the sitelinks count data for all Wikidata items? I want to use the data to help rank possible text entity links to Wikidata items I'm really only interested in counts for items that have at least one (e.g.,…
Tim Finin
  • 19
  • 3
0
votes
1 answer

How to create a SPARQL query to search Wikidata item descriptions

I'd like to be able to find an item based on words in its descriptions. This is what I'm trying to do, but clearly I don't know what I'm doing. Any help is appreciated. SELECT ?item ?itemLabel WHERE { ?item schema:description ?desc. …
Andrew Mayne
  • 1
  • 1
  • 4
0
votes
1 answer

How to use a variable as a property ID in a Wikidata SPARQL query

This query can return both the ID (?ID) for the property and the item ID, but I can't seem to get it to use the property ID (?ID) in a triplet. SPARQL is a dark art to me. Thank you for your help. SELECT ?item ?itemLabel ?superpower ?property…
Andrew Mayne
  • 1
  • 1
  • 4
0
votes
0 answers

SPARQL and counting items

I'm using SPARQL and Wikidata query service to try and determine: The actors that got the Oscar award sorted by the total number of (any) awards they received in decreasing order with the list of all their awards. So far this is what I have that…
0
votes
0 answers

Return "instances of" property for a wikidata item using SPARQL

I have a list of wikidata items I wish to extract the "instance of" property from. For example, looking up Q1339 I can see that it has a single instance type (P:31) labelled "human" (Q5). I have tried to write a simple query that would extract that…
cookie1986
  • 865
  • 12
  • 27
0
votes
0 answers

How to get all lables with language subtags?

For example, if I ask for cities with Chinese labels with SELECT (COUNT (?label) as ?labels) { ?item wdt:P31 wd:Q515 ; rdfs:label ?label . #FILTER (LANG(?label) = "zh") FILTER LANGMATCHES(LANG(?label), "zh") } I'll get over…
Ivo Velitchkov
  • 2,361
  • 11
  • 21
0
votes
0 answers

How to retrieve only actual values

I have a SPARQL query where I try to retrieve all current german municipalities from wikidata, with some of their properties. For example I try to retrieve their postal codes and parent regions: SELECT DISTINCT ?region ?regionLabel ?postalCode…
Tobias Liefke
  • 8,637
  • 2
  • 41
  • 58
0
votes
0 answers

Retrieving Multiple Property Rows + Labels from Wikidata

I'm trying to get a list of all of the landmark buildings in NYC / Manhattan. The problem I'm getting is when the building has multiple owners - my query only returns the name of one of the owners, and I need them all. Example is the Chrysler…
John
  • 1,167
  • 1
  • 16
  • 33
0
votes
1 answer

Get `one_of` specific items in SPAQRL

I use Wikidata as example. The following works (test it): SELECT ?name ?nameLabel WHERE { wd:Q1339 wdt:P735 ?name. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } } Now, suppose I have several items, e.g.…
cknoll
  • 2,130
  • 4
  • 18
  • 34