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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
76 views

How to query Wikidata in order to get all the species of flowers?

I’m trying to write a query that retrieves all the species of flowers in Wikidata. As far as I understood, flowers are represented by class Q506: https://www.wikidata.org/wiki/Q506. Therefore I tried ...
  • 11
1 vote
1 answer
33 views

SPARQL on Wikidata: Official languages of a country sorted by commonality

I am trying to get the languages spoken in a Country. The returned results should be returned in order. This order should be either the official ordering of the languages given by the country, if ...
  • 1,899
1 vote
0 answers
33 views

SPARQL: get entity descriptions in different languages from Wikidata

I'm trying to retrieve all labels and descriptions in different languages from a instances of a specific class from Wikidata. I have followed the answer to a similar question (https://stackoverflow....
  • 1,899
0 votes
0 answers
38 views

Wikidata SPARQL Timeout

I'm trying to pull all instances of good and services from Wikidata but I'm getting a time out. Any idea how I could optimize this to be able to pull the full list? I've tried this query but I have no ...
  • 1
0 votes
1 answer
30 views

How to make the value of a claim in wikidata a hyperlink or link to another external page

I am trying to create a script in Wikidata that creates a claim for certain entities. The claim should have a property of "external identifier" and a value that is the identifier generated ...
0 votes
0 answers
32 views

How to get page ID from wiki data API using SPARQL

With the following query I get all the tourist attractions near me with SPARQL using the Wiki Data API. What I can't get to work is: I also need the page ID for each result. The page ID is the unique ...
0 votes
1 answer
28 views

Expand path between subject and object in SPARQL

This SPARQL query returns true: ASK { wd:Q216665 wdt:P279* wd:Q5185279 . } https://w.wiki/6Mi5 Is there any way to expand the path (i.e. wdt:P279*) to better understand the link between subject ...
  • 111
0 votes
1 answer
39 views

How to find for the wikipedia links in the infobox templates and other templates, using sql dumps

I want to extract the pages mentioned in the infobox and templates of pages. E.g. From this page: https://en.wikipedia.org/wiki/DNA I want to extract all of the links in the infobox, like: "...
  • 1,604
0 votes
0 answers
27 views

Wikidata REST API Forbidden using Access Token?

I have this Node.js request: /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as dotenv from 'dotenv' dotenv....
  • 73.9k
0 votes
0 answers
31 views

How to query for specific person on Wikidata using SparQL?

I am making a query which I think would make sense, but it is just hanging, no error: PREFIX schema: <http://schema.org/> SELECT ?item ?itemLabel ?person ?personLabel ?pic ?givenName ?...
  • 73.9k
0 votes
1 answer
82 views

Spacy entity linking: wiki dataset not connected

This relates to the Spacy entity linking library: https://github.com/egerber/spaCy-entity-linker When I use the following code: # python -m spacy_entity_linker "download_knowledge_base" ...
2 votes
1 answer
38 views

Simplify array of objects with children using JQ

From Wikidata, I get the following json: # Sparql query query=$(cat ./myquery.sparql) response=$(curl -G --data-urlencode query="${query}" https://wikidata.org/sparql?format=json) echo "...
  • 17k
1 vote
1 answer
34 views

Plot simple categorical data onto a map in Wikidata

