@desaisamir/lotr-sdk
v1.0.3
Published
SDK for the Lord of the Rings API.
Readme
Lord of the Rings SDK
This is an SDK for the Lord of the Rings API, providing easy access to movie and quote data.
Installation
To install the Lord of the Rings SDK, you can use npm:
npm install @desaisamir/lotr-sdkUsage
To use the SDK in your Node.js application, follow these steps:
Import the SDK:
const sdk = require('@desaisamir/lotr-sdk');Set up your environment variables:
Create a .env file in the root of your project and populate it with the following content. There is template .env-example file provided in the root of your project.
ACCESS_TOKEN=YOUR_ACCESS_TOKEN
BASE_API_URL=https://the-one-api.dev/v2Replace YOUR_ACCESS_TOKEN with your actual access token for the Lord of the Rings API. If you do not have ACCESS_TOKEN you can obtain access key once you sign up.
Call the desired functions from the SDK:
// Get the list of movies
const movies = await sdk.getMovies();
console.log(movies);
// Get a specific movie by ID
const movieId = '5cd95395de30eff6ebccde56';
const movie = await sdk.getMovieById(movieId);
console.log(movie);
// Get quotes by movie ID
const quotes = await sdk.getQuotesByMovieId(movieId);
console.log(quotes);
// Get the list of quotes
const allQuotes = await sdk.getQuotes();
console.log(allQuotes);
// Get a specific quote by ID
const quoteId = '5cd96e05de30eff6ebcce7a1';
const quote = await sdk.getQuoteById(quoteId);
console.log(quote);That's it! You can now make use of the Lord of the Rings SDK in your application.
Make sure to handle any errors that may occur during API requests and follow best practices when integrating the SDK into your codebase.
Testing
To run the tests for the SDK, you can use the following command:
npm testMake sure to set up your environment properly before running the tests.
