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

rotten-api

v0.0.2

Published

A simple NodeJS interface to the Rotten Tomatoes API

Downloads

37

Readme

rotten-api

rotten-api is a simple to use NodeJS interface to the Rotten Tomatoes API that allows you to :

  • search for movies based on a query string
  • get information on a single movie with its id (or IMDB id)
  • get similar movies of a given movie id
  • get the full cast of a movie
  • ...

Every callback takes two arguments, an error object and a response object.
In the examples below the errors are not handled, this is not recommended.

Install

npm install rotten-api

Getting Started

See the Rotten Tomatoes API web site to get your API key.

var r = require('rotten-api')("YOU_API_KEY");

Searching for movies

Supply a query string to the search method.

r.search('The Godfather', function (err, res) {
    if (!err) {
        var movies = (res && res.movies) ? res.movies : [];
        for(var i = 0, len = movies.length; i < len; i++) {
            console.log(movies[i].id + " : " + movies[i].title);
        }
    }
});

outputs :

12911 : The Godfather
12926 : The Godfather, Part II
13476 : The Godfather, Part III
770669374 : Bonanno: A Godfather's Story (The Youngest Godfather)
405587791 : Godfather
# 25 more lines ...

If you wish to see less results :

r.search({
    "query": 'The Godfather'
    "limit": 3
}, function (err, res) {
        // same as above
});

will output :

12911 : The Godfather
12926 : The Godfather, Part II
13476 : The Godfather, Part III

Get information on a single movie.

By supplying the movie's id (possibly retrieved thanks to a search query)

r.get("12911", function (err, res) {
    if (!err) {
        var movie = res || {};
        console.log(movie);
    }
});

or by supplying the IMDB id :

r.alias("tt0068646", function (err, res) {
        // same as above
});

outputs in both cases :

{ id: 12911,
  title: 'The Godfather',
  year: 1972,
  genres: [ 'Drama' ],
  mpaa_rating: 'R',
  runtime: 175,
  critics_consensus: 'One of Hollywood\'s greatest critical and commercial successes, The Godfather gets everything right; not only did the movie transcend expectations, it established new benchmarks for American cinema.',
  release_dates: { theater: '1972-03-24', dvd: '2001-10-09' },
  ratings:
   { critics_rating: 'Certified Fresh',
     critics_score: 100,
     audience_rating: 'Upright',
     audience_score: 97 },
  synopsis: '',
  posters:
   { thumbnail: 'http://content6.flixster.com/movie/11/17/16/11171612_mob.jpg',
     profile: 'http://content6.flixster.com/movie/11/17/16/11171612_pro.jpg',
     detailed: 'http://content6.flixster.com/movie/11/17/16/11171612_det.jpg',
     original: 'http://content6.flixster.com/movie/11/17/16/11171612_ori.jpg' },
  abridged_cast:
   [ { name: 'Marlon Brando', id: '162660428', characters: [Object] },
     { name: 'Al Pacino', id: '162654461', characters: [Object] },
     { name: 'James Caan', id: '162656402', characters: [Object] },
     { name: 'John Cazale', id: '162664256', characters: [Object] },
     { name: 'Robert Duvall', id: '162652186', characters: [Object] } ],
  abridged_directors: [ { name: 'Francis Ford Coppola' } ],
  studio: 'Paramount Pictures',
  alternate_ids: { imdb: '0068646' },
  links:
   { self: 'http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?type=imdb&id=0068646',
     alternate: 'http://www.rottentomatoes.com/m/godfather/',
     cast: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/cast.json',
     clips: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/clips.json',
     reviews: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/reviews.json',
     similar: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/similar.json',
     canonical: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911.json' },
  link_template: 'http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?type=imdb&id={alias-id}' }

Formats

Single result format

{ id: 12911,
  title: 'The Godfather',
  year: 1972,
  genres: [ 'Drama' ],
  mpaa_rating: 'R',
  runtime: 175,
  critics_consensus: 'One of Hollywood\'s greatest critical and commercial successes, The Godfather gets everything right; not only did the movie transcend expectations, it established new benchmarks for American cinema.',
  release_dates: { theater: '1972-03-24', dvd: '2001-10-09' },
  ratings:
   { critics_rating: 'Certified Fresh',
     critics_score: 100,
     audience_rating: 'Upright',
     audience_score: 97 },
  synopsis: '',
  posters:
   { thumbnail: 'http://content6.flixster.com/movie/11/17/16/11171612_mob.jpg',
     profile: 'http://content6.flixster.com/movie/11/17/16/11171612_pro.jpg',
     detailed: 'http://content6.flixster.com/movie/11/17/16/11171612_det.jpg',
     original: 'http://content6.flixster.com/movie/11/17/16/11171612_ori.jpg' },
  abridged_cast:
   [ { name: 'Marlon Brando', id: '162660428', characters: [Object] },
     { name: 'Al Pacino', id: '162654461', characters: [Object] },
     { name: 'James Caan', id: '162656402', characters: [Object] },
     { name: 'John Cazale', id: '162664256', characters: [Object] },
     { name: 'Robert Duvall', id: '162652186', characters: [Object] } ],
  abridged_directors: [ { name: 'Francis Ford Coppola' } ],
  studio: 'Paramount Pictures',
  alternate_ids: { imdb: '0068646' },
  links:
   { self: 'http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?type=imdb&id=0068646',
     alternate: 'http://www.rottentomatoes.com/m/godfather/',
     cast: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/cast.json',
     clips: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/clips.json',
     reviews: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/reviews.json',
     similar: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911/similar.json',
     canonical: 'http://api.rottentomatoes.com/api/public/v1.0/movies/12911.json' },
  link_template: 'http://api.rottentomatoes.com/api/public/v1.0/movie_alias.json?type=imdb&id={alias-id}' }

Multiple results format

{ total: 49,
  movies:
   [ { id: '12911',
       title: 'The Godfather',
       year: 1972,
       mpaa_rating: 'R',
       runtime: 175,
       critics_consensus: 'One of Hollywood\'s greatest critical and commercial successes, The Godfather gets everything right; not only did the movie transcend expectations, it established new benchmarks for American cinema.',
       release_dates: [Object],
       ratings: [Object],
       synopsis: '',
       posters: [Object],
       abridged_cast: [Object],
       alternate_ids: [Object],
       links: [Object] },
     { id: '12926',
       title: 'The Godfather, Part II',
       year: 1974,
       mpaa_rating: 'R',
       runtime: 200,
       critics_consensus: 'Drawing on strong performances by Al Pacino and Robert De Niro, Francis Ford Coppola\'s continuation of Mario Puzo\'s Mafia saga set new standards for sequels that have yet to be matched or broken.',
       release_dates: [Object],
       ratings: [Object],
       synopsis: '',
       posters: [Object],
       abridged_cast: [Object],
       alternate_ids: [Object],
       links: [Object] },
       // ...
       ],
  links:
   { self: 'http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=The+Godfather&page_limit=30&page=1',
     next: 'http://api.rottentomatoes.com/api/public/v1.0/movies.json?q=The+Godfather&page_limit=30&page=2' },
  link_template: 'http://api.rottentomatoes.com/api/public/v1.0/movies.json?q={search-term}&page_limit={results-per-page}&page={page-number}' }