the-one-api-sdk-jmedi116
v1.0.1
Published
An SDK around the The One API to rule them all.
Downloads
5
Readme
Lord of the Rings SDK
The Lord of the Rings is a JavaScript SDK built on Node.js. It interacts with The One API (https://the-one-api.dev/) and provides easy-to-use methods to fetch data about movies, including characters and movie quotes.
Installation
You can install the sdk with npm:
npm i the-one-api-sdk-jmedi116
Usage
First, you need to require the SDK and create an instance, providing your API token:
const LotRSDK = require('the-one-api-sdk-jmedi116');
const sdk = new LotRSDK('your_token');
Then, you can use the methods of the SDK to fetch data:
// Fetch all LotR movies
sdk.getMovies().then(movies => {
console.log(movies);
}).catch(error => {
console.error(error);
});
// Fetch a specific LotR movie by ID
sdk.getMovieById(1).then(movie => {
console.log(movie);
}).catch(error => {
console.error(error);
});
// Fetch movie quotes for a specific LotR movie
sdk.getMovieQuotes(1).then(quotes => {
console.log(quotes);
}).catch(error => {
console.error(error);
});
Parameters
The parameters you can provide to the methods are:
limit: The maximum number of results to return.
page: The page number when paginating the results.
offset: The number of results to skip before starting to return results.
sort: The sorting order of the results.
filters: An object specifying filters to apply to the results.
Errors
If an error occurs while making a request, the SDK will throw an error. Make sure to handle these errors in your code.
Testing
You can run the unit tests for this SDK with:
npm test