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

trots-vitalii-sdk

v1.0.1

Published

Lord Of The Rings SDK

Readme

Lord Of The Rings SDK

JavaScript NodeJS

This SDK has been created for a purpose of making a bridge to Lord Of The Rings API. With this SDK you are able to have an access to movies API of LoTR. Simple to install and easy to use.

Requirements

Installation

SDK Initialization

Before use

SDK Methods

Development

Contacts


Requirements

For using all the functionality you will need to register at the API WebSite. After success registration you will have an API key, that will be used for normal work of the SDK.

Installation

First, run the following script in your command line:

npm install trots-vitalii-sdk

SDK Initialization

You have to import SDK to your application and provide following arguments to it:

  • apiKey (key that was retrieved from API)
  • options (optional parameter to set cache and logger)

Options argument is not a requirement. It has two properties

  • cacheTime: Number (time in milliseconds to reset cache)
  • loggerEnabled: Boolean (initialize an SDK with logger)

CommonJS

Common JS SDK initialization example with setting cache reset to 10 seconds and enabling logger:

const { LoTRSdk } = require('trots-vitalii-sdk');

const sdk = LoTRSdk('_YourApiKey', { cacheTime: 10000, loggerEnabled: true });

ES Modules

ES Modules SDK initialization example with disabled logger and no cache:

import { LoTRSdk } from 'trots-vitalii-sdk';

const sdk = LoTRSdk('_YourApiKey', { loggerEnabled: false });

Before use

We recommend enabling the cache as the API has a limit on the number of requests (about 1 request per 6 seconds on average). Note that you will need to initialize SDK at the top level, to use the same scope for all users and share cached responses between them.

SDK methods

SDK is created to make developers life easier. However it is just a layer between developers and API.

Methods

Initialized SDK includes block of functions to operate with movies API of LoTR site.

  • getAllMovies(params);
  • searchMovieByName(name, params);
  • getMovie(id);
  • getQuotesOfMovie(id, params);
import { LoTR } from 'trots-vitalii-sdk';

const sdk = LoTR(apiKey);
sdk.movies.getAllMovies()
   .then((result) => console.log(result));

Params object

Object called params is an optional object and might consist following properties:

  • limit?: number;
  • offset?: number;
  • page?: number;
  • sort?: Array<Array<string, string>>;
  • filters?: Array<Array<string, string, string>>;

Recommendations

  1. Use offset and page properties separately. It's about a pagination concept, choose one to proceed with.

  2. You can use sort property to apply sorting. Not every endpoint supports it, so make sure you are tested such use case in advance. You have to provide an array of arrays to sort, where each nested array has two string elements: field name and direction.

  3. You can use filters property to apply filtering. Not every endpoint supports it, so make sure you are tested such use case in advance. You have to provide an array of arrays to filter, where each nested array has three elements: field name, operator and value(s). Value can be string or array of strings.

Sorting example:

import { LoTRSdk } from 'trots-vitalii-sdk';

const sdk = LoTRSdk(apiKey);
const params = { sort: [['name', 'desc']] };
sdk.movies.getAllMovies(params)
   .then((result) => console.log(result));

Filtering example:

import { LoTRSdk } from 'trots-vitalii-sdk';

const sdk = LoTRSdk(apiKey);
const params = { filters: [['name', '=', 'Return']] };
sdk.movies.getAllMovies(params)
   .then((result) => console.log(result));

Error handling

For making a usage of current SDK more slight and safe we are not returning or throwing any errors from inside of it. In the success scenario you will always have a response. Consider that undefined is a response of failure. To understand a reason of it, please initialize SDK with logger enabled.

Development

Testing

Testing is available for development purpose, you may discover test cases in our GitHub Repository

It's developed with a help of Jest testing framework on a unit, integration and acceptance levels.

For this you will need to install development dependencies first:

npm i

Unit tests To run unit tests, execute following script:

npm run test:unit

Integration tests To run integration tests, execute following script:

npm run test:integration

E2E tests To run e2e tests, execute following script:

npm run test:e2e