4

I was using Freebase to get all movies/films there for my website, but it's getting shut down soon. so I was searching for another free database for movies and came across Wikidata. To be honest it's too complicated to understand how to query all the movies.

So I thought you guys could help me to get all the movies in Wikidata. In the future I want to include TV shows and series as well.

Programming language doesn't matter, I want to use web query with a link.

Termininja
  • 6,620
  • 12
  • 48
  • 49
Mightee
  • 689
  • 7
  • 22

1 Answers1

8

you can look for all the entities that are an instance of film, which in Wikidata is translated as:

P31 (instance of) -> Q11424 (film)

For the moment, the best way to do this query is to use the wdq.wmflabs.org API, where this query translate as: http://wdq.wmflabs.org/api?q=claim[31:11424] (avoid making this query in a browser as it will probably make it crash due to the ). At the moment I'm writting, this requests returns 157038 items in the form of numeric ids (ex: 125). To get the Wikidata ids, just add a leading Q -> Q125.

To get the labels and data from all those Wikidata ids, use the Wikidata API wbgetentities action: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q180736&format=json&languages=en. Beware of the 50 entities per-query limit though

[UPDATE] Wikidata now offers a SPARQL endpoints: the same query in SPARQL or even this same query but also including subclasses of films

maxlath
  • 1,804
  • 15
  • 24
  • thanks for your reply. but is there any paging when i get all the ids ? in freebase i could limit queries per page and then get the current page cursor to do the paging later. is this possible ? – Mightee Aug 24 '15 at 12:34
  • not that I'm aware of, but if you need to get absolutely all the films at once, you might rather have a look at wikidata dumps https://www.wikidata.org/wiki/Wikidata:Database_download#JSON_dumps_.28recommended.29 and extract a subset of it: `cat dump.json |grep '11424\,' > films.json`, see what I did there https://github.com/inventaire/inventaire-authors-birthday – maxlath Aug 24 '15 at 13:08
  • If you're thinking of using this for a production application, note that the referenced API is an experimental one which will probably be retired when there's a production Wikidata query API available. – Tom Morris Sep 01 '15 at 15:32
  • i tried to use the bash command but i got a file with 73 KB and there was only ~30 items which are not even films. [link](http://wdq.wmflabs.org/api?q=claim[31:11424]) gives different items which are also not movies. I dont understand why is it so complicated. – Mightee Sep 04 '15 at 14:41
  • Have also found some entries which are instances of Q24869(feature film). The classification is not as accurate as I would like either – Shamps Dec 11 '15 at 17:09