Jikan API wrapper for TypeScript and Node.js with built-in typing.
- 💅 Fully typed
- ♻ Built-in in-memory response cache (TTL-based)
- 📄 Request logging
- 📦 ESM with tree shaking support
npm install @tutkli/jikan-ts kyIf you want to use the types and endpoint constants to build your own HTTP client:
npm install @tutkli/jikan-tsimport type { Anime, JikanResponse } from '@tutkli/jikan-ts/types'
import { AnimeEndpoints, BASE_URL } from '@tutkli/jikan-ts/types'
// Build your own HTTP client using the provided types and endpoints
const response = await fetch(
`${BASE_URL}${AnimeEndpoints.AnimeById.replace('{id}', '1')}`
)
const data: JikanResponse<Anime> = await response.json()import { AnimeClient, JikanResponse, Anime } from '@tutkli/jikan-ts'
const animeClient = new AnimeClient()
animeClient.getAnimeById(1).then((response: JikanResponse<Anime>) => {
/* ... */
})import { JikanClient, JikanResponse, Anime } from '@tutkli/jikan-ts'
const jikanClient = new JikanClient()
jikanClient.anime.getAnimeById(1).then((response: JikanResponse<Anime>) => {
/* ... */
})Jikan-ts uses a built-in in-memory cache with TTL-based expiry (default: 5 minutes).
To customize the cache, pass the cacheOptions argument when instantiating a client:
import { AnimeClient } from '@tutkli/jikan-ts'
const animeClient = new AnimeClient({
cacheOptions: { ttl: 10 * 60 * 1000 } // 10 minutes
})Jikan-ts uses Ky as its HTTP client. You can provide your own Ky instance via the optional kyInstance argument:
import { AnimeClient } from '@tutkli/jikan-ts'
import ky from 'ky'
const animeClient = new AnimeClient({
kyInstance: ky.create({
/* ... */
})
})To enable logging, pass the enableLogging argument as true.
import { AnimeClient } from '@tutkli/jikan-ts'
const animeClient = new AnimeClient({
enableLogging: true
})- Did you find this project useful? Leave a ⭐
- Found a problem? Create an issue 🔎
- Want to contribute? Submit a PR 📑
