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 🙏

© 2026 – Pkg Stats / Ryan Hefner

guy_pavlov-sdk

v1.0.2

Published

Node.js SDK for the Lord Of The Rings API (LOTR) https://the-one-api.dev/.

Readme

Lord Of The Rings API SDK

Overview

This is a node.js SDK for the Lord Of The Rings API (LOTR) https://the-one-api.dev/. The LOTR API is a RESTful API based on the books and movies of The Lord of the Rings and The Hobbit. The API is free to use but requires an API key to access the data. You can get an API key by registering at https://the-one-api.dev/. The SDK was developed as a take home assignment for a job interview. The SDK is not intended for production use.

Compatibility

This SDK was tested with node v19.5.0 and npm v9.3.1

Installation

npm i guy_pavlov-sdk

Authentication

The SDK requires an API key to access the LOTR API. You can get an API key by registering at https://the-one-api.dev/. The API key should be set as an environment variable named API_ACCESS_TOKEN.

Environment Variables

The SDK requires the following environment variables to be set:

  • API_ACCESS_TOKEN - The API key for the LOTR API
  • ENABLE_LOGGING (optional, default false) - Set to true to enable logging

To use .env files, install the dotenv package and add the following to your code: require('dotenv').config() To start with a template .env file, rename the .env.example file to .env and set the environment variables there.

Usage

The SDK exposes the following methods:

  • getMovies (paginated, sorted) - returns a list of movies
  • getMovieById - returns a movie by id
  • getQuotesByMovieId (paginated, sorted) - returns a list of quotes for a movie given the movie id

Examples

getMovies

const sdk = require('guy_pavlov-sdk');
const movies = await sdk.getMovies();

getMovies results

{
  docs: [
    {
      _id: '5cd95395de30eff6ebccde56',
      name: 'The Lord of the Rings Series',
      runtimeInMinutes: 558,
      budgetInMillions: 281,
      boxOfficeRevenueInMillions: 2917,
      academyAwardNominations: 30,
      academyAwardWins: 17,
      rottenTomatoesScore: 94
    },
    
    {
      _id: '5cd95395de30eff6ebccde5b',
      name: 'The Two Towers',
      runtimeInMinutes: 179,
      budgetInMillions: 94,
      boxOfficeRevenueInMillions: 926,
      academyAwardNominations: 6,
      academyAwardWins: 2,
      rottenTomatoesScore: 96
    },
    {
      _id: '5cd95395de30eff6ebccde5c',
      name: 'The Fellowship of the Ring',
      runtimeInMinutes: 178,
      budgetInMillions: 93,
      boxOfficeRevenueInMillions: 871.5,
      academyAwardNominations: 13,
      academyAwardWins: 4,
      rottenTomatoesScore: 91
    },
    {
      _id: '5cd95395de30eff6ebccde5d',
      name: 'The Return of the King',
      runtimeInMinutes: 201,
      budgetInMillions: 94,
      boxOfficeRevenueInMillions: 1120,
      academyAwardNominations: 11,
      academyAwardWins: 11,
      rottenTomatoesScore: 95
    }
  ],
  total: 8,
  limit: 1000,
  offset: 0,
  page: 1,
  pages: 1
}

getMovieById

const sdk = require('guy_pavlov-sdk');
const movie = await sdk.getMovieById('5cd99d4bde30eff6ebccde5d');

getMovieById results

{
  docs: [
    {
      _id: '5cd95395de30eff6ebccde5d',
      name: 'The Return of the King',
      runtimeInMinutes: 201,
      budgetInMillions: 94,
      boxOfficeRevenueInMillions: 1120,
      academyAwardNominations: 11,
      academyAwardWins: 11,
      rottenTomatoesScore: 95
    }
  ],
  total: 1,
  limit: 1000,
  offset: 0,
  page: 1,
  pages: 1
}

getQuotesByMovieId

const sdk = require('guy_pavlov-sdk');
const quotes = await sdk.getQuotesByMovieId('5cd99d4bde30eff6ebccde5d');

getQuotesByMovieId results

{
  docs: [
    {
      _id: '5cd96e05de30eff6ebcce7e9',
      dialog: 'Deagol!',
      movie: '5cd95395de30eff6ebccde5d',
      character: '5cd99d4bde30eff6ebccfe9e',
      id: '5cd96e05de30eff6ebcce7e9'
    },
        {
      _id: '5cd96e05de30eff6ebcce84b',
      dialog: "Well, I'm back.",
      movie: '5cd95395de30eff6ebccde5d',
      character: '5cd99d4bde30eff6ebccfd0d',
      id: '5cd96e05de30eff6ebcce84b'
    },
    {
      _id: '5cd96e05de30eff6ebcce84c',
      dialog: "I didn't think it would end this way.",
      movie: '5cd95395de30eff6ebccde5d',
      character: '5cd99d4bde30eff6ebccfe2e',
      id: '5cd96e05de30eff6ebcce84c'
    },
    ... 772 more items
  ],
  total: 872,
  limit: 1000,
  offset: 0,
  page: 1,
  pages: 1
}

Using pagination and sorting

The SDK supports pagination and sorting through an optional options parameter. The options parameter is an object with the following properties:

type Pagination = {
    limit?: number;
    page?: number;
    offset?: number;
}

type Sorting = {
    field?: string;
    direction?: 'asc' | 'desc';
}

type Filtering = {
    name?: string;
}

type Options = {
    pagination?: Pagination;
    sorting?: Sorting
    filtering?: Filtering
}

Retrieving the second page of 3 movies

const sdk = require('guy_pavlov-sdk');
const options = {
    // Three quotes per page, page 2, quote 1
    pagination: {
      limit: 3,
      page: 2,
      offset: 1
    }
  }
const movies = await sdk.getMovies(options);

Sorting movies by name in descending order

const sdk = require('guy_pavlov-sdk');
const options = {
    sorting: {
      field: 'name',
      direction: 'desc'
    }
  }
const movies = await sdk.getMovies(options);

Test

npm run test

Build

npm run build

Publish

npm publish

Unsupported Features

The filtering feature is not supported by the SDK.