@djuk1csrdjan/lotr-sdk
v1.0.2
Published
JS SDK for The One API
Downloads
10
Readme
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 filtergetMovieById(id)
- id - id of a moviegetMovieQuites(id, qOptions)
- id - id of a movie, qOptions representing a filtergetAllQuotes(qOptions)
- qOptions representing a filtergetQuoteById(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: '>='
}
],
}
})