Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Client

A client for fetching imdb information.

This is primarly useful for making many requests without having to pass a MovieOpts object to the same function over and over again.

All methods still accept an optional MovieOpts object in the case that you want to override one or more of the options. These per-method options are merged with the options that are attached to the object, and override the object-local options.

const cli = new imdb.Client({apiKey: 'xxxxxx', timeout: 30000});
cli.get({name: "The Toxic Avenger"}).then((movie) => {
  console.log(movie.title);
});

cli.search({name: "The Toxic Avenger"}).then((search) => {
  for (let result of search.results) {
    console.log(result.title);
  }
});

Hierarchy

  • Client

Index

Constructors

Methods

Constructors

constructor

  • Creates a new Client object.

    throws

    ImdbError if an invalid MovieOpts is passed

    Parameters

    • opts: MovieOpts

      A set of MovieOpts that will be applied to all requests made by this object unless overridden.

    Returns Client

Methods

get

  • Fetches a single movie by arbitrary criteria

    Parameters

    Returns Promise<Movie>

    a promise yielding a movie

search

  • Searches for a movie by arbitrary criteria

    Parameters

    • req: SearchRequest

      set of requirements to search for

    • Optional page: undefined | number

      page number to return

    • Optional opts: MovieOpts

      options that override the Client's options

    Returns Promise<SearchResults>

    a promise yielding search results

Generated using TypeDoc