Skip to main content
This guide will walk you through setting up Hianime and building your first anime scraper application. By the end, you’ll understand how to fetch anime lists, episodes, and streaming sources.

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
The Hianime client handles all HTTP requests and HTML parsing for you. No configuration needed!

Step 3: Fetch Anime Lists

Start by getting a list of currently airing anime:
index.ts
What’s happening here:
  • 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’s dataId to fetch its episodes:
index.ts
What’s happening here:
  • getEpisodes() takes a dataId (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
What’s happening here:
  • getEpisodeServers() returns available streaming servers
  • Servers are split into sub (subtitled) and dub (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
What’s happening here:
  • 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(), or getTVShows()
  • 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