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 🙏

© 2025 – Pkg Stats / Ryan Hefner

the-lord-of-the-rings-api-ts-sdk

v1.0.1

Published

A TypeScript SDK for the The One (The Lord of the Rings) API

Downloads

3

Readme

The One (The Lord of the Rings) API SDK for TypeScript

Introduction

A TypeScript SDK for The One (The Lord of the Rings) API. This library is built with TypeScript developers in mind, but it also works with JavaScript.

Features

  • Full type information for requests and responses
  • OAuth2 support
  • Supports Node.js 18+. Doesn't work in browser environments due to the The One (The Lord of the Rings) API not supporting CORS

Installing

npm install the-lord-of-the-rings-api-ts-sdk

Client

To set up the client you need to authenticate with authentication token


import { Client } from "the-lord-of-the-rings-api-ts-sdk";

const client = new Client({ auth: 'MY-BEARER-TOKEN' });

Examples

Listing movies

import { Client } from "the-lord-of-the-rings-api-ts-sdk";

const client = new Client({ auth: ACCESS_TOKEN });

const moviesRes = await client.listMovies();

if (!('docs' in moviesRes)) {
    throw new Error(moviesRes.body.message);
}

const movies = moviesRes.docs;

Getting a movie

import { Client } from "the-lord-of-the-rings-api-ts-sdk";

const client = new Client({ auth: ACCESS_TOKEN });

const movieRes = await client.getMovie({ movieId: movies[0]._id });

if (!('_id' in movieRes)) {
    throw new Error(movieRes.body.message);
}

console.log(`Movie: ${movieRes.name} (${movieRes.budgetInMillions} M$)`);

Getting a movie quotes

import { Client } from "the-lord-of-the-rings-api-ts-sdk";

const client = new Client({ auth: ACCESS_TOKEN });

const quotesRes = await client.getMovieQuotes({ movieId: movieRes._id });

if (!('docs' in quotesRes)) {
    throw new Error('No movies to list');
}

const quotes = quotesRes.docs;

Sorting

Pass the sort parameter to the queryParameters method to sort the results.

import { Client } from "the-lord-of-the-rings-api-ts-sdk";
    
const client = new Client({ auth: ACCESS_TOKEN });

    
const moviesRes = await client.listMovies({ sort: 'name:desc' });

Filtering

Filter results by passing the value to any available key parameter to the queryParameters.

import { Client } from "the-lord-of-the-rings-api-ts-sdk";
    
const client = new Client({ auth: ACCESS_TOKEN });

    
const moviesRes = await client.listMovies({ name: 'hobbit' });

Pagination

You can paginate results by passing the limit, page and offset parameter to the queryParameters method.

import { Client } from "the-lord-of-the-rings-api-ts-sdk";
    
const client = new Client({ auth: ACCESS_TOKEN });

const moviesRes = await client.listMovies({
    queryParameters: { page: '2', offset: '3' },
});

Contributing

Live development

npm run build:watch

Building

npm run build

Testing

npm run test