CoolFace
Apppublic

srrexus/komicastapi

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

<div align="center">

๐Ÿ“š Komikcast API

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

![Next.js](https://nextjs.org) ![TypeScript](https://typescriptlang.org) ![Vercel](https://vercel.com) ![Hugging Face](https://huggingface.co/spaces) ![Cloudflare Workers](https://workers.cloudflare.com)

Live Demo ยท API Explorer ยท Report Bug

</div>

โœจ Features

  • โ€”๐Ÿš€ Blazing Fast โ€” Responses are aggressively cached on the Edge (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 โ€” Deploy to Vercel or Hugging Face Spaces with one push

๐Ÿ“ฆ API Endpoints

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

MethodEndpointDescriptionCache
GET/api/homeHome data โ€” banner, popular, latest, newest manga5 min
GET/api/latest?page=1Latest updated manga, paginated5 min
GET/api/popular?category=...Popular manga by category5 min
GET/api/genresList of all available genres1 hour
GET/api/advanceSearchFilter/search manga with query params5 min
GET/api/komik/:slugManga detail โ€” synopsis, genres, chapter list30 min
GET/api/komik/:slug/:chapterIdChapter images & prev/next navigation7 days
GET/api/proxy?url=...Image proxy โ€” bypasses hotlinking restrictions1 year

Popular Categories

?category=best-manhwa
?category=best-manhua
?category=best-manga
?category=anime-adaptations
?category=trending

Response Format

All endpoints return structured JSON:

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

Rate Limiting

HeaderDescription
X-RateLimit-LimitMaximum requests per window (60)
X-RateLimit-RemainingRemaining requests in current window
Retry-AfterSeconds until rate limit resets (on 429)

Bypass rate limit by sending your secret API key:

X-API-Key: your-secret-key

๐Ÿ› ๏ธ Tech Stack

ComponentTechnology
FrameworkNext.js 16 (App Router)
LanguageTypeScript
ScrapingCheerio + native fetch()
ProxyCloudflare Workers (free tier)
StylingTailwind CSS
AnalyticsVercel Analytics + Speed Insights

๐Ÿš€ Self-Hosting Guide

Prerequisites

1. Clone & Install

bash
git clone https://github.com/Wakype/komikcast-api.git
cd komikcast-api
pnpm install

2. Configure Environment

bash
cp .env.example .env.local

Edit .env.local:

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

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

# Optional: additional proxy fallbacks
SCRAPER_PROXY_URL_2=
SCRAPER_PROXY_URL_3=

# Optional: ScraperAPI key (alternative to CF Worker)
SCRAPER_API_KEY=

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

3. Deploy Cloudflare Worker

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

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

4. Run Locally

bash
pnpm dev

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


โ˜๏ธ Deploy to Vercel

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

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


๐Ÿค— Deploy to Hugging Face Spaces

This project supports auto-deploy to Hugging Face Spaces via GitHub Actions.

1. Add Dockerfile to project root

dockerfile
FROM node:22-alpine AS builder

WORKDIR /app

RUN corepack enable

COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

COPY . .
RUN pnpm build

FROM node:22-alpine AS runner

WORKDIR /app
ENV NODE_ENV=production
ENV PORT=7860

RUN corepack enable

COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 7860

CMD ["node", "server.js"]

2. Enable standalone output in next.config.ts

ts
const nextConfig: NextConfig = {
  output: 'standalone',
};

3. Create a Hugging Face Space

  1. 1.Login to huggingface.co โ†’ New Space
  2. 2.Choose SDK: Docker
  3. 3.Note your username and space-name

4. Get a Hugging Face Token

Go to huggingface.co/settings/tokens โ†’ New token โ†’ Role: Write

5. Add GitHub Secrets

Go to your GitHub repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions โ†’ New repository secret

SecretValue
HF_TOKENYour Hugging Face write token
HF_USERNAMEYour Hugging Face username
HF_SPACE_NAMEYour Space name
MANGA_BASE_URLTarget manga API base URL
BYPASS_SECRETYour bypass secret key
SCRAPER_PROXY_URLYour Cloudflare Worker URL
SCRAPER_API_KEY(optional) ScraperAPI key

6. Add the GitHub Action

Add .github/workflows/deploy-huggingface.yml to your repo (see the workflow file included in this repo). Every push to main will automatically build and deploy to your Space.


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Your Frontend  โ”‚โ”€โ”€โ”€โ”€โ†’โ”‚   API Server     โ”‚โ”€โ”€โ”€โ”€โ†’โ”‚  CF Worker     โ”‚โ”€โ”€โ”€โ”€โ†’ Target Site
โ”‚   + X-API-Key    โ”‚     โ”‚  (Next.js)       โ”‚     โ”‚  (Proxy)       โ”‚     (komikcast)
โ”‚                  โ”‚     โ”‚  Rate Limiter    โ”‚     โ”‚  Trusted IPs   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                               โ†‘
                          Random Users
                         (rate limited)

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


๐Ÿ“ Project Structure

komikcast-api/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ deploy-huggingface.yml  # Auto-deploy to HF Spaces
โ”œโ”€โ”€ 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
โ”œโ”€โ”€ Dockerfile             # For Hugging Face Spaces deployment
โ”œโ”€โ”€ .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