Nondeterministic Polynomial Munchies

npm

Don't miss out on this year's npm Pride t-shirt designs!Order your favorites here »

myts-api

0.2.0 • Public • Published

myts-api

Get started quickly with yts api with the myts-api for JavaScript in Node.js. The SDK helps take the complexity out of coding by providing JavaScript functoins for yts services including List Movies and List Upcoming. The single, downloadable package includes the yts api JavaScript Library and documentation.

Highlights

  • Works on server and client
  • Jest - 🃏 Delightful JavaScript Testing
  • Log generator
  • YTS API
  • axios as a Promise based HTTP client for the browser and node.js
  • No axios unit jest test (next release)

Install

Inside your project folder do:

npm i -S myts-api

Usage

NodeJS

Simply require the module myts-api

const MytsApi = require('myts-api').API;
const myts = new MytsApi();
 
 
// myts fields
/*
baseUrl: string;      // Yts api base url, for endpoints GET request
qualities: any;       // Yts moveis qualities object - [HD,FULL HD, 3D]
sortBy: any;          // query sort object - [title,year,rating,peers,seeds,download_count, like_count, date_added], default: date_added
orderBy: any;         // query order object - [asc,desc], default: desc
endpoints: any;       // Yts Api Endpoints which provides an easy way to access the YTS website
trackers: any;   // YTS, torrents recommend trackers
*/
 

Functions

This functions makes HTTP GET call using axios, and return an Promise, with the response or throw and error.

List Movies

For list movies action, call listMovies(params:not required), where params is the search condition (please check the YTS API List Movies parameters table at the bottom ), returning the result empty list, or a list of movies object.

myts.listMovies()
  .then((movies)=>{
    console.log("Movies: ",movies)
  })
  .catch(err=>{
      console.log("Error: ",err)
  })
 

Movie Details

For movies details action, call movieDetails(params:{movie_id:int} required), where params is an object with required movie_id and others (please check the YTS API Movie Details parameters table at the bottom ), returning the result empty object, or the result movie detail object.

myts.movieDetails({movie_id:8553})
  .then((movie)=>{
    console.log("Movie: ",movie)
  })
  .catch(err=>{
      console.log("Error: ",err)
  })
 

YTS API

Endpoints

List Movies

list_movies - Used to list and search through out all the available movies. Can sort, filter, search and order the results.

Example: https://yts.am/api/v2/list_movies.json?quality=3D

Parameters
Parameter Required Type Default Description
limit False Integer between 1 - 50 (inclusive) 20 The limit of results per page that has been set
page False Integer (Unsigned) 1 Used to see the next page of movies, eg limit=15 and page=2 will show you movies 15-30
quality False String (720p, 1080p, 3D) All Used to filter by a given quality
minimum_rating False Integer between 0 - 9 (inclusive) 0 Used to filter movie by a given minimum IMDb rating
query_term False String 0 Used for movie search, matching on: Movie Title/IMDb Code, Actor Name/IMDb Code, Director Name/IMDb Code
genre False String All Used to filter by a given genre (See http://www.imdb.com/genre/ for full list)
sort_by False String (title, year, rating, peers, seeds, download_count, like_count, date_added) date_added Sorts the results by choosen value
order_by False String (desc, asc) desc Orders the results by either Ascending or Descending order
with_rt_ratings False Boolean false Returns the list with the Rotten Tomatoes rating included

Movie Details

movie_details - Returns the information about a specific movie.

Example:https://yts.am/api/v2/movie_details.json?movie_id=15&with_images=true&with_cast=true

Parameters
Parameter Required Type Default Description
movie_id True Integer (Unsigned) null The ID of the movie
with_images False Boolean false When set the data returned will include the added image URLs
with_cast False Boolean false When set the data returned will include the added information about the cast

List Upcoming

list_upcoming - Returns the 4 latest upcoming movies.

Example: https://yts.am/api/v2/list_upcoming.json

changelogs for this project

install

npm i myts-api

Downloadsweekly downloads

27

version

0.2.0

license

ISC

homepage

shrink.org

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability