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
4
votes
1 answer

How to retrieve Wikidata entry from Wikidata search results?

I make a Wikidata search request like this (autocomplete use case): https://www.wikidata.org/w/api.php?action=wbsearchentities&format=json&language=en&type=item&continue=0&search=photog And the service returns a JSON response thus { id:…
metalaureate
  • 7,572
  • 9
  • 54
  • 93
4
votes
1 answer

How can I harnest Wikidata to build a Siri-like service?

I'd like to discuss the first part of this Siri-like service. Ideally, I'd like to be able to query for things like: "the social network" "beethoven" "bad blood taylor swift" And get results like…
Vulkan
  • 1,004
  • 16
  • 44
4
votes
2 answers

Extracting Entity-Verb relations from open knowledge bases like Freebase and DBPedia

Is there any way that we can extract entity-verb relations from already existing online KBs like Freebase, DBPedia, Wikidata or Wordnet, I checked and only found that these sources concentrate on entities. My aim is to derive relations like "A…
4
votes
2 answers

Access JSON item with variable key name

The following is my JSON data which happens to be the format supplied by Wikidata, although greatly trimmed down for clarity. { "entities": { "Q200405": { "id": "Q200405", "type": "item", "claims": "Cheese" } …
MortimerCat
  • 829
  • 9
  • 26
3
votes
0 answers

How to extract triples from a sentence, and the triples should be existant in Wikidata

I have a sentence, and I want to use some tools to automatically extract a triple (triples) from the sentence. The triple(s) should be already existant in Wikidata. Is there any tool from Wikidata that can automatically do this, better in a Python…
3
votes
1 answer

How to get list of entities in python wikidata

I need to get all the info about some writers in wikidata For example - https://www.wikidata.org/wiki/Q39829 My code from wikidata.client import Client client = Client() entity = client.get('Q39829', load=True) # Spouse spouse_prop =…
TiBrains
  • 105
  • 8
3
votes
1 answer

How can I optimize my recursive SPARQL query?

I'm trying to extract buildings from Wikidata using a recursive SPARQL query but I keep getting query timeouts. Is there a way to circumvent this? This is my current query, selecting all buildings with either a Freebase ID or a Google Knowledge…
Latitia
  • 31
  • 1
3
votes
0 answers

Is there a way to return only the known precision of a date in Wikidata?

When querying p569 (date of birth) or a similar property, it returns dates as full month-day-year time strings, even if the statement only contains the year. If the statement only contains the year it assigns January 1st as the date. Is there a way…
jmwink
  • 35
  • 3
3
votes
1 answer

How to query Wikidata using SPARQL using entity names and also check alternative labels?

I'm trying to query Wikidata using entity names. My goal is to get the Wikidata ID of the entity. Right now I have something like: SELECT ?item WHERE { ?item rdfs:label "name_of_thing"@en } and while this usually gets the job done I also want…
Sean
  • 2,890
  • 8
  • 36
  • 78
3
votes
1 answer

Retrieve Wikidata ID candidates based on a partial name match

I have some entities in a specific language and I am trying to retrieve the possible IDs from Wikidata that match those names. For example, I have some German name, let's say "Ministerium für Auswärtige Angelegenheiten" and I can get the top N…
Porjaz
  • 771
  • 1
  • 8
  • 28
3
votes
1 answer

Wikidata - get labels for a large number of ids

I have a list of around 300.000 wikidata ids (e.g. Q1347065, Q731635 etc.) in an ndjson file as {"Q1347065": ""} {"Q731635": ""} {"Q191789": ""} ... etc What I would like is to get the label of each id, and form a dictionary of key values, such…
Paschalis
  • 191
  • 10
3
votes
2 answers

How to get *all* superclasses of a Wikidata entity with SPARQL?

I am interested in visualizing the Wikidata class hierarchy to create graphs like I know how I can get direct superclasses of a Wikidata entity. For this I use SPARQL code like: SELECT ?item ?itemLabel WHERE { wd:Q125977 wdt:P279 ?item. …
cknoll
  • 2,130
  • 4
  • 18
  • 34
3
votes
2 answers

Wikidata query to get country synonyms but not flag symbols

I am using the following query to get a list of ISO countries with their details: SELECT ?country ?countryLabel ?code  ?wikipedia ?countryAltLabel WHERE {   ?country wdt:P297 ?code .   OPTIONAL {                         ?wikipedia schema:about…
Rachel Watson
  • 212
  • 2
  • 9
3
votes
2 answers

How to use Wikidata API to get ISO 3166-1 country codes?

I have been looking for examples online but can't find any for getting ISO 3166-1 country codes using the Wikidata API. It's mentioned here that one can do https://query.wikidata.org/sparql or https://query.wikidata.org/bigdata/ldf, but I don't…
Raj
  • 1,555
  • 18
  • 32
3
votes
1 answer

Wikidata Forbidden Access

I was trying to run some wikidata queries with Python requests and multiprocessing (number_workers = 8) and now I'm getting code 403 (Access Forbiden). Are there any restrictions? I've seen here that I should limit myself to 5 concurrent queries,…