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 🙏

© 2024 – Pkg Stats / Ryan Hefner

daniel-lee-lotr-sdk

v1.0.2

Published

SDK wrapper in javascript for the one lotr api :)

Downloads

3

Readme

The Lord Of The Rings SDK

Installation

npm install daniel-lee-lotr-sdk

Initialization

import { LotrSdk } from 'daniel-lee-lotr-sdk';

const sdk = new LotrSdk(<YOUR_ACCESS_TOKEN_STRING>);

Usage

The following data outlined within the LOTR API can be fetched directly from the sdk client:

  • books
  • movies
  • characters
  • quotes
  • chapters

To fetch all items of a particular item type:

sdk.<ITEM_TYPE>.getAll()

/* EXAMPLE */
const books = await sdk.books.getAll()

To fetch a single item by id:

sdk.<ITEM_TYPE>.getOneById(<ID>)

/* EXAMPLE */
const character = await sdk.characters.getOneById('5cd99d4bde30eff6ebccfc15')

The following item types also have additional methods:

Books

  • Fetch all chapters of a specific book by ID

sdk.books.getAllChapters(<BOOK_ID>)

Quotes

  • Fetch all quotes from a specific movie by ID

sdk.quotes.getAllQuotesFromMovie(<MOVIE_ID>)

  • Fetch all quotes from a specific character by ID

sdk.quotes.getAllQuotesFromCharacter(<CHARACTER_ID>)

Query Parameters

As outlined in the LOTR API, there are also options for sorting, pagination, and filtering. For each endpoint, you may also pass in a params object to denote any special query parameters you desire.

Example

sdk.quotes.getAll({
    limit: 30,
    page: 2,
    offset: 4
  })

The interface of the params object is as follows

{
  /* PAGINATION */
  limit: number
  page: number
  offset: number
  /* SORTING */
  sort: string 
  /* FILTERING */
  filters: string
}

Sorting

For the sort parameter, the string should be formatted like the following

{
  ...
  sort: <VALUE>:<'asc' or 'dsc'>
}

Where asc and dsc denotes either ascending or descending order respectively. Example:

const charactersInAlphabeticalOrder = await sdk.characters.getAll({
    sort: "name:asc"
  })

Filtering

For the filters parameter, you may utilize the FiltersBuilder builder class that will generate a query string denoting your filters. The FiltersBuilder class contains the following methods:

includes(key,value)
excludes(key,value)
exists(key)
doesNotExist(key)
lessThan(key,value,equalTo) // equalTo should be a boolean value denoting if the comparison should be inclusive
greaterThan(key,value,equalTo)

NOTE: The includes(key,value) and excludes(key,value) methods can take either a single string, CSV, or regex. These methods roll the match, include, and regex filters into one method.

Example:

const allNonMaiarMaleCharacters = await sdk.charcters.getAll({
    filters: new FiltersBuilder()
      .includes("gender","Male")
      .excludes("race","Maiar)
      .build()
  })

Rate Limit

There is currently a rate limit of 100 request per 10 minutes. Please keep that in mind as you play around :)