Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of all films on Wikidata?

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.

like image 300
Mightee Avatar asked Feb 10 '23 05:02

Mightee


1 Answers

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

like image 109
maxlath Avatar answered Feb 15 '23 23:02

maxlath