npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imdb-api

v4.4.1

Published

Queries unofficial imdb APIs to get movie and television information from imdb

Downloads

1,669

Readme

node-imdb-api

A non-scraping, functional node.js interface to imdb

Badges

NPM version pipeline status Dependency Freshness coverage report Join the chat at https://gitter.im/worr/node-imdb-api

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!

Github / Gitlab

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.

API Docs

API docs are now here

Use

Import the library using require

const imdb = require('imdb-api')

or ES6 import

import imdb from '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) => {
    return things.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' },
...

Using a Client object

imdb-api also exported a Client object that you can use to store options for subsequent requests.

import imdb = require('imdb');
const cli = new imdb.Client({apiKey: 'xxxxxx'});
cli.get({'name': 'The Toxic Avenger'}).then(console.log);

Client also has a search method for searching.

import imdb = require('imdb');
const cli = new imdb.Client({apiKey: 'xxxxxx'});
cli.search({'name': 'The Toxic Avenger'}).then((search) => {
  for (const result of search.results) {
    console.log(result.title);
  }
});

FAQ

I see an API key in your examples? Is it required? How do I get one?

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.

Why? There are like 3 other interfaces to imdb in npm

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.

WOAH I looked at your code and you're using unofficial APIs!

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.

What if one of the unofficial APIs disappears?

File a bug. I'll get creative.