> ## Documentation Index
> Fetch the complete documentation index at: https://hianime.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get up and running with Hianime in minutes

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

<CodeGroup>
  ```bash npm theme={null}
     npm install hianime
  ```

  ```bash yarn theme={null}
     yarn add hianime
  ```
</CodeGroup>

## Step 2: Basic Setup

Create a new TypeScript file and import the Hianime library:

```ts index.ts icon="js" lines theme={null}
import { Hianime } from "hianime";

// Initialize the Hianime client
const hianime = new Hianime();
```

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:

```ts index.ts icon="js" lines highlight={2,8} theme={null}
// Fetch top airing anime (paginated results)
const airings = await hianime.getTopAiring();

console.log(`Found ${airings.results.length} anime on page ${airings.page}`);
console.log(`Total pages available: ${airings.totalPage}`);

// Get the first anime from the list
const topAiring = airings.results[0];
console.log(`Top anime: ${topAiring.title}`);
```

**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:

```ts index.ts icon="js" lines highlight={2,7} theme={null}
// Get episodes for the selected anime
const episodes = await hianime.getEpisodes(topAiring.dataId);

console.log(`Found ${episodes.length} episodes`);

// Get the first episode
const firstEpisode = episodes[0];
console.log(`First episode: ${firstEpisode.title || "Episode 1"}`);
```

**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:

```ts index.ts icon="js" lines highlight={2,8} theme={null}
// Get available streaming servers for the episode
const servers = await hianime.getEpisodeServers(firstEpisode.id);

console.log(`Sub servers: ${servers.sub.length}`);
console.log(`Dub servers: ${servers.dub.length}`);

// Use the first subtitle server
const selectedServer = servers.sub[0];
console.log(`Using server: ${selectedServer.name}`);
```

**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:

```ts index.ts icon="js" lines highlight={2,9-15} theme={null}
// Get video sources from the selected server
const sources = await hianime.getEpisodeSources(selectedServer.id);

console.log("Available video qualities:");
sources.sources.forEach((source) => {
  console.log(`- ${source.type}: ${source.file}`);
});

// Get subtitle tracks if available
if (sources.tracks?.length > 0) {
  console.log("Available subtitles:");
  sources.tracks.forEach((track) => {
    console.log(`- ${track.label}: ${track.file}`);
  });
}
```

**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:

```ts index.ts icon="js" lines theme={null}
import { Hianime } from "hianime";

async function main() {
  const hianime = new Hianime();

  try {
    // Step 1: Get top airing anime list
    const airings = await hianime.getTopAiring();
    const topAiring = airings.results[0];

    console.log(`Selected anime: ${topAiring.title}`);

    // Step 2: Get episodes for the anime
    const episodes = await hianime.getEpisodes(topAiring.dataId);
    const firstEpisode = episodes[0];

    console.log(`Getting episode: ${firstEpisode.title || "Episode 1"}`);

    // Step 3: Get available streaming servers
    const servers = await hianime.getEpisodeServers(firstEpisode.id);
    const server = servers.sub[0]; // Use first subtitle server

    console.log(`Using server: ${server.name}`);

    // Step 4: Extract video sources
    const sources = await hianime.getEpisodeSources(server.id);

    console.log("Video sources:");
    sources.sources.forEach((source) => {
      console.log(`${source.type}: ${source.file}`);
    });
  } catch (error) {
    console.error("Error:", error.message);
  }
}

main();
```

## 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
