1.0.2 • Published 10 months ago

@djuk1csrdjan/lotr-sdk v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
10 months ago

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: '>='
            }
        ],
    }
})
1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago