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

Get a clean extract from Wikipedia page

I am currently exploring the Wikipedia API and am trying to understand it a bit more. So I am starting with a Wikidata ID and can find my Wikipedia Title there. I extract the title and am then able to query Wikipedia like e.g.…
Georg
  • 3,664
  • 3
  • 34
  • 75
0
votes
1 answer

SPARQL query that returns Wikidpedia labels from Wikidata itemLabel

I am new to SPARQL, Is it possible to write a query that returns Wikipedia box information for a corresponding item label from the Wikipedia box for the Arabic Language that appears at the bottom of the Wikidata item page? see the picture: Instead…
Mai
  • 121
  • 1
  • 10
0
votes
0 answers

Remote SPARQL query in C/C++

I need to process responses of RDF graphs querying with SPARQL, using C/C++ code. I'm trying to query Wikidata endpoint with SPARQL, using the Rasqal library, but it doesn't work (HTTP 403 problem). The problem (probably) is in the cURL…
0
votes
1 answer

Python Library to retrieve Wikipedia page summary from URL

From a previous question on the StackOverflow How to get Wikipedia page from Wikidata Id?, The following answer helped me retrieve the Wikipedia URL for a corresponding Wikidata Identifier def get_wikipedia_url_from_wikidata_id(wikidata_id,…
Mai
  • 121
  • 1
  • 10
0
votes
0 answers

Wikidata SPARQL property values order

I found that Wikidata API returns the data with some relevance order. For example look at the occupationvalues of https://www.wikidata.org/wiki/Q22686 and compare with occupation values list from here: VALUES (?company) {(wd:Q22686)} ?company ?p…
Nox
  • 191
  • 1
  • 11
0
votes
0 answers

How can I use SPARQL regex to parse Wikitext and extract values from parameters in a Wikimedia Commons template?

This query against the Wikidata SPARQL endpoint returns the Wikitext content of the first 50 files in the Wikimedia Commons category "1930s photographs in Auckland Museum". For each file, I want to extract several pieces of data from that…
Hugh
  • 73
  • 6
0
votes
1 answer

Can I use generators in WikiData's API?

I am trying to get all of the pages in given category from wikipedia, including ones in subcategories. No problem with that, but I also want certain fields from each page, like birth date. From this topic I suppose I need to use…
adamgorszy
  • 15
  • 2
0
votes
1 answer

Wikidata getting properties of linked item?

I currently have this query that will grab the description and place of death of J.R.R. Tolkien, but I would like to display the city and country of the place of birth. Currently I get a reference to another wikidata item. How can I resolve…
zkwsk
  • 1,960
  • 4
  • 26
  • 34
0
votes
1 answer

Wikidata Returning Multiple Results For Id

I am trying to get the label of a wikidata item using its id. My sparql looks like: SELECT ?label WHERE { wd:Q245068 rdfs:label ?label . FILTER (langMatches( lang(?label), "EN" ) ) } When I run this, I get 3 results that are all…
micah
  • 7,596
  • 10
  • 49
  • 90
0
votes
1 answer

How to get the values of the P642 of-predicate applied to a previous statement in a SPARQL query for Wikidata?

I would like to get the provincial or territorial capital city in Canada with the names of the provinces. SELECT ?item ?itemLabel ?provinceOrTerritoryLabel WHERE { ?item wdt:P31 wd:Q21507383. # provincial or territorial capital city…
0
votes
0 answers

How to reverse the order of concatenated values in a SPARQL query of Wikidata?

I would like to get cities in Canada with a location concatenation as cross-feature that is sortable. This works : SELECT (GROUP_CONCAT(?locationLabel; separator = ' < ') as ?locationLabels) ?city ?cityLabel #?locationLabel WHERE { ?city wdt:P17…
0
votes
1 answer

How do I create a Wikidata SPARQL query to return the top 10 US companies and their directors based on revenue?

Here is the query I am working with: SELECT DISTINCT ?item ?itemLabel ?rev ?date (group_concat(distinct ?directorLabel ; separator = ", ") as ?directors) WHERE { ?item wdt:P31/wdt:P279* wd:Q4830453 ; wdt:P17 wd:Q30 . ?item p:P2139…
Korimako
  • 359
  • 3
  • 13
0
votes
0 answers

Get the qid for a value

I'm using the following query to get all claims/statements for an item, like for instance for the band Build To Spill. https://w.wiki/3n3H Some of the values, like Boise, indie rock, etc. , are items by themselves. How can I display their QID if…
chhenning
  • 2,017
  • 3
  • 26
  • 44
0
votes
1 answer

How do you query for current board members of a business using SPARQL on Wikidata?

Here is the base query which returns all directors, including those who are no longer members of the board. I don't know how to access the start or end date of their membership, because the first line of the where statement returns a person entity,…
Korimako
  • 359
  • 3
  • 13
0
votes
1 answer

Wikidata SPARQL filter field values by language

So I have this SparQL query that gets the information of the United States dollar SELECT ?currency ?page_title ?currencyLabel ?currencyIso4217 (GROUP_CONCAT(distinct ?shortName; separator = ', ') as ?shortNames) { ?currency…
NLAnaconda
  • 1,534
  • 3
  • 14
  • 38