Repository navigation
AniKotoAPI v2.6.1
Full release covering 2.6.0 + 2.6.1 — both shipped 2026-10-24 (2.6.0 never got its own tag). Three sessions in one: the 2.6.0 architecture push (modular middleware/routes, AniList enrichment, cache controls), the 2.6.1 stream-resolver rebuild, and the follow-up full diagnostic sweep that closed every P0–P3 finding.
Added
- AniList Enrichment —
GET /api/anilist/:id(also?mal=21) returns synopsis, genres, scores, studios, characters, relations, recommendations and next-airing data straight from AniList's public GraphQL API — no scraping, immune to origin-site Cloudflare challenges. Unknown media returns 404, an AniList outage returns 502. - Seasonal Chart —
GET /api/anilist/season?season=WINTER&year=2026&page=1&perPage=25, defaults to the current season/year, 30 min cache per season/page. - AniList Client —
src/helper/anilist.helper.js(cached GraphQL client + MAL→AniList ID map, 60 min) shared by/anilist,info.externalIdsand/stream/embeds. - Modular Stack — middleware extracted to
src/middleware/(request ID, CORS, security headers, rate limit, timeout, validation), routes split intosrc/routes/*domain modules, spec builder moved tosrc/configs/openapi.config.js(49 paths / 13 tags);server.jsis now a pure composition root. - Cache Controls —
?refresh=1bypasses the LRU for the whole request chain (AsyncLocalStorage scope) withX-Cache: HIT/MISS/BYPASSheaders, plus an in-flight request registry so a cold key can no longer fan out into 5-mirror stampedes. - TRUST_PROXY — rate limiting keys on the real client IP behind Render/Vercel/nginx instead of the proxy's address (one noisy client can no longer 429 the whole API).
- Response Sanitizer — new
src/middleware/sanitizeJson.middleware.js: decodes HTML entities (&,', non-terminated&NBSP 1999), collapses whitespace runs and coerces stringified identity keys to numbers on every JSON response. - Rate-Limit Skip —
/api/healthand/api/openapiare exempt from the limiter so monitoring and spec readers are never throttled out of the window. - Tests — 16 new sweep-regression cases (real seasons/watch-order, ranking windows, error mapping, strict validation, payload hygiene); suite now 64 tests, and the runner prints its count after the dynamic injections so the number always matches the list.
Fixed
- Seasons & Watch Order (P0) — both endpoints served the generic trending sidebar for every anime; they now parse the real upstream AJAX fragments
GET {base}api/seasons/{animeId}andGET {base}api/watch-order/{animeId}(XHR header + Referer). Naruto → 4 real seasons (Classic Series,Shippuden Series, …), One Piece → honesttotalSeasons: 0, watch-order → 56 One Piece / 25 Naruto related entries, deduped with the anime itself excluded. Slug and numeric forms work —/api/seasons/1642used to answer 500. - Top Rankings (P0) — the selector merged all three homepage tabs (27 items, ranks 1–27, byte-identical output for every
?sort=). Now scoped per window: 9 unique slugs ranked 1–9 each,day ≠ week ≠ month, and an unknown sort returns 400 instead of silently falling back. - Fast-Fail Error Mapping (P1) — client faults no longer replay across every mirror with backoff: structured upstream
4xx/"Bad request" answers are terminal on the first try, so a bad slug returns 404 in ~0.5–1 s instead of 500 after 13–16 s; the status propagates through all 42 routecatchblocks (plus/stream, which used to wrap everything as a 502). - JSON 404s — unknown
/api/*paths return{ success: false, message: "Endpoint not found" }instead of the HTML error page; 429s carry the creator envelope again (limiter now runs after the attribution middleware);/api/mirrors/resetgained the standardresultskey. - Stream Resolver (upstream break) — the legacy
/ajax/sourceshost (megaplay-1.buzz) died in DNS, killing/stream/resolveand/stream/qualities. Resolution now callsstream/getSourcesNew → stream/getSourceson the embed host and decrypts the AES-256-CBCencpayload (key/IV from the player) to themaster.m3u8; the legacy call stays as fallback,kind: "captions"tracks count as subtitles,skipDatanormalised to the site's[start, end]shape. - Stream Qualities — the playlist fetch sent no player-origin Referer and the CDN answered 403, so
totalQualitieswas always0; it now sendsstreamRefererHeaders()and returns the real variant list. - Info Artifacts —
ratingreads#w-rating[data-score](the old text extraction doubled it:"8.73 8.73 /10"),premieredstrips upstream's&NBSP,altNamesis split + deduped,episodesisnullinstead of the literal"?". - AniList Misses —
/api/anilist/999999999→ 404 (was 502). - Validation —
?page=/ slug / letter guards rejected before any upstream call; embedslang,ep,mal,anilistnow 400 on junk instead of being silently clamped or probed; schedule rejects impossible calendar dates (2026-13-45→ 400).
Changed
- Strict Qualities —
/api/stream/qualitiesanswers 415 when the URL isn't an HLS playlist and 502 when the fetch fails, instead of returningqualities: []with 200. - Proxy Upgrade — playlists rewrite every media reference (bare lines and
URI="…"on#EXT-X-KEY/#EXT-X-MAP), one bounded retry on network/429/5xx, segments are streamed withRangeforwarded, HTML bodies are rejected instead of served as media,Content-Typederives per extension; live allowlist now covers MegaPlay's current hosts (shiora.top,ivorysummit.world,nexabloom.top,eclipseharbor.space). - Schedule Defaults —
?date=is optional (defaults to today) and must be a realYYYY-MM-DDdate. - OpenAPI — 20 parameters flagged
required: trueto match the controllers that already 400 on them; refreshed descriptions for the seasons/watch-order sources + relation limitation, ranking windows, qualities415, embeds one-of and the numeric id types. - Docs —
docs/endpoints.md,docs/testing.md,docs/architecture.md,docs/index.mdand README synced to the new behaviour and the 64-test suite;docs/diagnostic-sweep.mdgained a status header pointing at this release.
Example
GET /api/seasons/naruto-eybxz → 4 seasons (Classic, Shippuden, …)
GET /api/seasons/1642 → { totalSeasons: 0 } # honest empty
GET /api/watch-order/1642 → 56 related entries, relation: "related"
GET /api/top-rankings?sort=month → 9 unique slugs, ranks 1–9
GET /api/schedule → today's airings (no date needed)
GET /api/schedule?date=2026-13-45 → 400 Invalid date
GET /api/stream/embeds?mal=21 → ids { malId: 21, anilistId: 21 }
GET /api/info?id=one-piece-odmau → rating "8.73", episodes null, clean titles
GET /api/definitely-not-a-route → JSON 404Verified
- Integration suite: 64 passed / 0 failed / 0 skipped (avg 401 ms)
- Full diagnostic sweep re-run: 97/97 requests, 0 × 5xx, 0 × 429 — statuses
{ 200: 50, 400: 33, 403: 3, 404: 11 } node --checkclean over all 94 JS files/api/health→2.6.1,/api/openapi→2.6.1/ 49 paths,/api/stats→ 42 endpoints- Bad-slug latency:
/episodes/<bad>0.5–1 s (was 13–16 s),/watch?slug=<bad>0.47 s, 429 + unknown-path replies verified JSON - No secrets tracked in git
Notes for API consumers
- Numeric identity fields (
animeId,malId,anilistId) are now numbers;info.episodesis a number ornull - Titles/descriptions are entity-decoded and whitespace-normalised
watch-orderentries all reportrelation: "related"until upstream fixes its placeholder labels- Invalid
sort/lang/dateand unknown/api/*paths now answer400/404instead of silently succeeding
Full changelog: CHANGELOG.md
End-to-end endpoint reference: docs/endpoints.md
Diagnostic sweep (cross-repo): docs/diagnostic-sweep.md