MCPcopy Index your code
hub / github.com/Snozxyx/TatakaiAPI

github.com/Snozxyx/TatakaiAPI @v5.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.0.0 ↗ · + Follow
513 symbols 1,616 edges 93 files 3 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<a href="https://github.com/ghoshRitesh12/aniwatch-api">
    <img 
        src="https://raw.githubusercontent.com/ghoshRitesh12/aniwatch-api/refs/heads/main/public/img/hianime_v2.png" 
        alt="aniwatch_logo" 
        width="175" 
        height="175"
        decoding="async"
        fetchpriority="high"
    />
</a>

Aniwatch API

A free RESTful API serving anime information from <a href="https://hianimez.to" target="_blank">hianimez.to</a>








<a 
  href="https://github.com/ghoshRitesh12/aniwatch-api/issues/new?assignees=ghoshRitesh12&labels=bug&template=bug-report.yml"
> 
  Bug report
</a>
·
<a 
  href="https://github.com/ghoshRitesh12/aniwatch-api/issues/new?assignees=ghoshRitesh12&labels=enhancement&template=feature-request.md"
>
  Feature request
</a>

codeql docker-build test_coverage GitHub License

stars forks issues version

[!IMPORTANT]

  1. There was previously a hosted version of this API for showcasing purposes only, and it was misused; since then, there have been no other hosted versions. It is recommended to deploy your own instance for personal use by customizing the API as you need it to be.
  2. This API is just an unofficial API for hianimez.to and is in no other way officially related to the same.
  3. The content that this API provides is not mine, nor is it hosted by me. These belong to their respective owners. This API just demonstrates how to build an API that scrapes websites and uses their content.

Table of Contents

💻 Installation

Local

  1. Clone the repository and move into the directory.

    bash git clone https://github.com/ghoshRitesh12/aniwatch-api.git cd aniwatch-api

  2. Install all the dependencies.

    bash npm i #or yarn install or pnpm i

  3. Start the server!

    bash npm start #or yarn start or pnpm start

    Now the server should be running on http://localhost:4000

Docker

The Docker image is available at The GitHub Container Registry.

Run the following commands to pull and run the docker image.

docker run -d --name aniwatch-api -p 4000:4000 ghcr.io/ghoshritesh12/aniwatch

The above command will start the server on port 4000. You can access the server at http://localhost:4000, and you can also change the port by changing the -p option to -p <port>:4000.

The -d flag runs the container in detached mode, and the --name flag is used to name the container that's about to run.

⚙️ Configuration

Custom HTTP Headers

Currently this API supports parsing of only one custom header, and more may be implemented in the future to accommodate varying needs.

  • Aniwatch-Cache-Expiry: This custom request header is used to specify the cache expiration duration in seconds (defaults to 300 or 5 mins if the header is missing). The ANIWATCH_API_REDIS_CONN_URL env is required for this custom header to function as intended; otherwise, there's no point in setting this custom request header. A response header of the same name is also returned with the value set to the cache expiration duration in seconds if ANIWATCH_API_REDIS_CONN_URL env is set.

Environment Variables

More info can be found in the .env.example file, where envs' having a value that is contained within < > angled brackets, commented out or not, are just examples and should be replaced with relevant ones.

  • ANIWATCH_API_PORT: Port number of the aniwatch API.
  • ANIWATCH_API_WINDOW_MS: Duration to track requests for rate limiting (in milliseconds).
  • ANIWATCH_API_MAX_REQS: Maximum number of requests in the ANIWATCH_API_WINDOW_MS time period.
  • ANIWATCH_API_CORS_ALLOWED_ORIGINS: Allowed origins, separated by commas and no spaces in between (CSV).
  • ANIWATCH_API_DEPLOYMENT_ENV: The deployment environment of the Aniwatch API. Many configurations depend on this env, rate limiting being one of them. It must be set incase of serverless deployments; otherwise, you may run into weird issues. Possible values: 'nodejs' | 'docker' | 'vercel' | 'render' | 'cloudflare-workers'.
  • ANIWATCH_API_HOSTNAME: Set this to your api instance's hostname to enable rate limiting, don't have this value if you don't wish to rate limit.
  • ANIWATCH_API_REDIS_CONN_URL: This env is optional by default and can be set to utilize Redis caching functionality. It has to be a valid connection URL; otherwise, the Redis client can throw unexpected errors.
  • ANIWATCH_API_S_MAXAGE: Specifies the maximum amount of time (in seconds) a resource is considered fresh when served by a CDN cache.
  • ANIWATCH_API_STALE_WHILE_REVALIDATE: Specifies the amount of time (in seconds) a resource is served stale while a new one is fetched.

⛅ Host your instance

[!CAUTION]

For personal deployments:

  • If you want to have rate limiting in your application, then set the ANIWATCH_API_HOSTNAME env to your deployed instance's hostname; otherwise, don't set or have this env at all. If you set this env to an incorrect value, you may face other issues.
  • It's optional by default, but if you want to have endpoint response caching functionality, then set the ANIWATCH_API_REDIS_CONN_URL env to a valid Redis connection URL. If the connection URL is invalid, the Redis client can throw unexpected errors.
  • You may or may not wanna remove the last if block within the IIFE in the server.ts file. It is for render free deployments only, as their free tier has an approx 10 or 15 minute sleep time. That if block keeps the server awake and prevents it from sleeping. You can enable the automatic health check by setting the environment variables ANIWATCH_API_HOSTNAME to your deployment's hostname, and ANIWATCH_API_DEPLOYMENT_ENV to render in your environment variables. If you are not using render, you can remove that if block.
  • If you are using a serverless deployment, then set the ANIWATCH_API_DEPLOYMENT_ENV env to vercel or render or cloudflare-workers depending on your deployment platform. This is because the API uses this env to configure different functionalities, such as rate limiting, graceful shutdown or hosting static files.

