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

tmdb-ts-wrapper

v1.0.0

Published

Unofficial TypeScript API wrapper for TMDB v3 & v4.

Downloads

4

Readme

tmdb-ts-wrapper

An unofficial TypeScript wrapper for TMDB's API. Supports v3 and v4.

Install

npm i tmdb-ts-wrapper

Usage

Prerequisites

  • Create TMDB login and apply for an API key.
  • Obtain API Read Access Token. This can be found below your API key on TMDB.

Import

import { TMDB } from 'tmdb-ts-wrapper';

Instantiate

  • ACCESS_TOKEN - Read access token retrieved from TMDB
  • LANGUAGE - ISO-639-1 Language Code. Optional. Default is en-US. Follow this link and select 'Example' to see all 'officially' supported languages.
const ACCESS_TOKEN = "MY_ACCESS_TOKEN";
const LANGUAGE = "en-US";

const tmdb = new TMDB(ACCESS_TOKEN, LANGUAGE);

Getting Data

All endpoints and their methods described on TMDB for v3 and v4 are available and have been typed. For example.

//Get Movie Details
const movie: Movie = await tmdb.movies.getDetails(414906);

//Get Company Details
const company: Company = await tmdb.companies.getDetails(1);

//Create Guest Session
const res: Authenticationv3CreateGuestSessionResponse = await tmdb.authv3.createGuestSession();
const guest_session_id = res.guest_session_id;

//Rate Movie
const res1 = await tmdb.movies.rateMovie(414906, { guest_session_id }, { value: 8 });

Language / Translation

Any of the endpoints which include language in their query string will by default use the language you defined in the config. You can however override them if needed.

const ACCESS_TOKEN = "MY_ACCESS_TOKEN";

//Configured to English
const tmdb = new TMDB(ACCESS_TOKEN, "en-US");

//Will return in English
const enPopularMovies = tmdb.movies.getPopular();

//Override to German
const popularMovies = tmdb.movies.getPopular({ language: "de-DE" });

//Override to Spanish
const movieCredits = tmdb.moves.getCredits(414906, "es-ES");

Append To Response

To use append_to_response you will have to use endpoint. endpoint allows you to provide your own typing as well as your own endpoint, query string and request body.

For example:

import { Movie, Video } from 'tmdb-ts-wrapper';

interface MovieVideo extends Movie {
    videos: {
        results: Video[]
    }
};

const result = await tmdb.endpoint.get<MovieVideo>("movie/551", { append_to_response: "videos" });

Please note that according to TMDB documentation, Append To Response only supports the 'Get Details' methods for the following endpoints.

  • Movie
  • TV show
  • TV season
  • TV episode
  • Person

Images

To build image URLs use getImageURL(). Image types (e.g. backdrop, profile) and their sizes have been typed.

//Get Backdrop
const backdropURL = getImageURL({ file_path: "FILE_PATH", image_type: "backdrop", backdrop_size: "w1280" });

//Get Logo
const logoURL = getImageURL({ file_path: "FILE_PATH", image_type: "logo", logo_size: "w45" });

//Get Poster
const posterURL = getImageURL({ file_path: "FILE_PATH", image_type: "poster", poster_size: "w154" });

//Get Profile
const profileURL = getImageURL({ file_path: "FILE_PATH", image_type: "profile", profile_size: "h632" });

//Get Still
const stillURL = getImageURL({ file_path: "FILE_PATH", image_type: "still", still_size: "original" });