1.0.4 • Published 2 years ago

codemask-lotr-sdk v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

SDK for Lord-of-the-Ring API

This SDK provides easy access to the Lord of the Rings API endpoints for movies and quotes.

Documentation

The official documentation for The Lord-of-the-Ring API can be found here

This SDK library currently supports the Movie and Quote endpoints:

  • /movie
  • /movie/{id}
  • /movie/{id}/quote
  • /quote
  • /quote/{id}

Installation

Install the sdk library with npm

npm install codemask-lotr-sdk

Usage/Examples

To use the SDK, import the LotrSDK function and initialize by passing the following configuration parameters:

The following parameters are accepted:

apiToken (Required): The API access token. You must create an account to get a valid token.

baseURL (Optional): The Default base URL is https://the-one-api.dev/v2. It's subject to change from time to time, please check the main site.

Example Usage with javascript/typescript

import { LotrSDK } from '@codemask-lotr-sdk';

const sdk = new LotrSDK({
  apiToken: 'YOUR_API_TOKEN'
});


// retrieve all movies
const allMovies = sdk.movies.getAllMovies();

console.log(allMovies);

// retrieve all quotes
const allQuotes = sdk.quotes.getAllQuotes()

console.log(allQuotes);

Available Methods

The SDK provides the following methods for interacting with the LOTR API:

Movies API methods

  • To retrieve all movies

    movie.getAllMovies(queryOptions?: QueryOptions)

  • To retrieve a single movie by ID

    movie.getMovieById(id: string, queryOptions?: QueryOptions)

  • To retrieve movie quotes by the movie ID.

    movie.getMovieQuotes(id: string, queryOptions?: QueryOptions)

Quotes API methods

  • To retrieve all quotes.

    quote.getAllQuotes(queryOptions?: QueryOptions)

  • To retrieve a quote by its ID.

    quote.getQuoteById(id: string, queryOptions?: QueryOptions)

Running Tests

To run tests, run the following command

  npm run test
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago