Typescript SDK for LOTR API
npm i evan-sutherland-sdk
// non-authenticated sdk
const sdk = createSDK()
// authenticated sdk
const sdk = createSDK({
apiKey: "<API_KEY>"
})
non-authenticated sdk can access
- booksApi
authenticated sdk can access
- booksApi
- charactersApi
- moviesApi
- quotesApi
get your API key here
const { books } = createSDK()
books.getBooks({
limit: 5,
page: 3,
offset: 0
})
const { books } = createSDK()
const response = books.getBooks()
response.docs // BookResponse[]
response.limit // number,
response.offset // number,
response.page // number,
response.pages // number,
response.total // number,
Any key (aside from _id
) of the underlying type can be sorted asc or desc
const { books } = createSDK()
books.getBooks({
sort: 'name: asc'
})
Any key (aside from _id
) can be filtered in one of many ways. Each filter operation takes an array, so multiple keys can filtered. Each member of the array is either the single key (exists
& notExists
) or a tuple of the key and the search term or search terms.
const { books } = createSDK()
books.getBooks({
filter: {
match: [FilterableKeys<T>, string][],
negate: [FilterableKeys<T>, string][],
include: [FilterableKeys<T>, string[]][],
exclude: [FilterableKeys<T>, string[]][],
exists: FilterableKeys<T>[],
notExists: FilterableKeys<T>[],
regex: [FilterableKeys<T>, RegExp | string][],
lessThan: [FilterableKeys<T>, number][],
lessThanOrEqual: [FilterableKeys<T>, number][],
greaterThan: [FilterableKeys<T>, number][],
greaterThanOrEqual: [FilterableKeys<T>, number][],
}
})
This project uses vite
npm run build
This project uses jest
npm run test
Ensure correct node version with nvm
nvm use
Install dependencies
npm ci
Run build with watcher
npm run dev