Overview
@kreisler/anime-api is a comprehensive TypeScript library for scraping anime information from AnimeFLV and integrating with Jikan (MyAnimeList) API. It provides methods to search, browse, and retrieve detailed anime information including episodes, characters, and download links.
Package : @kreisler/anime-api
Version : 2.0.0
License : MIT
Installation
npm install @kreisler/anime-api
Quick Start
import {
search ,
getAnimeInfo ,
latestAnimeAdded ,
latestEpisodesAdded
} from '@kreisler/anime-api' ;
// Search for anime
const results = await search ( 'tokyo ghoul' );
// Get anime details
const info = await getAnimeInfo ( 'anime/5226/tokyo-ghoul' , 'Tokyo Ghoul' );
// Get latest episodes
const episodes = await latestEpisodesAdded ();
Core Functions
search()
Searches for anime by query string.
Search query (anime title or keywords).
return
Promise<AnimeSearchResult[]>
Array of anime search results. Show AnimeSearchResult properties
Anime ID (e.g., “anime/5226/tokyo-ghoul”).
Anime poster image in base64 format.
Anime synopsis/description.
Anime type (TV, Movie, OVA, etc.).
List of episodes with IDs and previews.
const results = await search ( 'naruto' );
results . forEach ( anime => {
console . log ( ` ${ anime . title } - ${ anime . type } ` );
console . log ( `Episodes: ${ anime . episodes ?. length } ` );
});
getAnimeInfo()
Retrieves detailed information about a specific anime.
Anime ID from AnimeFLV (e.g., “anime/5226/tokyo-ghoul”).
Anime title for fetching additional info from Jikan.
return
Promise<AnimeDetailedInfo[]>
Array containing detailed anime information. Show AnimeDetailedInfo properties
Additional information from MyAnimeList.
List of characters and voice actors.
const [ anime ] = await getAnimeInfo (
'anime/5226/tokyo-ghoul' ,
'Tokyo Ghoul'
);
console . log ( 'Title:' , anime . title );
console . log ( 'Synopsis:' , anime . synopsis );
console . log ( 'Episodes:' , anime . episodes ?. length );
console . log ( 'Characters:' , anime . charactersList ?. length );
latestAnimeAdded()
Retrieves the latest anime added to AnimeFLV.
return
Promise<AnimeSearchResult[]>
Array of recently added anime.
const latest = await latestAnimeAdded ();
console . log ( 'Latest anime:' );
latest . forEach ( anime => {
console . log ( `- ${ anime . title } ( ${ anime . type } )` );
});
latestEpisodesAdded()
Retrieves the latest episodes added to AnimeFLV.
Array of recently added episodes. Show LatestEpisode properties
Episode ID (e.g., “ver/5226/tokyo-ghoul-1”).
Episode thumbnail in base64.
Available streaming servers for the episode.
const episodes = await latestEpisodesAdded ();
episodes . forEach ( ep => {
console . log ( ` ${ ep . title } - Episode ${ ep . episode } ` );
console . log ( `Servers: ${ ep . servers ?. length } ` );
});
getAnimeServers()
Retrieves streaming server information for a specific episode.
Episode ID (e.g., “ver/5226/tokyo-ghoul-1”).
Array of available servers. Show IServersData properties
Server name (e.g., “Fembed”, “Mega”, “Okru”).
Optional direct URL to the video.
Whether the server works on mobile.
Embed code or stream URL.
const servers = await getAnimeServers ( 'ver/5226/tokyo-ghoul-1' );
servers . forEach ( server => {
console . log ( ` ${ server . server } : ${ server . code } ` );
console . log ( `Ads: ${ server . ads } , Mobile: ${ server . allow_mobile } ` );
});
downloadLinksByEpsId()
Retrieves download links for a specific episode.
return
Promise<IDownloadLinksByEpsId[]>
Array of download links. Show IDownloadLinksByEpsId properties
Server/host name (e.g., “Mega”, “MediaFire”).
const downloads = await downloadLinksByEpsId ( 'ver/5226/tokyo-ghoul-1' );
downloads . forEach ( link => {
console . log ( ` ${ link . server } : ${ link . url } ` );
});
Browse Functions
tv()
Browses TV anime with pagination and sorting.
order
'updated' | 'added'
required
Sort order (by update date or added date).
Page number as string (e.g., “1”, “2”).
return
Promise<AnimeSearchResult[]>
Array of TV anime.
const tvAnime = await tv ( 'updated' , '1' );
console . log ( `Found ${ tvAnime . length } TV anime` );
movies()
Browses anime movies.
order
'updated' | 'added'
required
Sort order.
return
Promise<AnimeSearchResult[]>
Array of anime movies.
const movieList = await movies ( 'added' , '1' );
ova()
Browses OVA anime.
order
'updated' | 'added'
required
Sort order.
return
Promise<AnimeSearchResult[]>
Array of OVA anime.
const ovaList = await ova ( 'updated' , '1' );
special()
Browses special episodes and anime.
order
'updated' | 'added'
required
Sort order.
return
Promise<AnimeSearchResult[]>
Array of special anime.
const specials = await special ( 'added' , '1' );
animeByState()
Browses anime filtered by airing status.
Status code (1 = Currently Airing, 2 = Finished Airing, 3 = Not Yet Aired).
order
'updated' | 'added'
required
Sort order.
return
Promise<AnimeSearchResult[]>
Array of anime matching the status.
// Get currently airing anime
const airing = await animeByState ( 1 , 'updated' , '1' );
// Get finished anime
const finished = await animeByState ( 2 , 'updated' , '1' );
animeByGenres()
Browses anime filtered by genre.
Genre slug (e.g., ‘comedia’, ‘accion’, ‘romance’).
order
'updated' | 'added'
required
Sort order.
return
Promise<AnimeSearchResult[]>
Array of anime in the specified genre.
const comedyAnime = await animeByGenres ( 'comedia' , 'updated' , '1' );
const actionAnime = await animeByGenres ( 'accion' , 'added' , '1' );
Retrieves promotional videos for an anime from MyAnimeList.
Anime title to search on MyAnimeList.
return
Promise<PromoVideo[] | null>
Array of promotional videos or null if not found. Show PromoVideo properties
const promos = await getAnimeVideoPromo ( 'Tokyo Ghoul' );
if ( promos ) {
promos . forEach ( promo => {
console . log ( ` ${ promo . title } : ${ promo . videoURL } ` );
});
}
getAnimeCharacters()
Retrieves character information from MyAnimeList.
return
Promise<Character[] | null>
Array of characters or null if not found. Show Character properties
Character information object. Show character properties
MyAnimeList character ID.
Character role (Main, Supporting, etc.).
const characters = await getAnimeCharacters ( 'Tokyo Ghoul' );
if ( characters ) {
characters . forEach (({ character }) => {
console . log ( ` ${ character . name } ( ${ character . role } )` );
});
}
Interfaces
AnimeEpisode
Represents an anime episode.
Episode ID for streaming/downloading.
Release date of next episode (for ongoing anime).
Additional anime information from MyAnimeList.
Source material (Manga, Light Novel, Original, etc.).
Total number of episodes.
Airing dates. Human-readable date range.
Number of members who added it.
Number of users who favorited it.
Premiere season and year.
Production companies. Show producers properties
Licensing companies. Show licensors properties
IFlvFiltros
Filter options for browsing anime.
Genre filter (e.g., ‘comedia’, ‘accion’).
Usage Examples
Search and Display Anime
import { search } from '@kreisler/anime-api' ;
const query = 'one piece' ;
const results = await search ( query );
results . forEach ( anime => {
console . log ( ' \n ---' );
console . log ( 'Title:' , anime . title );
console . log ( 'Type:' , anime . type );
console . log ( 'Rating:' , anime . rating );
console . log ( 'Genres:' , anime . genres ?. join ( ', ' ));
console . log ( 'Episodes:' , anime . episodes ?. length );
});
import { search , getAnimeInfo } from '@kreisler/anime-api' ;
// First search for the anime
const [ result ] = await search ( 'death note' );
if ( result ) {
// Then get detailed information
const [ details ] = await getAnimeInfo ( result . id ! , result . title ! );
console . log ( 'Title:' , details . title );
console . log ( 'Synopsis:' , details . synopsis );
console . log ( ' \n Extra Info from MyAnimeList:' );
console . log ( 'Japanese Title:' , details . moreInfo ?. titleJapanese );
console . log ( 'Total Episodes:' , details . moreInfo ?. totalEpisodes );
console . log ( 'Status:' , details . moreInfo ?. status );
console . log ( 'Rank:' , details . moreInfo ?. rank );
console . log ( 'Studios:' , details . moreInfo ?. studios ?. names . join ( ', ' ));
console . log ( ' \n Characters:' );
details . charactersList ?. slice ( 0 , 5 ). forEach (({ character }) => {
console . log ( `- ${ character . name } ( ${ character . role } )` );
});
}
Browse Latest Episodes
import { latestEpisodesAdded , getAnimeServers } from '@kreisler/anime-api' ;
const episodes = await latestEpisodesAdded ();
console . log ( 'Latest Episodes:' );
for ( const ep of episodes . slice ( 0 , 5 )) {
console . log ( ` \n ${ ep . title } - Episode ${ ep . episode } ` );
// Get available servers
if ( ep . id ) {
const servers = await getAnimeServers ( ep . id );
console . log ( 'Available servers:' , servers . map ( s => s . server ). join ( ', ' ));
}
}
Filter by Genre and Status
import { animeByGenres , animeByState } from '@kreisler/anime-api' ;
// Get currently airing action anime
const airingAction = await animeByGenres ( 'accion' , 'updated' , '1' );
console . log ( 'Currently Airing Action Anime:' );
airingAction . forEach ( anime => {
console . log ( `- ${ anime . title } ` );
});
// Get finished comedy anime
const finishedComedy = await animeByState ( 2 , 'updated' , '1' );
console . log ( ' \n Finished Anime:' );
finishedComedy . slice ( 0 , 10 ). forEach ( anime => {
console . log ( `- ${ anime . title } ` );
});
Download Episode Links
import {
latestEpisodesAdded ,
downloadLinksByEpsId
} from '@kreisler/anime-api' ;
const [ episode ] = await latestEpisodesAdded ();
if ( episode . id ) {
const downloads = await downloadLinksByEpsId ( episode . id );
console . log ( `Download links for ${ episode . title } - Episode ${ episode . episode } :` );
downloads . forEach ( link => {
console . log ( ` ${ link . server } : ${ link . url } ` );
});
}
Build a Complete Anime Database
import {
tv ,
movies ,
ova ,
getAnimeInfo
} from '@kreisler/anime-api' ;
const database = [];
// Get TV anime from multiple pages
for ( let page = 1 ; page <= 3 ; page ++ ) {
const anime = await tv ( 'updated' , String ( page ));
database . push ( ... anime );
}
// Get movies
const movieList = await movies ( 'updated' , '1' );
database . push ( ... movieList );
// Get OVAs
const ovaList = await ova ( 'updated' , '1' );
database . push ( ... ovaList );
console . log ( `Total anime in database: ${ database . length } ` );
// Get detailed info for each
for ( const anime of database . slice ( 0 , 5 )) {
const [ details ] = await getAnimeInfo ( anime . id ! , anime . title ! );
console . log ( `Processed: ${ details . title } ` );
}
Helper Utilities
imageUrlToBase64()
Internal utility that converts image URLs to base64 format.
Base64 encoded image string.
Constants
URLS
Object containing all API endpoints.
Episode thumbnail base URL.
Jikan API search endpoint.
Error Handling
All functions handle errors gracefully and return null or empty arrays when data cannot be fetched:
try {
const results = await search ( 'nonexistent anime' );
if ( results . length === 0 ) {
console . log ( 'No results found' );
}
} catch ( error ) {
console . error ( 'Search failed:' , error );
}
Rate Limiting
Be mindful of rate limits when making multiple requests:
// Add delays between requests
const delay = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ));
for ( const anime of animeList ) {
const info = await getAnimeInfo ( anime . id , anime . title );
await delay ( 1000 ); // Wait 1 second between requests
}
Dependencies
cheerio - HTML parsing and scraping
cheerio-tableparser - Table parsing for download links
cloudscraper - HTTP client with Cloudflare bypass
urldecode - URL decoding utilities
image-to-base64 - Image conversion
Links