@dvcol/simkl-http-client
v1.1.8
Published
Simple fetch based http client for Simkl API with full typescript support (request and response)
Downloads
248
Maintainers
Readme
Simple fetch based http client for Simkl API with full typescript support (request and response).
Prerequisites
- pnpm >=9.0.0
- node >=20.0.0
Install
pnpm install
Usage
pnpm add @dvcol/simkl-http-client
Modular endpoint bundling
Simkl-http-client is designed to be modular and flexible. Although it uses static classes, endpoints are instantiated at runtime and can be easily omitted, extended or overridden. If your bundler does not support tree-shaking, you can omit unused endpoints by only importing the ones you need.
By default we provide a full api object with all supported endpoints, as well as a minisimkl api object with only the essential authentication endpoints. You can also import any endpoint by common scope.
import { SimklClient } from '@dvcol/simkl-http-client';
import { anime } from '@dvcol/simkl-http-client/api/anime';
import { minimalSimklApi } from '@dvcol/simkl-http-client/api/minimal';
import { search } from '@dvcol/simkl-http-client/api/search';
import { Config } from '@dvcol/simkl-http-client/config';
import type { SimklClientSettings } from '@dvcol/simkl-http-client/models';
const simklUsedApi = {
...minimalSimklApi,
anime,
search
};
const simklClientSettings: SimklClientSettings = {
client_id: '<Your simkl ID>',
client_secret: '<Your simkl secret>',
redirect_uri: '<Your simkl redirect uri>',
endpoint: Config.endpoint,
useragent: '<Your user Agent>',
corsProxy: '<Optional cors Proxy>',
corsPrefix: '<Optional cors Proxy prefix>',
};
const initAuthentication = {}
const simklClient = new SimklClient(simklClientSettings, initAuthentication, simklUsedApi);
Features
- Built-in cache support (per client, endpoint, or query)
- Extensible cache store (in-memory, local storage, etc.)
- Event observer (request, query, auth)
- Built-in cancellation support
- Code redirect authentication
- Device code polling
Documentation
See Simkl API documentation for more information.
Author
- Github: @dvcol
📝 License
This project is MIT licensed.