Introduction
The AniDojo Anime API provides TypeScript functions for fetching anime data from the Jikan API (MyAnimeList). All functions include built-in rate limiting, caching, and error handling.Key Features
- Automatic Rate Limiting: 3 requests per second with queue management
- Smart Caching: 5-minute cache with automatic expiry
- Retry Logic: Exponential backoff for failed requests
- Type Safety: Full TypeScript support with comprehensive interfaces
- Zero Configuration: No API key required
Available Functions
Search Anime
Search for anime by query string with pagination
Top Anime
Get top-rated anime with optional filtering
Seasonal Anime
Fetch anime by season and year, or get current season
Get by ID
Retrieve detailed information for a specific anime
Quick Start
Core Types
JikanAnime Interface
The primary data structure returned by all API functions:MyAnimeList unique identifier
Default anime title (usually romaji)
English translated title
Original Japanese title
Image URLs in multiple formats
Anime type: TV, Movie, OVA, Special, ONA, Music
Total number of episodes
Current airing status: Currently Airing, Finished Airing, Not yet aired
MyAnimeList rating score (0-10)
Plot description and summary
Array of genre objects with
mal_id, name, type, and urlArray of animation studio objects
Release year
JikanSearchResponse Interface
Wrapper for paginated API responses:Array of anime objects matching the query
Pagination metadata
Get Anime by ID
Retrieve detailed information for a specific anime using its MyAnimeList ID.Function Signature
MyAnimeList anime ID (mal_id)
Example
Response
Returns an object with adata property containing a single JikanAnime object.
Utility Functions
convertJikanToAnime
Converts Jikan API format to AniDojo’s internalAnime interface.
clearAPICache
Clears the internal API cache, forcing fresh data on next request.Rate Limiting
The API automatically handles Jikan’s rate limits:- Limit: 3 requests per second (~350ms between calls)
- Queue: Automatic request queuing when limit reached
- Retry: Up to 3 retries with exponential backoff on 429 errors
- Cache: 5-minute cache to reduce API calls
Error Handling
All functions may throw errors for:- Network failures
- Invalid responses (non-200 status codes)
- Rate limit exceeded (after retries)
- Malformed API responses
React Hooks
For React applications, use the provided hooks from/hooks/useAnime.ts:
useAnimeSearch(query, page)- Search with loading/error statesuseTopAnime(page)- Top anime with automatic updatesuseSeasonalAnime(year, season)- Seasonal anime data
src/hooks/useAnime.ts and handle loading states, error handling, and data caching automatically.
API Source
All anime data is provided by the Jikan API, an unofficial MyAnimeList API.- Base URL:
https://api.jikan.moe/v4/ - Documentation: docs.api.jikan.moe
- Rate Limit: 3 requests/second, 60 requests/minute
- Authentication: None required
Next Steps
Search Function
Learn about searchAnime() parameters and usage
Top Anime Function
Explore getTopAnime() with filters
Seasonal Function
Get seasonal and current anime data
Database Schema
Explore the database structure and tables