# otakubox
> A Go HTTP API that resolves one anime id into playable video streams by
> aggregating nine independent scrape sources, then proxies the resulting HLS
> manifests, segments, keys and captions so a browser player can play them.
> Every endpoint is `GET` and returns JSON, except `/proxy`, which returns video
> bytes or a rewritten playlist.
The base URL is the origin that serves this file. All paths below are relative to
it. The API is stateless from a client's point of view: an id discovered by
`/search` is the input to `/info`, an episode id from `/episodes` is the input to
`/watch`, and the URLs in `/watch` are the input to `/proxy`.
## How a client should use it
1. `GET /search?q=
` → pick an anime `id`.
2. `GET /info/` → see which providers have it, in preference order.
3. `GET /episodes/?provider=` → verified episode list.
4. `GET /watch?provider=&episodeId=&type=sub` → playable URLs.
5. `GET /dubs/` → measured English-dub episode count, when you need to
show one.
6. Hand `sub[0].sources[0].url` to an HLS-capable player. Do not rewrite it, and
do not use `rawUrl` — the upstream CDN requires a `Referer` header that a
browser player cannot set, which is the whole reason `/proxy` exists.
## Endpoints
### GET /search
Find an anime id by title. Hits the series catalog only; never touches a scrape source, so
it stays fast and correct even when every provider is down.
Parameters:
- `q` (required, string) — free-text title, case and punctuation tolerant.
- `page` (optional, integer, 1-based) — Returns 15 results per page.
Returns `{ "results": [ ... ] }` where each result is:
```json
{
"id": "154587",
"malId": 52991,
"title": { "romaji": "Sousou no Frieren", "english": "Frieren: Beyond Journey's End", "native": "葬送のフリーレン" },
"image": "/img?url=https%3A%2F%2Fcdn.myanimelist.net%2Fimages%2Fanime%2F1615%2F149911.jpg",
"totalEpisodes": 28,
"type": "TV",
"status": "FINISHED"
}
```
`id` is a string, not a number — treat it as opaque. `title.english` and
`title.native` are omitted when the catalog has no value.
### GET /info/{animeId}
Map one Anime id onto the providers that carry it. Cheap: one catalog lookup
plus one search per provider, no episode fetches.
The fan-out is bounded: providers that have not answered in time are reported in
`pending` rather than making the request wait, and their searches continue in the
background so a repeat call is complete and fast.
Parameters:
- `animeId` (required, numeric, in the path).
Returns:
```json
{
"id": "154587",
"mappings": [
{ "provider": "AnikotoTV", "id": "frieren-beyond-journey-s-end-c6fbj", "title": "Frieren: Beyond Journey's End", "score": 0.9 }
],
"partial": true,
"pending": ["AniNeko"]
}
```
`mappings` is in **provider preference order**, not score order. Index 0 is the
provider the deployment trusts most. `score` is a ranking signal in `[0,1]`, not
a probability; 0.9 is a normal confident match. A provider absent from the list
had no confident match at all — it is not an error.
`partial` and `pending` appear only when the deadline cut the tail off. When
`pending` is absent, every provider answered, so a provider missing from
`mappings` genuinely had no match. Repeating the request returns the full set.
### GET /episodes/{animeId}
Return a verified episode list for a series.
Parameters:
- `animeId` (required, numeric, in the path).
- `provider` (optional, string, case-insensitive) — preferred provider. If it
cannot serve the show the request falls through to the others and the response
names whichever actually served it.
Returns:
```json
{
"provider": "AniWaves",
"episodes": [ { "id": "74575/1", "number": 1, "title": "Episode 1", "url": "https://aniwaves.ru/watch/sousou-no-frieren-74575/ep-1" } ],
"matchConfidence": "metadata"
}
```
`matchConfidence` is one of:
- `exact-id` — the provider leaked an anime id that matched exactly.
- `metadata` — season ordinal and/or episode count agreed with the catalog.
- `unverified` — neither signal could decide (typically a still-airing show).
This endpoint exists to reject wrong mappings. A provider that confidently calls
a show "Season 4" when it is serving Season 1 is caught here, not served.
`episode.id` is opaque and provider-specific: pass it to `/watch` unchanged and
never parse it.
### GET /watch
Resolve an episode id into every playable server and quality.
Parameters:
- `provider` (required, string) — from `/info` or `/episodes`.
- `episodeId` (required, string) — opaque id from `/episodes`. URL-encode it;
some providers embed `/` in ids.
- `type` (optional, `sub` or `dub`) — omit to resolve both concurrently and get
both keys in the response.
Returns:
```json
{
"sub": [
{
"serverName": "Vidplay",
"audio": "original",
"subtitleKind": "soft",
"headers": { "Referer": "https://play.vhscdn.to/" },
"sources": [
{ "url": "/proxy?url=...&ref=...", "rawUrl": "https://re-2.echovideo.to/.../master.m3u8", "quality": "auto", "isM3U8": true },
{ "url": "/proxy?url=...&ref=...", "rawUrl": "https://re-2.echovideo.to/.../720/index.m3u8", "quality": "720p", "isM3U8": true }
],
"subtitles": [ { "url": "/proxy?url=...", "rawUrl": "https://.../sub.vtt", "lang": "en" } ]
},
{
"serverName": "HD-1 (Hard Sub)",
"audio": "original",
"subtitleKind": "hard",
"sources": [ { "url": "/proxy?url=...", "rawUrl": "https://.../master.m3u8", "quality": "auto", "isM3U8": true } ],
"subtitles": []
}
],
"dub": null
}
```
Field notes:
- `sub` and `dub` are each `null` or an array of servers. `null` means the track
does not exist for that provider. A request for a track that genuinely does not
exist is a `502` naming the missing track - it never silently returns the other
one, because dub audio under a sub request is invisible until playback starts.
- `sources[0]` is normally the master playlist (`quality: "auto"`, `isM3U8:
true`). The rest are its variants. `isM3U8: false` means a direct `MP4`.
- `intro` / `outro` are present only when the provider publishes skip markers:
`{ "start": 12.5, "end": 102.5 }`, in seconds.
- `headers` is diagnostic. A browser client must use `url`, not `rawUrl`.
### Audio and subtitles are two different questions
This trips up almost every client, so it is stated separately.
`type=sub|dub` on the request is a **preference**, not a description. It says
which audio you want, not what you got. Two independent fields on each source say
what actually resolved:
- `audio`: `original` (Japanese for anime), `english`, or `other` (with
`audioLocale`, e.g. `"es-MX"`).
- `subtitleKind`: `soft` (a separate WebVTT/ASS track the player renders and the
user can toggle), `hard` (English burned into the video pixels - the text is
part of the picture), or `none` (no subtitle text in this stream).
Both fields are **omitted** when the provider does not state them. Absent means
unknown, not a default: do not render a language selector when `audio` is
missing, and do not assume `soft` when `subtitleKind` is missing.
Practical consequences:
- Offer a subtitle on/off toggle only for `soft`. On `hard` it does nothing; on
`none` there is nothing to show.
- Do not label a server "sub" because it answered a sub request. Check `audio`.
Several providers fall back to the original audio when a requested dub is not
ready, and they report `original` when they do.
- `subtitles: []` alone cannot distinguish "hardsub" from "no subtitles". That
is exactly why `subtitleKind` exists - use it.
- A track can be BOTH: `audio: "english"` with `subtitleKind: "hard"` is a
dub with English text burned into the frames, which is what Ani.pm's `dubhard`
channel is. Ani.pm also returns the soft and hard channels of one track as
separate `sub` entries, soft first, because they are different playlists rather
than a flag on one.
- `subtitleKind: "hard"` is only ever reported when a provider STATES it (a
dedicated hardsub channel). It is never inferred from a missing subtitle list.
- Source order is preference order. Index 0 is the server the deployment trusts
most for that track, and every entry is a genuine fallback, so try them in
order rather than only reading index 0.
### GET /proxy
Fetch an upstream URL, re-attach the headers the CDN demands, rewrite a manifest
so every child URI points back here, or stream a segment through untouched.
Parameters:
- `url` (required) — percent-encoded absolute upstream URL.
- `ref` (optional) — `Referer` to send upstream; most video CDNs require one.
- `org` (optional) — serialized `Origin` (`scheme://host[:port]`, no path).
- `pk`, `km`, `aud` — internal transforms for specific providers (playlist
obfuscation key, UniqueStream media id, default audio group). Strings copied
verbatim from `/watch`.
Returns either an M3U8 playlist (`Content-Type: application/vnd.apple.mpegurl`),
raw key bytes, or the upstream segment with `Content-Type`, `Content-Length`,
`Content-Range`, `Accept-Ranges` and `Cache-Control` preserved. `Range` requests
are forwarded, so seeking works.
`/proxy` is **never API-key gated**. Its URLs are embedded inside playlists the
player itself fetches, and a player cannot attach a custom header.
### GET /dubs
Measured English-dub coverage, one record per series, keyed by AniList id. This
is this API's own measurement, not a third-party counts file: it is built by
crawling the sources' per-episode dub flags, so the number is how many episodes
actually have a dub track.
```
GET /dubs every measured series
GET /dubs/ one series
GET /dubs?full=1 only series whose dub covers every episode
GET /dubs?partial=1 only series with a partial dub
```
```json
{
"count": 3093,
"generatedAt": "2026-11-16T00:00:00Z",
"source": "otakubox-dubdb/1",
"series": [
{ "anilistId": 9253, "title": "Steins;Gate", "dubEpisodes": 24, "totalEpisodes": 24, "full": true, "partial": false, "confidence": "full" },
{ "anilistId": 21, "title": "One Piece", "dubEpisodes": 1159, "totalEpisodes": 1180, "full": false, "partial": true, "confidence": "partial" }
]
}
```
A series with no confirmed dub has **no entry**. That is deliberate: an absent
record means "not measured" or "no dub", and a client should show an icon with
no number rather than assume a count. `confidence` is `full`, `partial`, or
`measured`.
The route is not API-key gated and answers `Cache-Control: public, max-age=3600`:
it changes only when the crawler runs.
### GET /health
Liveness and degraded-provider state. Touches no upstream, so it is cheap enough
to poll.
```json
{
"status": "ok",
"providers": 10,
"providerNames": ["Ani.pm", "AniNeko", "AnimeNoSub", "AnikotoTV", "AniWaves", "AniZone", "UniqueStream", "KickAssAnime", "Senshi", "Gogoanime"],
"cacheEntries": 57,
"uptimeSeconds": 32,
"degradedProviders": ["Senshi"],
"providerStats": {
"search": {
"AnikotoTV": { "latencyMs": 201, "failures": 0, "samples": 6 },
"Senshi": { "failures": 2, "samples": 0 }
},
"episodes": {
"AnikotoTV": { "latencyMs": 141, "failures": 0, "samples": 5 }
}
}
}
```
`degradedProviders` is absent when nothing is tripped. When present it lists
providers the circuit breaker is currently skipping after repeated failures.
`providerNames` is in preference order, matching `/info` and `/episodes`.
`providerStats` is split by stage and omitted entirely on a fresh process rather
than reported as zeros. `latencyMs` is an exponentially weighted moving average
and is omitted when `samples` is 0 — a never-measured provider is not an instant
one. `failures` counts consecutive failures and resets on a success. Values are
per process and lost on restart.
`GET /status` renders this same data as an HTML page for humans. `GET /demo` is a
working page that walks search -> info -> episodes -> watch -> play against live
providers, so a frontend can confirm each feature behaves as documented.
### GET /api
Machine-readable service description: name, status, provider list and the route
table.
## Providers
Registration order is preference order. It decides which provider answers first
when several carry a title, and it is what a client sees at index 0.
| # | Provider | Subtitles | Notes |
| - | -------- | --------- | ----- |
| 1 | AniNeko | soft .vtt | Currently answering Cloudflare 522 (origin down). |
| 2 | AnimeNoSub | soft .vtt | MegaPlay backend, large back catalog. |
| 3 | AnikotoTV | soft .vtt | nekostream backend, five requests deep. |
| 4 | AniWaves | none | Same nekostream backend as AnikotoTV. Vidplay + MyCloud (HLS), DatSaV (MP4). |
| 5 | AniZone | soft .ass | Catalog moved to Livewire: client-rendered, so search returns nothing. Info/sources still work for a known id. |
| 6 | UniqueStream | soft .vtt | Self-hosted Crunchyroll re-host. Genuinely multi-audio. Short-TTL signed manifests. |
| 7 | KickAssAnime | soft .vtt | One master carries both Japanese and English audio groups. |
| 8 | Senshi | burned in | Domain parked. Kept for reference; the circuit breaker absorbs it. |
| 9 | Gogoanime | soft .vtt | Legacy fallback catalog. |
Provider names are matched case-insensitively but returned in canonical form;
send back exactly what `/api` reports.
## Errors
Every error is JSON: `{ "error": "" }`. The status code is part of the
contract, not decoration.
- `400` — the caller's request is wrong: a non-numeric `animeId`, an unknown
provider, a non-integer `page`, a `type` other than `sub`/`dub`, or a `/proxy`
URL refused by the SSRF guard.
- `401` — an API key is configured and the request's is missing or wrong. Send
`x-api-key: ` or `Authorization: Bearer `. This only applies when the
deployment sets `API_KEY`.
- `404` — no such route.
- `429` — the route's rate tier is exhausted for this IP.
- `502` — the server tried and could not produce a result: every provider failed
verification, a provider was unreachable, or a manifest could not be fetched.
The message names the specific cause.
`400` vs `502` for `/proxy` is deliberate. A refused URL is the caller's mistake;
a `502` means the upstream was contacted and failed. Conflating them sends people
debugging a CDN that was never called.
## Rate limits
Per IP, fixed one-minute windows, per route tier. A single global limit would
either throttle playback or leave search unthrottled, since one video fires
hundreds of segment requests while a search fires one.
| Tier | Routes | Limit |
| ---- | ------ | ----- |
| root | `/` `/demo` `/api` `/health` `/status` `/llms.txt` | 140 / min |
| default | `/search` | 120 / min |
| scrape | `/info` `/episodes` | 60 / min |
| watch | `/watch` | 30 / min |
| proxy | `/proxy` | 600 / min |
## Caching
Caching happens inside the aggregator, per stage, with TTLs chosen by how fast
the underlying data changes:
| Data | TTL | Why |
| ---- | --- | --- |
| Series metadata for a series | 12 h | The catalog rarely changes a record. |
| Anime id → provider mappings (`/info`) | 6 h | Provider catalogs change, but slowly. |
| Verified episode lists (`/episodes`) | 30 min | New episodes appear weekly, so a stale list costs at most one airing window. |
`/search` is **not** cached: it is a single catalog request and the query space is
unbounded, so a cache would grow without ever paying for itself.
Cache hits are transparent — there is no header to distinguish them, and clients
must not depend on one. Cache keys include the Anime id, so two clients asking
for the same series share the work.
## Constraints worth knowing before writing a client
- All data routes are `GET` and idempotent. There is no write API.
- A `502` with an empty `mappings`-shaped body is not a bug: some providers
simply have no match for an obscure or very new title.
- Provider availability drifts because it depends on third-party sites. Poll
`/health` rather than hardcoding the assumption that all nine work.
- `PUBLIC_URL` is baked into every proxied link at request time. If the
deployment's origin changes, previously issued `/watch` responses point at a
dead host; re-request them rather than caching the URLs long-term.
## Terms
This API aggregates third-party sites it does not own; run it for your own use
and respect the sites it reads.