32 votes

Get Wikipedia URLs (sitelinks) in Wikidata SPARQL query

On 18. April 2016 the ticket "More efficient SPARQL queries for sitelinks" brought us a better way: schema:isPartOf. ?sitelink schema:about ?item . ?sitelink schema:inLanguage "en" . ?sitelink ...
robbi5's user avatar
  • 421
17 votes
Accepted

Get Wikipedia URLs (sitelinks) in Wikidata SPARQL query

Try this one: prefix schema: <http://schema.org/> PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/...
StasM's user avatar
  • 443
15 votes
Accepted

Querying Wikidata : WDQ vs. WDQS / SPARQL

I'm the developer of WDQ. It was developed as a stop-gap measure, until Wikidata would get its own query service. That took some years, but now we have SPARQL and https://query.wikidata.org/ so I plan ...
Magnus Manske's user avatar
15 votes
Accepted

How to include sub-classes in a Wikidata SPARQL query? (example: when querying "bands", include "rock bands")

The right expression to use here is p:P31/ps:P31/wdt:P279*. Explanation: p:P31/ps:P31 means instance of, or instance of not marked as preferred. Only using p:P31 at this step would miss some ...
Nicolas Raoul's user avatar
  • 8,386
11 votes
Accepted

Is Wikidata up to date with Wikipedia?

The dependency is supposed to be the opposite, i.e. that Wikipedia should rely on data in Wikidata. This is however not fully implemented yet. If you look at the infobox on this cheese in French, all ...
Ainali's user avatar
  • 436
7 votes

How to get the name of a Wikidata item

You can get it also using SPARQL: SELECT DISTINCT * WHERE { wd:Q19675 rdfs:label ?label . FILTER (langMatches( lang(?label), "ES" ) ) } See it on Wikidata Query Service.
Alexan's user avatar
  • 442
7 votes

Mapping all Wikipedia URLs to Wikidata entity ids

You can also use the SPARQL service with query like: prefix schema: <http://schema.org/> SELECT * WHERE { <https://en.wikipedia.org/wiki/Tom_Hanks> schema:about ?item . }
StasM's user avatar
  • 443
7 votes
Accepted

Wikidata get property of property

The point in time property of the award received is what Wikidata calls a qualifier: Along with sources and ranks, qualifiers allow statements to be expanded on, annotated, or contextualized beyond ...
Patrick Hoefler's user avatar
6 votes

How to get list of all items that have a particular property, in Wikidata?

You can do it by using MediaWiki API for Wikidata with backlinks query https://www.wikidata.org/w/api.php?action=query&list=backlinks&blnamespace=0&bllimit=500&&bltitle=Property:...
Termininja's user avatar
6 votes
Accepted

Get QID from Wikidata label name, via SPARQL

Yes, you can, but it isn't short: SELECT distinct ?item ?itemLabel ?itemDescription WHERE{ ?item ?label "Mozambique"@en. ?item wdt:P31 wd:Q6256 . ?article schema:about ?item . ?article ...
Alexan's user avatar
  • 442
6 votes

Retrieve periodic table information from wikidata

I think this is close to what you want but there doesn't seem to be a property for group or period as a number. SELECT ?element ?elementLabel ?symbol ?protons ?group ?groupLabel ?period ?periodLabel ...
chrisis's user avatar
  • 388
6 votes
Accepted

Wikidata: How to represent British Hong Kong's under Japanese occupation?

As far as I know, there are no methodological guidelines for how to model those things on Wikidata. Rerardless Wikidata, modelling of such geopolitical endurants/perdurants/aggregates might be fairly ...
Stanislav Kralin's user avatar
5 votes
Accepted

Extract labels from Wikidata entity

