67 |
68 | node-imdb-api
69 |
70 |
A non-scraping, functional node.js interface to imdb
71 |
72 | Badges
73 |
74 |

75 |
NOTE ON GITTER: I am online! I use the matrix bridge to talk on Gitter, so you'll see me talking through MatrixBot. Feel free to ask questions!
76 |
77 | Github / Gitlab
78 |
79 |
Gitlab is the official upstream, and
80 | commits are mirrored to Github. I look
81 | at issues and PRs/MRs on both. Feel free to contribute on either.
82 |
83 | API Docs
84 |
85 |
API docs are now here
86 |
87 | Use
88 |
89 |
Import the library using require
90 |
const imdb = require('imdb-api')
91 |
or ES6 import
92 |
import imdb from 'imdb-api'
93 |
Call get to get a single movie
94 |
imdb.get({name: 'The Toxic Avenger'}, {apiKey: 'foo', timeout: 30000}).then(console.log).catch(console.log);
95 |
96 | Movie {
97 | title: 'The Toxic Avenger',
98 | ...
99 | }
100 |
Furthermore if you already know the id you can call get with different args:
101 |
imdb.get({id: 'tt0090190'}, {apiKey: 'foo'}).then(console.log);
102 |
103 | Movie {
104 | title: 'The Toxic Avenger',
105 | ...
106 | }
107 |
You can search for movies, and get multiple results by using the search function.
108 |
imdb.search({
109 | name: 'Toxic Avenger'
110 | }, {
111 | apiKey: 'foo'
112 | }).then(console.log).catch(console.log);
113 |
TV shows have an episodes method that you can use to fetch all of the episodes
114 | from that TV series.
115 |
imdb.get({name: 'How I Met Your Mother'}, {apiKey: 'foo'}).then((things) => {
116 | return things.episodes()
117 | }).then((eps) => {
118 | console.log(eps);
119 | });
120 |
121 | Episode {
122 | season: 2,
123 | name: 'The Scorpion and the Toad',
124 | released: '2006-10-25T07:00:00.000Z',
125 | episode: 2,
126 | rating: '8.3',
127 | imdbid: 'tt0869673' },
128 | ...
129 |
130 | Using a Client object
131 |
132 |
imdb-api also exported a Client object that you can use to store options for subsequent requests.
133 |
import imdb = require('imdb');
134 | const cli = new imdb.Client({apiKey: 'xxxxxx'});
135 | cli.get({'name': 'The Toxic Avenger'}).then(console.log);
136 |
Client also has a search method for searching.
137 |
import imdb = require('imdb');
138 | const cli = new imdb.Client({apiKey: 'xxxxxx'});
139 | cli.search({'name': 'The Toxic Avenger'}).then((search) => {
140 | for (const result of search.results) {
141 | console.log(result.title);
142 | }
143 | });
144 |
145 | FAQ
146 |
147 |
148 | I see an API key in your examples? Is it required? How do I get one?
149 |
150 |
Yes, it is required! omdb made this a requirement as of May 8, 2017. This is unfortunate,
151 | but totally understandable. While I plan on working on finding an alternative to provide
152 | the movie info you crave, I've enabled you to pass in an apikey.
153 |
You can get one by going here.
154 |
155 | Why? There are like 3 other interfaces to imdb in npm
156 |
157 |
Most of them scrape imdb. imdb explicitly forbids scraping.
158 |
And what happens when the site layout changes? Well then your screen scraping
159 | solution fails in interesting ways. Screen scraping is also pretty slow,
160 | and we can't have that.
161 |
162 | WOAH I looked at your code and you're using unofficial APIs!
163 |
164 |
There isn't an official API to imdb. As soon as one is released (and I
165 | notice), I'll update the module.
166 |
imdb DOES release all of their data in text files nightly, so unofficial sites
167 | have popped up providing RESTful APIs against that data.
168 |
I have to use a few, since none of them are complete.
169 |
170 | What if one of the unofficial APIs disappears?
171 |
172 |
File a bug. I'll get creative.
173 |