To install a SDK, simply run the following command
npm install the-one-sdk-sbm
You need to set up an access token at: https://the-one-api.dev/account
You can use mine, but keep it a secret 🤫: SQb886IdnjD6GPZB3FsH
then import and initialize an instance of the SDK on your code:
import {TheOne} from 'the-one-sdk-sbm'
const TheOneSDK = new TheOne(access_token)
const page = 1
const result = await TheOneSDK.movies.list(page)
//You can iterate through all movies on the paginator or access the pagination information.
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.movies.forEach((movie) => console.log(movie.name)) //print all movie names
You can also filter the list by any attribute of the movie
const page = 1
const result = await TheOneSDK.movies.list(page,
{
attr: 'budgetInMillions',
operator: '>=',
value:'200'
}, {
attr: 'name',
operator: 'contains',
value: 'Lord'
})
const movieId = "5cd95395de30eff6ebccde5b"
const movie = await TheOneSDK.movies.get(movieId)
console.log(movie.name)
const movieId = "5cd95395de30eff6ebccde5b"
const page = 1
const result = await TheOneSDK.movies.getQuotes(movieId, page)
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes
const page = 1
const result = await TheOneSDK.quotes.list(page)
//the result structure is the same than when getting a list of quotes for a movie
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes
You can also filter the list by any attribute of the quote
const page = 1
const result = await TheOneSDK.quotes.list(page,
{
attr: 'dialog',
operator: 'notContains',
value:'Ring'
})
const quoteId = "5cd96e05de30eff6ebcce9ba"
const quote = await TheOneSDK.quotes.get(quoteId)
console.log(quote.dialog)
Movie = {
_id: string,
name: string,
runtimeInMinutes: number,
budgetInMillions: number,
boxOfficeRevenueInMillions: number,
academyAwardNominations: number,
academyAwardWins: number,
rottenTomatoesScore: number,
}
MovieQuote = {
_id: number,
dialog: string,
movie: string,
character: string,
}
Paginator = {
total: number,
results: number,
limit: number,
offset: number,
page: number,
pages: number
}
MovieQuotePaginator = {
quotes: MovieQuote[],
paginator: Paginator
}
MoviePaginator = {
movies: Movie[],
paginator: Paginator
}
Filter = {
attr: string,
operator: '=' | '!=' | '<' | '<=' | '>' | '>=' | 'contains' | 'notContains'
value: any
}