I use the following Wikidat SPARQL query to get a list of places of birth and death of hairdressers (https://w.wiki/6Gsz): #defaultView:Map SELECT ?pers ?pobC ?podC WHERE { ?pers wdt:P106 wd:...
  • 111
1 vote
0 answers
32 views

How to relate p[s[n]] and w[d[t]] properties in wikidata sparql query?

I am trying to get all quantitative values of a given wd:* entry including the statements details (qualifiers?) - foremost the unit, since most numeric values are useless without it. I was able to ...
0 votes
0 answers
29 views

How can I make a query for all existing items and their corresponding discriptions in WikiData?

I want to make a query for all existing items and their descriptions (in English). So it results in two columns: Item Description Q437 capital city of Slovenia Q2539 scientific study of algorithms ...
  • 15
-1 votes
2 answers
71 views

Wikidata query with values from CSV-File

I would like to do a Wikidata query of many values that are listed in a column of a CSV file on my computer. How can I load the values from the CSV file into the Wikidata query automatically without ...
1 vote
0 answers
46 views

Counting items over time using SPARQL

Given a list of items with start and end dates (Nobel Physics prize winners with birth and death in Wikidata, for example), how could I use SPARQL to return a count of the number in existence in every ...
0 votes
1 answer
33 views

Wikidata SPARL query by generic property return object instead of statement

I want to disseminate the query by spreading the nodes like in the below query. SELECT ?item ?itemLabel ?prop ?object ?objectLabel ?prop2 ?object2 WHERE { VALUES (?item) { (wd:Q12418)} ?item ?...
  • 1,155
0 votes
0 answers
51 views

How to search for multiple terms in Wikidata API using 'srsearch' (e.g. from Python)?

I am trying to search multiple terms on Wikidata and then parse the results locally using Python. I am currently looping through a list of terms and running the following piece of code: import ...
2 votes
1 answer
51 views

Unexpected missing value from Wikidata query

I'm using the Wikidata query service to learn the SPARQL query language. I'm trying to get information on countries and their identifying information. Here is a simple query which is intended to ...
4 votes
1 answer
69 views

SPARQL query gives different result as a subquery

When running the following query I get only one result as expected SELECT DISTINCT ?city ?country WHERE { FILTER (?city = wd:Q1748) . # Primary country ?city p:P17 ?c . ?c ps:P17 ?country ; ...
0 votes
1 answer
25 views

Given a list of Wikidata identifiers, is there a way to find which ones are directly related using Python and/or SPARQL?

I have a list of Wikidata IDs and I want to find which of those are subclasses (P279) of others. Let's suppose I have the list in pseudocode ["Q42" (Douglas Adams) , "Q752870" (...
0 votes
0 answers
44 views

Wikidata SPARQL filter properties by id

I have the following sparql: #Cats SELECT ?item ?itemLabel ?prop WHERE { ?item ?prop wd:Q7206. filter not exists {?prop **FILTER** wdt:P921 } SERVICE wikibase:label { bd:serviceParam wikibase:...
  • 1,155
1 vote
1 answer
31 views

SPARQL "any" relationship filter

I want to retrieve entities with any relation to some other entity. Consider following query: SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q28598684. SERVICE wikibase:label { bd:...
  • 1,155
0 votes
1 answer
46 views

Query timeout all living people on WikiData

I have the following query to fetch all living people on wikidata but it's timing out. Any suggestions on how to optimize it or change it to make it run? SELECT ?person ?personLabel WHERE { ?person ...
0 votes
0 answers
65 views

Retrieving all living people from wikipedia/wikidata

I have the following query from the WikiData query builder to fetch people, but I would like to fetch only people who are alive. I've tried playing around with date of death but I can't get anything ...
1 vote
0 answers
45 views

Wikidata COUNT(*) query times out

I have a straightforward query that counts how many humans have an English Wikipedia page. prefix schema: <http://schema.org/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wd: <...
0 votes
0 answers
30 views

SPARQL Distance problem WIKIDATA - problem with distance measuring

I am doing SPARQL exercise right now - I want to find all places that dont have airport in 100km range. Right now I am stuck, cause I wanted to union them to filter data, but that isnt working. Please ...
0 votes
0 answers
69 views

Sparql and Pandas conversion in Wikidata

I have queried Wikidata [https://query.wikidata.org/] via sparqlwrapper in python. It returns as an XML for some reason instead of CSV. Result of query in python I convert it to a Pandas DataFrame in ...
0 votes
0 answers
26 views

Limiting SPARQL result for each group

I have to write a query on wikidat. The question is : Consider only films directed by Woody Allen or Quentin Tarantino. Then consider the date of publication of these films (take the first one if ...
user avatar
-1 votes
1 answer
66 views

Wikipedia metadata dump?

I need metadata for wikipedia articles (title, views, time edited, categories, etc.). I was looking through the dumps at https://dumps.wikimedia.org/enwiki/20221201/ and there's so many that I'm not ...
  • 663
0 votes
0 answers
43 views

`wd:Q887 wdt:P31 ?x` does not list that Yekaterinburg is a "big city". Why? [duplicate]

On the entity page it's listed that it's a "city or town" as well as "big city". And if I query "What is Yekaterinburg?" via statement and specification I see that among ...
  • 3,018
0 votes
1 answer
37 views

HTTP response code: 400 querying wikidata

I am running this in a jupyter notebook. I am trying to enrich a neo4j graph querying wikidata. import pandas as pd import wikipedia from neo4j import GraphDatabase host = 'bolt://address:port' user =...
  • 650
1 vote
0 answers
31 views

SPARQL hanging when asked about two values

When I try to query what geographical areas two cities belong Wikidata SparQL query hangs. It works fine for each of the cites. Any ideas what's going on and whether a workaround is needed? # This ...
  • 3,018
0 votes
1 answer
27 views

Wikidata SPARQL query: how to get values of the property 'applies to part' (P518)

on the page describing Hurricane Ian on wikidata Ian wikidata, we can consult which parts of countries were concerned by the event (Florida, Georgia, etc.) I'm trying to write a query to get these ...
  • 35
1 vote
1 answer
30 views

SPARQL fetch French communes allongside their departement and region from wikidata

I'm trying to fetch French communes from Wikidata using SPARQL. I want to also retrieve the departement code and the region code of the commune. For now I have this query : SELECT ?inseeCode ?commune ?...
0 votes
0 answers
47 views

SPARQL recursive queries task

I found a SPARQL task that I can't finish. I am a beginner at SPARQL so I would be glad for some help. The endpoint is https://query.wikidata.org/. Write a SELECT query: Find all ingredients (parts, ...
1 vote
1 answer
35 views

How can I pull the Wikidata description?

I'm trying to pull the wikidata description of biblical figures. For example, for David, this would pull: king of Israel and Judah. Here's what I started with: select ?person ?personLabel where { ?...
0 votes
1 answer
47 views

How can I group multiple results into one cell with SPARQL in Wikidata

I'm trying to pull (lots of) data for one of my projects. Specifically trying to get some data on biblical figures. However, I've noticed that when there are mutiple results per column, I get the ...
1 vote
1 answer
42 views

SPARQL - Filter results for which objects explicitly match pattern

For a given SPARQL query I wonder how to explicitly match objects to a pattern i.e. it should have a set of given property values and only those values. Consider the following query: ` SELECT DISTINCT ...
2 votes
1 answer
53 views

How to convert the name of a historical time period in to a year/date in SPARQL?

I am a beginner to SPARQL and I managed to implement a query that returns the historical time period (P2348) for when an item was created, examples of this are 'Bronze age', 'Mesolithic', 'Nguyen ...
  • 53
1 vote
0 answers
43 views

Neo4j Desktop neosemantics RPC failure invoking rdf.preview.fetch - NoSuchMethodError JacksonFeatureSet JSONParser getReadCapabilities

I'm attempting to extract RDF from Wikidata into a Neo4j graph through the Neo4j Desktop with APOC and Neosemantics plugins on a Mac and keep getting Neo.ClientError.Procedure.ProcedureCallFailed ` ...
0 votes
0 answers
18 views

Run a wikidata dump

With the following code I try to retrieve a wikidata dump: #!/usr/bin/env bash # this is a bash script to bootstart the project including downloading of datasets - setup of additional tools. # pass a ...
0 votes
1 answer
98 views

Random indexing of large Json file compressed as Gzip

I have a large json file (Wikidata dump, to be more specific) compressed as gzip. What I want to achieve is build an index, such that I can do random access and retrieve the line/entity I desire. The ...
  • 5,285
1 vote
1 answer
29 views

unnest queries in Wikidata with SPARQL

I am trying to get a table from Wikidata with businesses, their twitter handle and the country of the business. I am running the following query on https://query.wikidata.org/ SELECT * WHERE { # ...
  • 906
0 votes
1 answer
29 views

Wikidata Query: Find American authors of children’s fiction

I want to find all children's fiction writers using Wikidata SPARQL query. But I couldn't figure out how? Can someone help, please? The following is my approach but I don't think it is the correct way....
  • 15
0 votes
0 answers
43 views

extracting covid-19 pandemic most recent data per country using a Wikidata SPARQL query

I'm trying to extract some of the most recents data about covid-19 pandemic statistics (number of cases, recoveries, point in time) per country from Wikidata using this SPARQL query: SELECT DISTINCT ?...
1 vote
1 answer
26 views

Why is the label not getting displayed in this SPARQL query?

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX bd: <http://www.bigdata.com/rdf#> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/...
1 vote
1 answer
33 views

Is it possible to formulate an OPTIONAL "subquery" so that it returns at most one record

The following Wikidata query returns a list of airports and their IATA codes. I am using ?airport rdfs:label ?airportName to also get a label for the airports. Most airports have labels in multiple ...
1 vote
1 answer
45 views

SPARQL limit result of only one variable

I am trying to query wikidata to retrieve artworks, their material characteristics and the artistic movement they are associated with. Each resulting record can have a number of movements/materials ...
  • 195

1
2 3 4 5
18