What you’ll build
A complete anime data fetcher that:- Gets the top airing anime list
- Retrieves episode information for a specific anime
- Finds available streaming servers
- Extracts video source URLs
Step 1: Install Hianime
Step 2: Basic Setup
Create a new TypeScript file and import the Hianime library:index.ts
Step 3: Fetch Anime Lists
Start by getting a list of currently airing anime:index.ts
getTopAiring()
returns a paginated list of popular anime currently airing- Each result includes metadata like title, image, type, and language availability
- The response includes pagination info (
page
,totalPage
,hasNextPage
)
Step 4: Get Episode Information
Use the anime’sdataId
to fetch its episodes:
index.ts
getEpisodes()
takes adataId
(the anime’s unique identifier)- Returns an array of episode objects with titles, numbers, and IDs
- Episode IDs are needed to get streaming servers
Step 5: Find Streaming Servers
Get available servers for a specific episode:index.ts
getEpisodeServers()
returns available streaming servers- Servers are split into
sub
(subtitled) anddub
(dubbed) arrays - Each server has a name and ID needed for source extraction
Step 6: Extract Video Sources
Finally, get the actual streaming URLs:index.ts
getEpisodeSources()
extracts direct video URLs from the streaming server- Returns multiple quality options (1080p, 720p, etc.)
- May include subtitle tracks in various languages
Complete Example
Here’s the full working example:index.ts
Next Steps
Now that you have the basics down, explore more features:- Browse different categories: Try
getMostPopular()
,getMovies()
, orgetTVShows()
- Handle pagination: Use the
page
parameter to fetch more results - Add error handling: Wrap API calls in try-catch blocks
- Rate limiting: Add delays between requests to be respectful