CollectionsCollections Database

TMDB Javascript library

The TMDB Javascript library is a wrapper for the The Movie Database (TMDB) API.

To use this library you need to register an API Key, please visit the TMDB Developer page for more info.

The source code is available in the GitHub repository.

app.api.tmdb
The library is accessible from the app.api.tmdb object.
api_key string
Set the API Key for the API (required).
language string
Set the language for the API in ISO 639-1 format. Default value is "en-US".
searchMovies(query app.query object) array of search results
The function searches movies and returns an array of search results.
getMovie(id integer) movie
The function gets a movie by ID. It returns a movie or undefined if it doesn't exist.
searchTV(query app.query object) array of search results
The function searches TV series and returns an array of search results.
getTV(id integer) tv
The function gets a TV series by ID. It returns a TV series or undefined if it doesn't exist.
movieClass class
Set a custom class for the movie, the class must extend app.classes.api.tmdb.movie
tvClass class
Set a custom class for the TV series, the class must extend app.classes.api.tmdb.tv
seasonClass class
Set a custom class for the TV season, the class must extend app.classes.api.tmdb.season
episodeClass class
Set a custom class for the TV episode, the class must extend app.classes.api.tmdb.episode
// TMDB movies search (1.1)
// https://github.com/risolvipro/collections

app.api.tmdb.api_key = "YOUR API KEY";
app.api.tmdb.language = "en-US";

let results = app.api.tmdb.searchMovies(app.query);
app.result(results);
// TMDB tv search (1.1)
// https://github.com/risolvipro/collections

app.api.tmdb.api_key = "YOUR API KEY";
app.api.tmdb.language = "en-US";

let results = app.api.tmdb.searchTV(app.query);
app.result(results);

Movie

app.classes.api.tmdb.movie
This class manages a movie.
data json
The json data returned by the TMDB API.
id integer
ID of the movie.
title string
Title of the movie.
overview string
Overview of the movie.
releaseDate date
The release date of the movie as a Date object.
posterURL(size string) string
Get a poster URL in the specified size. Size parameter is optional, default value is "original".
requestPoster(size string) image
Request a poster in the specified size. It returns an image or undefined it the request fails. Size parameter is optional, default value is "original".
runtime number
Runtime in seconds.
genres array of list item suggestions
Get the genres as an array of list item suggestions.
actors(limit integer) array of document suggestions
Get the actors as an array of document suggestions.
directors array of document suggestions
Get the directors as an array of document suggestions.
configureActor(actor document, data json)
Implement this method in your custom class to configure an actor before it's added to the actors array.
configureDirector(director document, data json)
Implement this method in your custom class to configure a director before it's added to the directors array.
// TMDB movies document (1.1)
// https://github.com/risolvipro/collections

app.api.tmdb.api_key = "YOUR API KEY";
app.api.tmdb.language = "en-US";

let movie = app.api.tmdb.getMovie(app.params.id);

if(movie == undefined) {
    app.fail();
}

let builder = app.document.builder();

builder.setString(movie.title, "title");
builder.setString(movie.id, "tmdb-id");
builder.setImage(movie.requestPoster(), "poster");
builder.setString(movie.overview, "overview");
builder.setListItems(movie.genres, "genre");
builder.setDate(movie.releaseDate, "release-date");
builder.setDecimal(movie.runtime, "runtime");
builder.setDocuments(movie.actors(10), "actors");
builder.setDocuments(movie.directors, "directors");

app.result(builder);

TV Series

app.classes.api.tmdb.tv
data json
The json data returned by the TMDB API.
id integer
ID of the TV series.
name string
Name of TV series.
overview string
Overview of the TV series.
firstAirDate date
Air date.
posterURL(size string) string
Get a poster URL in the specified size. Size parameter is optional, default value is "original".
requestPoster(size string) image
Request a poster in the specified size. It returns an image or undefined it the request fails. Size parameter is optional, default value is "original".
genres array of list item suggestions
Get the genres as an array of list item suggestions.
actors(limit integer) array of document suggestions
Get the actors as an array of document suggestions.
seasons array of document suggestions
Get the seasons an array of document suggestions.
configureActor(actor document, data json)
Implement this method in your custom class to configure an actor before it's added to the actors array.
configureSeason(season document, object season object)
Implement this method in your custom class to configure a season before it's added to the seasons array. Please see TV Season for more info.
configureEpisode(episode document, object episode object)
Implement this method in your custom class to configure an episode before it's added to the episodes array. Please see TV Episode for more info.
// TMDB tv document (1.1)
// https://github.com/risolvipro/collections

app.api.tmdb.api_key = "YOUR API KEY";
app.api.tmdb.language = "en-US";

let tvShow = app.api.tmdb.getTV(app.params.id);

if(tvShow == undefined) {
    app.fail();
}

let builder = app.document.builder();

builder.setString(tvShow.name, "name");
builder.setImage(tvShow.requestPoster(), "poster");
builder.setString(tvShow.overview, "overview");
builder.setListItems(tvShow.genres, "genre");
builder.setDate(tvShow.firstAirDate, "air-date");
builder.setDocuments(tvShow.actors(10), "actors");
builder.setManagedDocuments(tvShow.seasons, "seasons");
builder.setString(tvShow.id, "tmdb-id");

app.result(builder);

TV Season

app.classes.api.tmdb.season
This class manages a TV season.
data json
The json data returned by the TMDB API.
id integer
name string
seasonNumber integer
airDate date

TV Episode

app.classes.api.tmdb.episode
This class manages a TV episode.
data json
The json data returned by the TMDB API.
id integer
name string
seasonNumber integer
episodeNumber integer
runtime number
airDate date