mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
feat: upgrade to v2.0.0 with multi-mirror fallback, new endpoints, and LRU cache
- Add multi-mirror fallback system with 5 mirror domains - Add LRU cache with configurable TTL per endpoint - Add response compression (gzip) - Add Seasons endpoint (/api/seasons/:id) - Add Watch Order endpoint (/api/watch-order/:id) - Add Latest Updated endpoint (/api/latest-updated) - Add Download endpoint (/api/download) - Add cache stats endpoint (/api/cache/stats) - Add mirror status/reset endpoints (/api/mirrors, /api/mirrors/reset) - Add configurable rate limiting with X-RateLimit headers - Add request timeouts and entity too large handling - Update documentation with all new endpoints - Update CHANGELOG.md with v2.0.0 entry - Update package.json version to 2.0.0 - Add 6 AI agent prompts for development
This commit is contained in:
+17
-8
@@ -7,7 +7,7 @@ AniKotoAPI/
|
||||
├── server.js # Express entry point, port 4444
|
||||
├── package.json # name: "AniKotoAPI"
|
||||
├── vercel.json # Routes /api/* and /* to server.js
|
||||
├── .env # ANIKOTO_CHECK_SERVER_TS env var
|
||||
├── .env # Configuration (see .env.example)
|
||||
│
|
||||
├── public/ # Static files served from process.cwd()
|
||||
│ ├── index.html # Premium landing page (56KB, SVG icons, live console)
|
||||
@@ -21,7 +21,7 @@ AniKotoAPI/
|
||||
│
|
||||
├── docs/ # API documentation
|
||||
│ ├── index.md # Overview, quick start, features
|
||||
│ ├── endpoints.md # Full API reference (30 endpoints)
|
||||
│ ├── endpoints.md # Full API reference (33 endpoints)
|
||||
│ ├── streaming.md # Streaming flow guide (3-step)
|
||||
│ ├── examples.md # cURL, JavaScript, Python, Node.js
|
||||
│ └── architecture.md # This file
|
||||
@@ -33,7 +33,7 @@ AniKotoAPI/
|
||||
│ │ └── ids.config.js # Genre/type/status ID mappings
|
||||
│ │
|
||||
│ ├── routes/
|
||||
│ │ ├── apiRoutes.js # All route definitions
|
||||
│ │ ├── apiRoutes.js # All route definitions + OpenAPI spec
|
||||
│ │ └── category.route.js # genre/:name, type/:name, status/:name
|
||||
│ │
|
||||
│ ├── controllers/
|
||||
@@ -49,7 +49,7 @@ AniKotoAPI/
|
||||
│ │ ├── topten.controller.js # Top 10
|
||||
│ │ ├── schedule.controller.js # Schedule
|
||||
│ │ ├── random.controller.js # Random anime
|
||||
│ │ ├── newRelease.controller.js # New releases
|
||||
│ │ ├── newRelease.controller.js # New releases + Latest Updated
|
||||
│ │ ├── popular.controller.js # Most popular
|
||||
│ │ ├── category.controller.js # Genre filter
|
||||
│ │ ├── category.controller.js # Type filter
|
||||
@@ -68,17 +68,24 @@ AniKotoAPI/
|
||||
│ │ ├── topTen.extractor.js # Top 10
|
||||
│ │ ├── schedule.extractor.js # Schedule
|
||||
│ │ ├── random.extractor.js # Random anime
|
||||
│ │ ├── newRelease.extractor.js # New releases
|
||||
│ │ ├── newRelease.extractor.js # New releases + Latest Updated
|
||||
│ │ ├── mostPopular.extractor.js # Most popular
|
||||
│ │ ├── genre.extractor.js # Genre filter
|
||||
│ │ ├── type.extractor.js # Type filter
|
||||
│ │ ├── status.extractor.js # Status filter
|
||||
│ │ ├── filter.extractor.js # Advanced filter
|
||||
│ │ └── suggestion.extractor.js # Suggestions
|
||||
│ │ ├── suggestion.extractor.js # Suggestions
|
||||
│ │ ├── seasons.extractor.js # Seasons/OVAs/movies
|
||||
│ │ ├── watchOrder.extractor.js # Watch order
|
||||
│ │ └── download.extractor.js # Download links
|
||||
│ │
|
||||
│ └── helper/
|
||||
│ └── cache.helper.js # In-memory Map cache, 5-min TTL
|
||||
│ ├── cache.helper.js # LRU cache with configurable TTL
|
||||
│ ├── mirror.helper.js # Multi-mirror fallback (5 domains)
|
||||
│ └── extractPages.helper.js # Page fetching with mirror fallback
|
||||
│
|
||||
├── test.js # Test suite (27 tests)
|
||||
├── agents/ # AI agent prompts (6 agents)
|
||||
└── CHANGELOG.md # Version history
|
||||
```
|
||||
|
||||
@@ -90,7 +97,9 @@ AniKotoAPI/
|
||||
| Framework | Express.js |
|
||||
| Scraping | Cheerio + Axios |
|
||||
| Deployment | Vercel (Serverless) |
|
||||
| Caching | In-memory Map with 5-min TTL |
|
||||
| Caching | LRU cache with configurable TTL |
|
||||
| Compression | gzip (level 6, 1024 byte threshold) |
|
||||
| Mirror Fallback | 5 mirror domains with health checks |
|
||||
| Static Files | Express static middleware |
|
||||
|
||||
## Request Flow
|
||||
|
||||
+41
-8
@@ -554,33 +554,66 @@ Returns trending anime for sidebar display.
|
||||
|
||||
## GET /seasons/:id
|
||||
|
||||
Get season information for an anime.
|
||||
Get all seasons for an anime (main season, OVAs, movies, specials).
|
||||
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `id` | string | Yes | Anime slug |
|
||||
| `id` | number | Yes | Anime numeric ID |
|
||||
|
||||
```bash
|
||||
curl "https://anikototvapi.vercel.app/api/seasons/one-piece-100"
|
||||
curl "https://anikototvapi.vercel.app/api/seasons/1642"
|
||||
```
|
||||
|
||||
Returns season data including related seasons.
|
||||
Returns all seasons including OVAs, movies, and specials for the anime.
|
||||
|
||||
---
|
||||
|
||||
## GET /watch-order/:id
|
||||
|
||||
Get recommended watch order for an anime.
|
||||
Get recommended watch order for an anime franchise.
|
||||
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `id` | string | Yes | Anime slug |
|
||||
| `id` | number | Yes | Anime numeric ID |
|
||||
|
||||
```bash
|
||||
curl "https://anikototvapi.vercel.app/api/watch-order/one-piece-100"
|
||||
curl "https://anikototvapi.vercel.app/api/watch-order/1642"
|
||||
```
|
||||
|
||||
Returns recommended watch order sequence.
|
||||
Returns recommended watch order sequence with relationship types.
|
||||
|
||||
---
|
||||
|
||||
## GET /latest-updated
|
||||
|
||||
Get recently updated anime sorted by update time.
|
||||
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `page` | number | No | Page number (default: 1) |
|
||||
|
||||
```bash
|
||||
curl "https://anikototvapi.vercel.app/api/latest-updated"
|
||||
```
|
||||
|
||||
Returns paginated list of recently updated anime.
|
||||
|
||||
---
|
||||
|
||||
## GET /download
|
||||
|
||||
Get download links for an anime episode.
|
||||
|
||||
| Param | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `slug` | string | Yes | Anime slug |
|
||||
| `ep` | number | Yes | Episode number |
|
||||
|
||||
```bash
|
||||
curl "https://anikototvapi.vercel.app/api/download?slug=one-piece-odmau&ep=1165"
|
||||
```
|
||||
|
||||
Returns decoded download links for the specified episode.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -363,3 +363,67 @@ async function getSchedule() {
|
||||
|
||||
getSchedule();
|
||||
```
|
||||
|
||||
### Latest Updated
|
||||
|
||||
```javascript
|
||||
const axios = require('axios');
|
||||
|
||||
async function getLatestUpdated(page = 1) {
|
||||
const { data } = await axios.get('https://anikototvapi.vercel.app/api/latest-updated', {
|
||||
params: { page }
|
||||
});
|
||||
|
||||
console.log('Recently updated anime:', data.results.length);
|
||||
return data.results;
|
||||
}
|
||||
|
||||
getLatestUpdated();
|
||||
```
|
||||
|
||||
### Seasons
|
||||
|
||||
```javascript
|
||||
const axios = require('axios');
|
||||
|
||||
async function getSeasons(animeId) {
|
||||
const { data } = await axios.get(`https://anikototvapi.vercel.app/api/seasons/${animeId}`);
|
||||
|
||||
console.log('Seasons:', data.results.length);
|
||||
return data.results;
|
||||
}
|
||||
|
||||
getSeasons(1642);
|
||||
```
|
||||
|
||||
### Watch Order
|
||||
|
||||
```javascript
|
||||
const axios = require('axios');
|
||||
|
||||
async function getWatchOrder(animeId) {
|
||||
const { data } = await axios.get(`https://anikototvapi.vercel.app/api/watch-order/${animeId}`);
|
||||
|
||||
console.log('Watch order entries:', data.results.length);
|
||||
return data.results;
|
||||
}
|
||||
|
||||
getWatchOrder(1642);
|
||||
```
|
||||
|
||||
### Download Links
|
||||
|
||||
```javascript
|
||||
const axios = require('axios');
|
||||
|
||||
async function getDownloadLinks(slug, episode) {
|
||||
const { data } = await axios.get('https://anikototvapi.vercel.app/api/download', {
|
||||
params: { slug, ep: episode }
|
||||
});
|
||||
|
||||
console.log('Download links:', data.results);
|
||||
return data.results;
|
||||
}
|
||||
|
||||
getDownloadLinks('one-piece-odmau', 1165);
|
||||
```
|
||||
|
||||
+5
-3
@@ -57,9 +57,11 @@ curl "https://anikototvapi.vercel.app/api/info?id=road-of-naruto-ggjw8"
|
||||
|
||||
## Features
|
||||
|
||||
- **30 Endpoints** — Home, search, info, episodes, streaming, schedule, and more
|
||||
- **33 Endpoints** — Home, search, info, episodes, streaming, schedule, seasons, watch order, download, and more
|
||||
- **No API Key** — Just make requests, no registration needed
|
||||
- **In-Memory Cache** — 5-minute TTL for fast responses
|
||||
- **LRU Cache** — Configurable TTL per endpoint type (3min to 60min)
|
||||
- **Multi-Mirror Fallback** — Automatic failover across 5 mirror domains
|
||||
- **Response Compression** — Gzip compression for faster responses
|
||||
- **CORS Enabled** — Access from any domain
|
||||
- **JSON Responses** — Standardized `{success, results}` format
|
||||
|
||||
@@ -92,7 +94,7 @@ Error responses:
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
There are no explicit rate limits, but the API uses a 5-minute in-memory cache. Repeated requests for the same data will be served from cache.
|
||||
Rate limiting is configurable via environment variables (`RATE_LIMIT`, `RATE_WINDOW`). Default is 100 requests per 60 seconds per IP. Includes `X-RateLimit-Limit` and `X-RateLimit-Remaining` headers.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
@@ -272,3 +272,30 @@ curl "https://anikototvapi.vercel.app/api/watch?slug=road-of-naruto-ggjw8&ep=1"
|
||||
- Next episode schedule
|
||||
|
||||
This is useful when you need all watch page data at once instead of making 3 separate requests.
|
||||
|
||||
---
|
||||
|
||||
## Download Links
|
||||
|
||||
For downloading episodes, use the `/download` endpoint which returns decoded download links.
|
||||
|
||||
**Request:**
|
||||
|
||||
```bash
|
||||
curl "https://anikototvapi.vercel.app/api/download?slug=one-piece-odmau&ep=1165"
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"results": {
|
||||
"downloadLinks": [...],
|
||||
"episodeNumber": 1165,
|
||||
"title": "One Piece"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> **Note:** Download links are decoded from base64 data and may require browser interaction due to Cloudflare protection on some hosts.
|
||||
|
||||
Reference in New Issue
Block a user