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

haryells-lotr-sdk

v1.0.0

Published

Lord of the Rings SDK

Downloads

5

Readme

Lord of the Rings SDK

Overview

Lord of the Rings SDK is a easy way to conume the resources from the The One API from wherever Node application you are working on.


Instalation

To install this SDK on your project just run the following command:

npm i @haryells/lotr-sdk

Example usage

// Import the lib
const TOAClient = required('@haryells/lotr-sdk');

// Initialize the client passing your customer token from The One API. Follow this documentation to get one token: (https://the-one-api.dev/documentation#3)
const client = new TOAClient("YOUR_THE_ONE_API_TOKEN");

// Call the listMovies method to get all movies from the API.
const response = await client.listMovies();

// Extract the movies from the response
const movies = response.docs;

Getting Started

Before you start to use the SDK, please make sure you have a Access token from The One API. Please follow the documentation to get one.

Methods

.listMovies()

Return all the movies from the API. It can be paginated and filtered though params.

INPUT PARAMETERS | param | required | type | description | |---|---|---|---| | options | false | Object | Options to be used when get the list of the movies. | | options.limit | false | Integer | Number of results to be returned. The default value will only be used if the param page is informed. Default value: 0. | | options.page | false | Integer | Number of the page to be returned. The default value will only be used if the param limit is informed. Default value: 1 | | options.search | false | Array | List of search objects, used to filter the movies to be returned. More information about search options see this documentation | | options.search.field | false | String | Field to be filtered. | | options.search.operation | false | String | The filter operation. Possible values: =, !=, >, <, >=, <=, exists and !exists. | | options.serach.value | false | String | The filtered value. |

.getMovieById()

Return the movie data by it's Id.

INPUT PARAMETERS | param | required | type | description | |---|---|---|---| | id | true | String | The Id of the movie. |

.listQuotesByMovieId()

List all quotes from a movie. You can paginate the result using the params.

INPUT PARAMETERS | param | required | type | description | |---|---|---|---| | movieId | true | String | The ID of the movie. | options | false | Object | Options to be used when get the list of the quotes. | | options.limit | false | Integer | Number of results to be returned. The default value will only be used if the param page is informed. Default value: 0. | | options.page | false | Integer | Number of the page to be returned. The default value will only be used if the param limit is informed. Default value: 1 |

.listQuotes()

List all quotes from all movies. You can paginate and filter the result using the params.

INPUT PARAMETERS | param | required | type | description | |---|---|---|---| | options | false | Object | Options to be used when get the list of the quotes. | | options.limit | false | Integer | Number of results to be returned. The default value will only be used if the param page is informed. Default value: 0. | | options.page | false | Integer | Number of the page to be returned. The default value will only be used if the param limit is informed. Default value: 1 | | options.search | false | Array | List of search object, used to filter the quotes to be returned. More information about search options see this documentation | | options.search.field | false | String | Field to be filtered. | | options.search.operation | false | String | The filter operation. Possible values: =, !=, >, <, >=, <=, exists and !exists. | | options.serach.value | false | String | The filtered value. |

.getQuoteById()

Return de details of a Quote by it's ID.

INPUT PARAMETERS | param | required | type | description | |---|---|---|---| | id | true | String | The Id of the Quote. |


Responses

The response object are the default response from the API tha follows the uppcomming pattern:

{
    "docs": [
        ...
    ], // Object(s) returned for the request, it is alwas an Array of Objects, even when calling to get an registry by it ID.
    "total": 1, // Total of registers founds
    "limit": 1000, // Max of registers returneds
    "offset": 0, // Registers skippeds, for pagination purpose.
    "page": 1, // Current page returned.
    "pages": 1 // Total of pages.
}

Error

The SDK throw exception errors with if there is missing params or if there is API problems. If you wan't you can treat this errors with try {} catch() {};:

// Import the lib
const TOAClient = required('@haryells/lotr-sdk');
try {
    // Initialize the client without a token.
    const client = new TOAClient();
} catch (error) {
    // It will throw a error with the message "Token is required.".
}

Test

To run the unit test first go to the file ./test/TOAClient.test.js and place your Access Token from the The One API in the line 2:

const token = null; // Place your The One API Token here

Then run the command to start the test:

npm run test

License

ISC