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.
movieClass class
Set a custom class for the movie, the class must extend app.classes.api.tmdb.movie
// TMDB movies search (1.0)
// 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);

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".
genres array of list item suggestions
Get the genres of the movie as an array of list item suggestions.
// TMDB movies document (1.0)
// 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.setImage(movie.requestPoster(), "poster");
builder.setString(movie.overview, "overview");
builder.setListItems(movie.genres, "genre");
builder.setDate(movie.releaseDate, "release-date");

app.result(builder);