Skip to content

Jikan API wrapper for Typescript and NodeJS with built in typings.

License

Notifications You must be signed in to change notification settings

tutkli/jikan-ts

Repository files navigation

jikan-ts

jikan-ts-890w

Language Shield GitHub License Code Style Shield NPM Downloads npm bundle size

Jikan API wrapper for TypeScript and Node.js with built-in typing.

Features

  • πŸ’… Fully typed
  • β™» Http Request Cache
  • πŸ“„ Logging
  • πŸ“¦ ESM with tree shaking support

Installation

npm install --save @tutkli/jikan-ts axios axios-cache-interceptor
# or
yarn add @tutkli/jikan-ts axios axios-cache-interceptor

Example

Using a specific client, like AnimeClient:

import { AnimeClient, JikanResponse, Anime } from '@tutkli/jikan-ts';

const animeClient = new AnimeClient();

animeClient
  .getAnimeById(1)
  .then((response: JikanResponse<Anime>) => {
    /* ... */
  })

Or, using the JikanClient:

import { JikanClient, JikanResponse, Anime } from '@tutkli/jikan-ts';

const jikanClient = new JikanClient();

jikanClient.anime
  .getAnimeById(1)
  .then((response: JikanResponse<Anime>) => {
    /* ... */
  })

Client configuration

Cache Configuration

Jikan-ts uses axios-cache-interceptor to store request results. To use a specific configuration, pass the cacheOptions argument when instantiating a client:

import { AnimeClient } from '@tutkli/jikan-ts';

const animeClient = new AnimeClient({
    cacheOptions: { ... } // axios-cache-interceptor options
  }
);

Custom Axios Instance

Jikan uses axios as an http client and if you are not satisfied with the default client settings, then you can build your instance by passing it to the optional axiosInstance argument

import { AnimeClient } from '@tutkli/jikan-ts';
import Axios from 'axios';

const animeClient = new AnimeClient({
    axiosInstance: Axios.create({ ... })
  }
);

For more information, check out the axios-cache-interceptor Documentation.

Logging

To enable logging, pass the enableLogging argument as true.

import { AnimeClient } from '@tutkli/jikan-ts';

const animeClient = new AnimeClient({
  enableLogging: true,
});

Available Clients

Client Status
AnimeClient βœ… Supported
CharactersClient βœ… Supported
ClubsClient βœ… Supported
GenresClient βœ… Supported
MagazinesClient βœ… Supported
MangaClient βœ… Supported
PeopleClient ❌ Upcoming
ProducersClient ❌ Upcoming
RandomClient βœ… Supported
RecommendationsClient ❌ Upcoming
ReviewsClient ❌ Upcoming
SchedulesClient βœ… Supported
UsersClient ❌ Upcoming
SeasonsClient βœ… Supported
TopClient βœ… Supported
WatchClient βœ… Supported
JikanClient (Main client) βœ… Supported

Leave you feedback