2.0.1 • Published 1 year ago
kaseris_anastasios-sdk v2.0.1
SDK Wrapper for TheOneAPI
This SDK access The One API and exports the functionality for querying the following endpoints:
- /movie
- /movie/{id}
- /movie/{id}/quote
Requirements
Installation
npm i kaseris_anastasios-sdk
Usage
In order to access the api you will need a token from The One API by signing up. Once you acquire a token you can use it as follows:
Add to your code:
import { initOneSDK } from "kaseris_anastasios-sdk";
const oneSDK = initOneSDK("YOUR_TOKEN");
// Example calls
const movies = await oneSDK.movies().getAll();
const movies = await oneSDK
.movies()
.with("budgetInMillions", "<", 200)
.getAll();
const movie = await oneSDK.movie("id").get();
const quotes = await oneSDK.movie("id").quotes().sort("dialog", "asc").get();
Available response manipulation:
// Limit
.limit(n: number)
// Page
.page(n: number)
// Offset
.offset(n: number)
// Sorting
.sort(field: string, order: "asc" | "desc")
// Comparison
.with(field: string, op: "==" | "!=" | ">" | "<" | ">=" | "<=" | "in" | "not in", value: any)
// Existence
.exists(field: string)
.notExists(field: string)
Tests
For tests the jest packages is being used. In order to run the tests:
- Go to the root folder of this repo's directory
- Export env variable with your token
export "ONE_API_TOKEN"="YOUR_TOKEN"
3.
npm i
3.
npm test