Reputation: 1473
I'm collecting data about some films in Russian and, using Wikipedia API, I can query data about required film in JSON format:
https://ru.wikipedia.org/w/api.php?format=json&action=query&prop=revisions&rvprop=content&titles=%s
where %s
is a title of article.
One of required properties - IMDb ID. The problem here is that not all articles contain it in wiki markup (actually in film template), but rendered page always.
Russian version of film template says that IMDb ID is automatically taken from Wikidata (English version says about refusing any database in this infobox at all in favor of links section at the bottom).
Is there a way to request IMDb ID using Wikipedia API or Wikidata API?
Upvotes: 4
Views: 2541
Reputation: 7036
You can get all Wikidata film items that have IMDb ID and link to ruwiki by Wikidata Query Service:
SELECT ?item ?IMDb_ID ?sitelink WHERE {
?item wdt:P31 wd:Q11424 .
?item wdt:P345 ?IMDb_ID .
?sitelink schema:about ?item ; schema:isPartOf <https://ru.wikipedia.org/> .
}
or
https://query.wikidata.org/bigdata/namespace/wdq/sparql?format=json&query=SELECT+?item+?IMDb_ID+?sitelink+WHERE+{?item+wdt:P31+wd:Q11424+.?item+wdt:P345+?IMDb_ID+.?sitelink+schema:about+?item+;+schema:isPartOf+%3Chttps://ru.wikipedia.org/%3E+.}
where each item has:
The result will include all Wikidata items, their IMDb IDs and linked with them ruwiki article names.
{
"item" : {
"value" : "http://www.wikidata.org/entity/Q203063"
},
"IMDb_ID" : {
"value" : "tt0457308"
},
"sitelink" : {
"value" : "https://ru.wikipedia.org/wiki/Приходи_пораньше"
}
},
...
And here is an example how you can get the IMDb ID only for the Russian page Приходи пораньше.
Upvotes: 4