@djuk1csrdjan/lotr-sdk

1.0.2 • Public • Published

LotrSDK

SDK for The One API

Prerequisites

You will need to obtain a APIKey from The One API Clicking here takes you to dev sign up!

Installation:

npm install @djuk1csrdjan/lotr-sdk

Get started:

import LotrSDK from '@djuk1csrdjan/lotr-sdk';
const sdkInstance = new LotrSDK('YOUR_API_KEY');

Quick mention that The One API has Limited usage to 100r/10min

Supported Endpoints

  • Movies

  • Quotes

    SDK methods for these endpoints:

  • getAllMovies(qOptions) - qOptions representing a filter

  • getMovieById(id) - id - id of a movie

  • getMovieQuites(id, qOptions) - id - id of a movie, qOptions representing a filter

  • getAllQuotes(qOptions) - qOptions representing a filter

  • getQuoteById(id) - id - id of a quote

Filter

Filter is a JS object, you can form it like following:

{
    paging: {
        limit: 3,
        page: 1,
        offset: 2
    },
    sort: {
        fieldName: 'character',
        direction: 'desc' | 'asc'
    },
    filters: {
        regularFilters: [
            {
                character: ['5cd99d4bde30eff6ebccfd0d'], //multiple (race: ['Orc','Human','Hobbit'])
                operation: '='
            }
        ],
        fieldExistsFilters : ['name', '!chapterName']
    }
}

Method examples

All quotes:

sdkInstance.getAllQuotes();

Movie by id:

sdkInstance.getMovieById('5cd95395de30eff6ebccde5d');

Pagination example

sdkInstance.getAllQuotes({
    paging: {
        limit: 5,
        page: 2
    }
});

Sorting example

sdkInstance.getAllQuotes({
    sort: {
        fieldName: 'character',
        direction: 'desc'
    }
});

Filtering example

sdkInstance.getAllMovies({
    filters: {
        regularFilters : [
            {
                budgetInMillions: [94],
                operation: '<' 
            },
            {
                academyAwardWins: [3],
                operation: '>='
            }
        ],
    }
})

Readme

Keywords

Package Sidebar

Install

npm i @djuk1csrdjan/lotr-sdk

Weekly Downloads

1

Version

1.0.2

License

UNLICENSED

Unpacked Size

11.8 kB

Total Files

8

Last publish

Collaborators

  • djuk1csrdjan