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

rett-behrens-lotr-sdk

v0.1.0

Published

One API to rule them all - LibLab take home project - The Lord of the Rings SDK - NodeJS client

Downloads

4

Readme

Rett Behrens LOTR SDK

This SDK makes it easy for developers to consume information about the LOTR series via the LOTR API.

Table of Contents

SDK Installation

To install this SDK in your project:

npm install rett-behrens-lotr-sdk

Getting Started

The LOTR API rquires a valid access token in order to make API requests to the server. To obtain an access token sign up for a LOTR API user account. Upon sign up you will be presented with an access token. You can also revisit your account page to retrieve your access token at any time. Add the access token to your project evironment variables file so you can reference this key securely in your project code.

LOTR_TOKEN = "xxxxxxxuxxxxxxxxxx-x"

Available Methods

| method | description | | --- | --- | | getMovies() | Returns a list of all movies, including the "The Lord of the Rings" and the "The Hobbit" trilogies | | getMovieById(id) | Returns the specified movie | | getQuotes() | Returns a list of all movie quotes | | getQuoteById(id) | Returns the specified quote | | getQuotesByMovieId(id) | Returns all movie quotes for one specific movie (only working for the LotR trilogy) |

Usage

require('dotenv').config()
const lotr = require('rett_behrens_lotr_sdk');
(async () => {
    // instatiating API client
    const moviesAPI = new lotr.MoviesApi()
    const quotesAPI = new lotr.QuotesApi();

    // setting your access token to the API client
    moviesAPI.accessToken = process.env.LOTR_TOKEN;
    quotesAPI.accessToken = process.env.LOTR_TOKEN;

    // GET all movies
    const movies = await moviesAPI.getMovies();
    console.log(movies.body);

    // quotes will only work for the LotR trilogy, so we're filtering here
    const movieId = movies.body.docs.filter(movie => movie.name == 'The Fellowship of the Ring')[0].id;
    console.log(movieId);

    // GET a specific movie by ID 
    const movie = await moviesAPI.getMovieById(movieId);
    console.log(movie.body);

    // GET all quotes
    const quotes = await quotesAPI.getQuotes();
    console.log(quotes.body);

    // In The Hobbit, the approximate distance traveled by Bilbo and his companions to Rivendell was 397 miles. It took them 38 days to get there.
    // GET a specific quote by ID
    const quote = await quotesAPI.getQuoteById(quotes.body.docs[397].id);
    console.log(quote.body);

    // GET quotes from specific movie
    const quotesFromTFOTR = await quotesAPI.getQuotesByMovieId(movieId);
    console.log(quotesFromTFOTR.body);
})();