Vercel

Deploy your own instance of Aniwatch API on Vercel.

[!NOTE]

When deploying to vercel, you must set the env named ANIWATCH_API_DEPLOYMENT_ENV to vercel for proper functioning of the API.

Deploy with Vercel

Render

Deploy your own instance of Aniwatch API on Render.

[!NOTE]

When deploying to render, you must set the env named ANIWATCH_API_DEPLOYMENT_ENV to render for proper functioning of the API.

Deploy to Render

📚 Documentation

The endpoints exposed by the api are listed below with examples that uses the Fetch API, but you can use any http library.

GET Anime Home Page

Endpoint

/api/v2/hianime/home

Request Sample

const resp = await fetch("/api/v2/hianime/home");
const data = await resp.json();
console.log(data);

Response Schema

{
  success: true,
  data: {
    genres: ["Action", "Cars", "Adventure", ...],
    latestEpisodeAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        type: string,
        episodes: {
          sub: number,
          dub: number,
        }
      },
      {...},
    ],
    spotlightAnimes: [
      {
        id: string,
        name: string,
        jname: string,
        poster: string,
        description: string,
        rank: number,
        otherInfo: string[],
        episodes: {
          sub: number,
          dub: number,
        },
      },
      {...},
    ],
    top10Animes: {
      today: [
        {
          episodes: {
            sub: number,
            dub: number,
          },
          id: string,
          name: string,
          poster: string,
          rank: number
        },
        {...},
      ],
      month: [...],
      week: [...]
    },
    topAiringAnimes: [
      {
        id: string,
        name: string,
        jname: string,
        poster: string,
      },
      {...},
    ],
    topUpcomingAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        duration: string,
        type: string,
        rating: string,
        episodes: {
          sub: number,
          dub: number,
        }
      },
      {...},
    ],
    trendingAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        rank: number,
      },
      {...},
    ],
    mostPopularAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        type: string,
        episodes: {
          sub: number,
          dub: number,
        }
      },
      {...},
    ],
    mostFavoriteAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        type: string,
        episodes: {
          sub: number,
          dub: number,
        }
      },
      {...},
    ],
    latestCompletedAnimes: [
      {
        id: string,
        name: string,
        poster: string,
        type: string,
        episodes: {
          sub: number,
          dub: number,
        }
      },
      {...},
    ],
  }
}

🔼 Back to Top

GET Anime A-Z List

Endpoint

/api/v2/hianime/azlist/{sortOption}?page={page}

Path Parameters

Parameter Type Description Required? Default
sortOption string The az-list sort option. Possible values include: "all", "other", "0-9" and all english alphabets . Yes --

Query Parameters

Parameter Type Description Required? Default
page number The page number of the result. No 1

Request Sample

const resp = await fetch("/api/v2/hianime/azlist/0-9?page=1");
const data = await resp.json();
console.log(data);

Resp

Extension points exported contracts — how you extend this code

ScraperHealthProbe (Interface)
(no doc)
src/providers/route.ts
ClearanceResult (Interface)
(no doc)
src/lib/cf-bypass.ts
EmbedStream (Interface)
(no doc)
src/providers/techinmind/techinmind.ts
HindiApiResult (Interface)
(no doc)
src/providers/techinmind/techinmind.ts
AnimeKaiPagedResult (Interface)
(no doc)
src/providers/animekai/types.ts
AnimeKaiServer (Interface)
(no doc)
src/providers/animekai/types.ts

Core symbols most depended-on inside this repo

$
called by 411
src/providers/toonstream/jwplayer.js
n
called by 292
src/providers/toonstream/jwplayer.js
get
called by 261
src/lib/cache.ts
et
called by 108
src/providers/toonstream/jwplayer.js
set
called by 80
src/lib/cache.ts
error
called by 38
src/providers/toonstream/lib/logger.ts
r
called by 35
src/providers/toonstream/jwplayer.js
u
called by 35
src/providers/toonstream/jwplayer.js

Shape

Function 377
Method 95
Class 24
Interface 16
Enum 1

Languages

TypeScript100%

Modules by API surface

src/providers/toonstream/jwplayer.js229 symbols
src/providers/animekai/animekai.ts28 symbols
src/providers/techinmind/techinmind.ts18 symbols
src/providers/animelok/animelok.ts16 symbols
src/providers/animeya/animeya.ts15 symbols
src/providers/animepahe/animepahe.ts15 symbols
src/routes/tatakai.ts13 symbols
src/routes/proxy.ts11 symbols
src/providers/animepahe/scraper/unpacker.ts11 symbols
src/lib/proxyBalancer.ts10 symbols
src/providers/watchaw/watchaw.ts9 symbols
src/providers/hindidubbed/hindidubbed.ts9 symbols

For agents

$ claude mcp add TatakaiAPI \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page