Skip to content

Wakype/komikcast-api

Repository files navigation

πŸ“š Komikcast API

A fast, free, and open-source REST API for manga data

Next.js TypeScript Vercel Cloudflare Workers

Live Demo Β· API Explorer Β· Report Bug

✨ Features

  • πŸš€ Blazing Fast β€” Responses are aggressively cached on Vercel's Edge Network (5 min to 7 days)
  • πŸ”‘ API Key Support β€” Your own apps get unlimited access with a secret bypass key
  • πŸ›‘οΈ Rate Limited β€” Built-in per-IP rate limiting (60 req/min) to prevent abuse
  • πŸ–ΌοΈ Image Proxy β€” Built-in proxy to bypass hotlinking and CORS restrictions
  • πŸ“– Interactive Docs β€” API Explorer dashboard at /api
  • 🌐 Cloudflare Bypass β€” CF Worker proxy to avoid 403 blocks on serverless platforms
  • πŸ“¦ Self-Hostable β€” Clone it, set your env vars, and deploy your own instance

πŸ“¦ API Endpoints

Base URL: https://your-deployment.vercel.app

Method Endpoint Description Cache
GET /api/home Home data β€” banner, popular, latest, newest manga 5 min
GET /api/komik/:slug Manga detail β€” synopsis, genres, chapter list 30 min
GET /api/komik/:slug/:chapterId Chapter images & prev/next navigation 7 days
GET /api/proxy?url=... Image proxy β€” bypasses hotlinking restrictions 1 year
Check more in API Docs

Response Format

All endpoints return structured JSON:

{
  "status": 200,
  "message": "Success",
  "data": { ... }
}

Rate Limiting

Header Description
X-RateLimit-Limit Maximum requests per window (60)
X-RateLimit-Remaining Remaining requests in current window
Retry-After Seconds until rate limit resets (on 429)

Bypass rate limit by sending your secret API key:

X-API-Key: your-secret-key

πŸ› οΈ Tech Stack

Component Technology
Framework Next.js 16 (App Router)
Language TypeScript
Scraping Cheerio + native fetch()
Proxy Cloudflare Workers (free tier)
Styling Tailwind CSS
Analytics Vercel Analytics + Speed Insights

πŸš€ Self-Hosting Guide

Prerequisites

1. Clone & Install

git clone https://github.com/Wakype/komikcast-api.git
cd komikcast-api
pnpm install # or npm install

2. Configure Environment

cp .env.example .env.local

Edit .env.local:

# Required: Target manga site URL
MANGA_BASE_URL=https://be.komikcast.cc/

# Required for Vercel deploy: Your CF Worker proxy URL
SCRAPER_PROXY_URL=https://your-worker.your-subdomain.workers.dev

# Optional: Secret key for rate limit bypass
BYPASS_SECRET=your-super-secret-key

3. Deploy Cloudflare Worker

The Vercel deployment needs a Cloudflare Worker to bypass Cloudflare's IP blocking. The worker code is at cloudflare-worker/worker.js.

  1. Go to Cloudflare Dashboard β†’ Workers & Pages β†’ Create Worker
  2. Name it (e.g., komikcast-proxy) β†’ click Deploy
  3. Click Edit Code β†’ paste the contents of cloudflare-worker/worker.js
  4. In Worker Settings β†’ Variables, add: BYPASS_SECRET = same value as your .env.local
  5. Click Deploy
  6. Copy the Worker URL and set it as SCRAPER_PROXY_URL in your Vercel environment

4. Run Locally

pnpm dev

Open http://localhost:3000 to see the landing page, or http://localhost:3000/api for the API Explorer.

5. Deploy to Vercel

# Push to GitHub, then import in Vercel
# Or use Vercel CLI:
npx vercel

Set environment variables in Vercel β†’ Project β†’ Settings β†’ Environment Variables.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Your Frontend  │────→│   Vercel API     │────→│  CF Worker     │────→ Target Site
β”‚   + X-API-Key    β”‚     β”‚  (Next.js)       β”‚     β”‚  (Proxy)       β”‚     (komikcast)
β”‚                  β”‚     β”‚  Rate Limiter    β”‚     β”‚  Trusted IPs   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               ↑
                          Random Users
                         (rate limited)

Why Cloudflare Worker? Vercel's serverless functions run on datacenter IPs that Cloudflare actively blocks. By routing requests through a CF Worker (which runs inside Cloudflare's own network), the requests are treated as trusted.


πŸ“ Project Structure

komikcast-api/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/               # API endpoints + Explorer UI
β”‚   β”œβ”€β”€ legal/             # Legal pages (Terms, Privacy, DMCA)
β”‚   └── page.tsx           # Landing page
β”œβ”€β”€ cloudflare-worker/     # CF Worker proxy (deploy separately)
β”œβ”€β”€ libs/                  # Scraper core (fetchAPI, fetchPage)
β”œβ”€β”€ types/                 # TypeScript interfaces
β”œβ”€β”€ utils/                 # Response helpers, cache utilities
β”œβ”€β”€ proxy.ts               # Rate limiting (Next.js proxy convention)
β”œβ”€β”€ .env.example           # Environment variable template
└── AGENTS.md              # AI coding assistant guide

⚠️ Legal Disclaimer

This API is provided for educational purposes and personal projects only. The creator is not responsible for how you use the data. We do not host any manga, images, or copyrighted content. All content belongs to their respective copyright holders.


πŸ“ License

MIT License

Made with ❀️ by waky.dev