# rett-behrens-lotr-sdk

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

Latest version **0.1.0** (published 2023-05-11) · 0 weekly downloads

## Install

```sh
npm install rett-behrens-lotr-sdk
pnpm add rett-behrens-lotr-sdk
yarn add rett-behrens-lotr-sdk
bun add rett-behrens-lotr-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-05-11 |
| First published | 2023-05-11 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 78.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rett Behrens |
| Maintainers | rett.behrens |

## Links

- npm: https://www.npmjs.com/package/rett-behrens-lotr-sdk
- Repository: https://github.com/RettBehrens/rett_behrens_lotr_sdk
- Homepage: https://github.com/RettBehrens/rett_behrens_lotr_sdk#readme
- Issues: https://github.com/RettBehrens/rett_behrens_lotr_sdk/issues
- npm.io page: https://npm.io/package/rett-behrens-lotr-sdk

## Dependencies (1)

- [request](https://npm.io/package/request.md) ^2.88.2

## Recent versions

- 0.1.0 (latest) — 2023-05-11

## README

# Rett Behrens LOTR SDK

This SDK makes it easy for developers to consume information about the LOTR series via the [LOTR API](https://the-one-api.dev/).

# Table of Contents
- [SDK Installation](#sdk-installation)
- [Getting Started](#getting-started)
- [Available Methods](#available-methods)
- [Usage](#usage)

## 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](https://the-one-api.dev/sign-up). Upon sign up you will be presented with an access token. You can also revisit your [account page](https://the-one-api.dev/account) 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
```js
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);
})();
```

---
_Source: https://npm.io/package/rett-behrens-lotr-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
