@dvcol/simkl-http-client
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

@dvcol/simkl-http-client

donate

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

Documentation

See Simkl API documentation for more information.

Author

📝 License

This project is MIT licensed.

Package Sidebar

Install

npm i @dvcol/simkl-http-client

Weekly Downloads

9

Version

1.1.8

License

MIT

Unpacked Size

437 kB

Total Files

218

Last publish

Collaborators

  • dvcol