1.1.1 • Published 11 months ago

@w3tsadev/lotr-sdk v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Lord of the Rings SDK

A simple Javascript SDK for the One API.

Installation

npm i @w3tsadev/lotr-sdk

Authentication

To use ALL the features of the LOTR SDK, you need to provide an accessToken. That token is available for free on the One API website once you sign up.

Quick Start

const LOTR = require('@w3tsadev/lotr-sdk');

const client = new LOTR('<YOUR_ACCESS_TOKEN>');

client.movie
  .list({ limit: 2 })
  .then((movies) => console.log(movies))
  .catch((err) => console.error(err));

That's it!

Usage

The SDK models the One API and each property from the SDK matches a section in the API documentation.

Examples

To list all movies:

const LOTR = require('@w3tsadev/lotr-sdk');

const client = new LOTR('<YOUR_ACCESS_TOKEN>');

client.movie
  .list()
  .then((movies) => console.log(movies))
  .catch((err) => console.error(err));

To get a single movie by id:

const LOTR = require('@w3tsadev/lotr-sdk');

const client = new LOTR('<YOUR_ACCESS_TOKEN>');

client.movie
  .get('movie_id')
  .then((movie) => console.log(movie))
  .catch((err) => console.error(err));

To get a quotes by a movie, with sorting and filtering:

import LOTR from '@ajejoseph22/lotr-sdk';

const client = new LOTR('<YOUR_ACCESS_TOKEN>');

client.quote
  .getQuotesByCharacter('<character_id>', {
    limit: 2,
    page: 2,
    sort: {
      character: 'asc',
    },
    filter: {
      excludes: {
        dialog: ["I didn't think it would end this way."],
      },
      propertyExists: 'character',
      isEqualTo: {
        movie: '5cd95395de30eff6ebccde5d',
      },
    },
  })
  .then((quotes) => {
    // handle data
  })
  .catch((e) => {
    // handle error
  });
1.1.1

11 months ago

1.1.0

11 months ago

1.0.0

11 months ago