1.0.4 • Published 3 years ago

@ypcorp/lotr-api v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@ypcorp/lotr-api

Allows access to Lord of the Ring information through The One API

Using

Requirements

Usage

Install the dependency

  • npm: npm install @ypcorp/lotr-api --save
  • yarn: yarn add @ypcorp/lotr-api

Example:

import { getSettings, listMovies } from "@ypcorp/lotr-api";

async function run() {
  const settings = getSettings({ accessToken: "YOUR_ACCESS_TOKEN" });
  console.log(await listMovies(settings));
}

run()
  .then(() => console.log("finished"))
  .catch((e) => console.error("error", e));

Replace the YOUR_ACCESS_TOKEN string and run the file

If you can't use EcmaScript modules, use the import function instead of require

async function run() {
  const { getSettings, listMovies } = await import("@ypcorp/lotr-api");

  const settings = getSettings({ accessToken: "DkR4mHZduv_aB5F8gMsi" });
  console.log(await listMovies(settings));
}

run()
  .then(() => console.log("finished"))
  .catch((e) => console.error("error", e));

Methods

  • getSettings(params)
    • params properties
      • accessToken - required - API access token
      • timeout - request timeout in milliseconds - default 5 seconds
  • listBooks(settings)
  • getBook(settings, bookId)
  • listChapters(settings)
  • getChapter(settings, chapterId)
  • listCharacters(settings)
  • getCharacter(settings, charaterId)
  • listMovies(settings)
  • getMovie(settings, movieId)
  • listQuotes(settings)
  • getQuote(settings, quoteId)

Development

Design file

Dependencies

  • Node 16.10 or superior
  • Yarn 1

Setup

# required for yarn - https://yarnpkg.com/getting-started/install#nodejs-1610
corepack enable

yarn install

Tests

To run the tests, you need to set the ACCESS_TOKEN environment variable

ACCESS_TOKEN=YOUR_ACCESS_TOKEN yarn test
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago