lotr-sdk-jordan-hammond
v1.0.2
Published
SDK for the LOTR API
Downloads
1
Readme
Lord of the Rings SDK
Installation
- Get your access token from here.
- Go into your JS application. Note: you will need to have a
package.json
file. npm install lotr-sdk-jordan-hammond
- Start using it. You can see how below.
Examples
- Video walkthrough: https://www.loom.com/share/ae6241be562d401aa0ece9e8b6dea4fd
- You can also find an example in
/examples/app.js
Usage
Basic usage
const lotrSdk = require('lotr-sdk-jordan-hammond');
async function main() {
try {
const client = lotrSdk('YOUR_API_TOKEN');
const movies = await client.getMovies();
console.log(movies);
} catch (error) {
console.error(error);
}
}
main();
Initialization
const lotrSdk = require('lotr-sdk-jordan-hammond');
const client = lotrSdk('YOUR_API_TOKEN');
getMovies()
Fetches an array of all the movies from the API.
Example Usage:
const movies = await client.getMovies();
Example Return:
[
// ... Additional movie objects ...
{
"_id": "5cd95395de30eff6ebccde5c",
"name": "The Fellowship of the Ring",
"runtimeInMinutes": 178,
"budgetInMillions": 93,
"boxOfficeRevenueInMillions": 871.5,
"academyAwardNominations": 13,
"academyAwardWins": 4,
"rottenTomatoesScore": 91
},
// ... Additional movie objects ...
]
getMovie(movieId)
Fetches data for a specific movie by its ID.
Example Usage:
const movie = await client.getMovie('5cd95395de30eff6ebccde5b');
Example Return:
{
"_id": "5cd95395de30eff6ebccde5b",
"name": "The Two Towers",
"runtimeInMinutes": 179,
"budgetInMillions": 94,
"boxOfficeRevenueInMillions": 926,
"academyAwardNominations": 6,
"academyAwardWins": 2,
"rottenTomatoesScore": 96
}
getMovieQuotes(movieId)
Fetches all quotes from a specific movie by its ID.
Example Usage:
const quotes = await client.getMovieQuotes('5cd95395de30eff6ebccde5b');`
Example Return:
[
// ... Additional quote objects ...
{
"_id": "5cd96e05de30eff6ebcce84a",
"dialog": "My dear Sam, you cannot always be torn in two...",
"movie": "5cd95395de30eff6ebccde5d",
"character": "5cd99d4bde30eff6ebccfc15"
},
// ... Additional quote objects ...
]
getQuotes()
Fetches an array of all the quotes from the API.
Example Usage:
const quotes = await client.getQuotes();
Example Return:
[
// ... Additional quote objects ...
{
"_id": "5cd96e05de30eff6ebcce84c",
"dialog": "I didn't think it would end this way.",
"movie": "5cd95395de30eff6ebccde5d",
"character": "5cd99d4bde30eff6ebccfe2e"
},
// ... Additional quote objects ...
]
getQuote(quoteId)
Fetches data for a specific quote by its ID.
Example Usage:
const quote = await client.getQuote('5cd96e05de30eff6ebcce84c');
Example Return:
{
"_id": "5cd96e05de30eff6ebcce84c",
"dialog": "I didn't think it would end this way.",
"movie": "5cd95395de30eff6ebccde5d",
"character": "5cd99d4bde30eff6ebccfe2e"
}