You could do it with SPARQL: SELECT ?wdLabel ?ooLabel WHERE { VALUES (?s) {(wd:Q42)} ?s ?wdt ?o . ?wd wikibase:directClaim ?wdt . ?wd rdfs:label ?wdLabel . OPTIONAL { ?o rdfs:label ?...
Stanislav Kralin's user avatar
5 votes
Accepted

How to output the description of Wikidata items using SPARQL?

I am far from expert in this, but your question motivated me to learn a little, and I have a solution, below. In short, there is a "label service" which can be added to the WHERE clause. By simply ...
Joe Germuska's user avatar
  • 5,488
5 votes
Accepted

Wikidata Query Service reliability

The reason is an error in loading data. It was a temporary problem, now fixed. The information about future plans and work on WDQS can be found on Wikimedia Discovery team page and Phabricator board....
StasM's user avatar
  • 443
5 votes
Accepted

Wikidata SPARQL, why an intermediate item is needed in this sample query?

In the original query ?property and ?p are distinct values: ?property is wd:P54 (short for <http://www.wikidata.org/entity/P54>) and ?p is wdt:P54 (short for <http://www.wikidata.org/prop/...
svick's user avatar
  • 859
5 votes

Querying Wikidata : WDQ vs. WDQS / SPARQL

As Magnus Manske points out, SPARQL is the preferred way since, I would add, SPARQL is standardized BUT, here is the downside: The SPARQL endpoint, at this point in time, is NOT as reliable as WDQ ...
David Sánchez Martín's user avatar
5 votes

Querying Wikidata : WDQ vs. WDQS / SPARQL

You can abbreviate SPARQL by expanding a given query fragment with default namespace definitions and other options. For instance the wikidata query command line client expands wdq -tplanet '?planet ...
Jakob's user avatar
  • 195
5 votes

Is Wikidata up to date with Wikipedia?

Wikidata doesn't automatically use data from Wikipedia. Data from Wikipedia is uploaded to Wikidata by hand or using some more or less automated tools to do batch uploads but ultimately under control ...
Pere's user avatar
  • 381
5 votes

wikidata extract

Try Tabernacle. Seems to be exactly what you search. The downloaded resultset is in TSV format, and can be imported in Excel. You'll need to have a Wikimedia account to work with Tabernacle and some ...
XXN's user avatar
  • 51
4 votes

How to add a claim to an existing Wikidata item, from command line?

You can use wikidata-agent for that: curl -XPOST http://your.wikidata.agent.instance/claim -d 'entity=Q5369879&property=P137&value=Q39' [Update]: you can now actually add claims using ...
maxlath's user avatar
  • 266
4 votes

How to output the description of Wikidata items using SPARQL?

Include SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } inside your WHERE clause Append the magic string Label and Description to the variable names of your SELECT For instance, if ...
Nicolas Raoul's user avatar
  • 8,386
4 votes
Accepted

Wikidata label language: How to fallback to ANY language?

As optional get the label in English and in any language, then coalesce: SELECT ?item (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label) WHERE { ?item wdt:P31 wd:Q22674925 . OPTIONAL {?item ...
Nicolas Raoul's user avatar
  • 8,386
4 votes
Accepted

Constructing a WordNet-like tree from the Wikidata dataset?

I would say that the P279-property (subclass of) will span a semantic "tree" (it is not necessarily a tree but a directed graph). You might be able to build semantic trees from other Wikidata ...
Finn Årup Nielsen's user avatar
4 votes

Publishing (structured?) data about products: information about products, barcodes, photos (incl. packaging)

As you can see in Wikimedia Commons, packages usually involve some copyrighted content and therefore its image can't be published under a free license. It can only be published with permission of ...
Pere's user avatar
  • 381
4 votes
Accepted

Retrieve periodic table information from wikidata

Using the series ordinal added to the chemical groups, I can extract the group and period numbers with this query. SELECT ?element ?symbol ?protons ?group ?groupNumber ?period ?periodNumber WHERE { ...
Ben's user avatar
  • 201
4 votes
Accepted

get item's properties know QID

I asked similar question on SO and got 2 answers. first answer: Using the URI instead of the variable ?item will get the information based on the entity Albert Einstein: PREFIX schema: <...
Alexan's user avatar
  • 442
4 votes
Accepted

Weird results in search from wikidata

...like if I made the filter of my 50 previous results... Wikibase:mwapi supports the limit parameter of the Entity Search service: SELECT ?item ?label ?order WHERE { VALUES (?type ?name) {(wd:Q5 "...
Stanislav Kralin's user avatar
4 votes
Accepted

Search in wikidata with specific Q code

In short, URIs are "things, not strings". The filtering condition should be: ?item = <http://www.wikidata.org/entity/Q6015113>, or ?item = wd:Q6015113, or ?item = URI("http://www.wikidata.org/...
Stanislav Kralin's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible