A non-scraping, functional node.js interface to imdb
Gitlab is the official upstream, and commits are mirrored to Github. I look at issues and PRs/MRs on both. Feel free to contribute on either.
Import the library using require
constimdb=require('imdb-api')or ES6 import
importimdbfrom'imdb-api'Call get to get a single movie
imdb.get({name: 'The Toxic Avenger'},{apiKey: 'foo',timeout: 30000}).then(console.log).catch(console.log);Movie{title: 'The Toxic Avenger',
...
}Furthermore if you already know the id you can call get with different args:
imdb.get({id: 'tt0090190'},{apiKey: 'foo'}).then(console.log);Movie{title: 'The Toxic Avenger',
...
}You can search for movies, and get multiple results by using the search function.
imdb.search({name: 'Toxic Avenger'},{apiKey: 'foo'}).then(console.log).catch(console.log);TV shows have an episodes method that you can use to fetch all of the episodes
from that TV series.
imdb.get({name: 'How I Met Your Mother'},{apiKey: 'foo'}).then((things)=>{returnthings.episodes()}).then((eps)=>{console.log(eps);});Episode{season: 2,name: 'The Scorpion and the Toad',released: '2006-10-25T07:00:00.000Z',episode: 2,rating: '8.3',imdbid: 'tt0869673'},
...imdb-api also exported a Client object that you can use to store options for subsequent requests.
importimdb=require('imdb');constcli=newimdb.Client({apiKey: 'xxxxxx'});cli.get({'name': 'The Toxic Avenger'}).then(console.log);Client also has a search method for searching.
importimdb=require('imdb');constcli=newimdb.Client({apiKey: 'xxxxxx'});cli.search({'name': 'The Toxic Avenger'}).then((search)=>{for(constresultofsearch.results){console.log(result.title);}});Yes, it is required! omdb made this a requirement as of May 8, 2017. This is unfortunate, but totally understandable. While I plan on working on finding an alternative to provide the movie info you crave, I've enabled you to pass in an apikey.
You can get one by going here.
Most of them scrape imdb. imdb explicitly forbids scraping.
And what happens when the site layout changes? Well then your screen scraping solution fails in interesting ways. Screen scraping is also pretty slow, and we can't have that.
There isn't an official API to imdb. As soon as one is released (and I notice), I'll update the module.
imdb DOES release all of their data in text files nightly, so unofficial sites have popped up providing RESTful APIs against that data.
I have to use a few, since none of them are complete.
File a bug. I'll get creative.