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
0 answers

optimise Wikidata SPARQL query

I have a Wikidata query that times out, and I think it could be optimised. I trie to include a "Hint" but it seems I don't include it properly because it does not improve the time (but it should!) EDIT: What follows is valid but I realised the line…
kaleidoscop
  • 113
  • 5
0
votes
1 answer

simple SPARQL with OR operator

I am trying to learn SPARQL to use with WikiData and I can't figure out how to perform an 'OR' statement, for instance find all taxons which are a subclasses of mammals OR a subclass of a subclass of mammals. I don't see how to use the VALUES method…
kaleidoscop
  • 113
  • 5
0
votes
0 answers

How to arbitrarily group values in SPARQL (Wikidata)?

I query occupations in Wikidata OPTIONAL { ?item wdt:P106 ?occupation }. No problem in grouping those by label ?occupation rdfs:label ?occupationLabel FILTER((LANG(?occupationLabel)) = "en") . So far, so good. But now I want to further group certain…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
0
votes
0 answers

Filter data with subquery in SPARQL

I'm trying to get some data from Wikidata. I've got a simple query which fetches information about universities: SELECT ?item ?itemLabel ?site WHERE { ?item (p:P31/ps:P31/(wdt:P279*)) wd:Q38723; wdt:P17 ?country; wdt:P856 ?site. SERVICE…
keddad
  • 1,398
  • 3
  • 14
  • 35
0
votes
0 answers

SPARQL: Get all entities from a P279+ query

Example: Q11862829 is subclass of Q1047113, which is subclass of Q9081. Can I build a query that returns all entities of which Q11862829 is subclass of between it and Q9081? wd:Q11862829 wdt:P279+ wd:Q9081 is "close to what I want.
AtilioA
  • 419
  • 2
  • 6
  • 19
0
votes
1 answer

Get information from Wikidata

I have this Wikidata query that returns all the football stadiums with the names, coordinates, club labels and stuff like this. But I cannot figure out how to also get the country and city names where stadiums are located (and possibly the…
user2360545
  • 131
  • 1
  • 2
  • 12
0
votes
0 answers

Wikidata mwapi Search multiple terms at the same time

is it possible to search multiple term at the same time ? Using the OR operator, such as if I want to search Chicago OR New York City, in media wiki api at https://query.wikidata.org/ Below is example of search just Chicago, also how to search exact…
William
  • 5,526
  • 6
  • 20
  • 42
0
votes
1 answer

How to retrive full Wikidata info of an entity

I'm using different kind of queries to retrive wikidata info of an entity like, for Berlin: https://www.wikidata.org/wiki/Special:EntityData/Q64.json https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q64&format=json but all of these did…
Luca
  • 848
  • 1
  • 14
  • 33
0
votes
0 answers

SPARQL Wikidata request string content for getting all the organizations in which a human person is member of?

Another title could be: Is there an inverse of "member of"? I don't see anything like that. I can get all the person who are member of an organization. SELECT ?p ?pLabel WHERE { ?p wdt:P463 wd:Q3227220. SERVICE wikibase:label { bd:serviceParam…
KBill
  • 166
  • 1
  • 12
0
votes
0 answers

What is the meaning or interpretation of a Wikidata JSON "item"?

I just downloaded the Wikidata JSON dump and parsed out a snippet of JSON: https://gist.github.com/lancejpollard/365ef405f1873fcf092c16db6cfcb446 Just one entity is 50,000 lines of JSON, the whole file is 80GB compressed, too large to fit in…
Lance
  • 75,200
  • 93
  • 289
  • 503
0
votes
0 answers

Query for EU universities from Wikidata times out

Asking the Wikidata service for all universities works. But when restricted to only EU universities, this query times out. WHERE { ?item wdt:P31/wdt:P279* wd:Q3918 ; wdt:P17 ?country. ?country wdt:P463 wd:Q458 . SERVICE wikibase:label…
Ivo Velitchkov
  • 2,361
  • 11
  • 21
0
votes
0 answers

Supposedly correct SPARQL query (Wikidata) not yielding any results in Python

Edit: When I use... print("Result", result) ...I get this output: Result ...but I do not know if that just means the format is wrong somehow. Edit 2: Following another request on wikidata, and…
0
votes
1 answer

Overcoming single value constraing issues with P625 coordinate location in Wikidata

I am trying to get a city list together with region and country information with a query like this: # get a list of cities # for geograpy3 library # see https://github.com/somnathrakshit/geograpy3/issues/15 PREFIX rdfs:…
Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
0
votes
2 answers

Wikidata sparql get related actors

I was attempting to write a query to get, given an actor, the actors that were cast members in the same movies (s)he played in. The following query gives me the movies the actor played in. SELECT distinct ?actorLabel ?movieLabel ?boxOffice WHERE { …
Enermis
  • 679
  • 1
  • 5
  • 16
0
votes
1 answer

Can't query local Wikidata dump

I'm trying to run the "Cats" Wikidata query locally against a 2016 Wikidata dump (.ttl format): PREFIX bd: PREFIX wd: PREFIX wdt: SELECT…
AtilioA
  • 419
  • 2
  • 6
  • 19