Case Study
Hayainime API
A Go-based REST API backend that scrapes anime data from Otakudesu and exposes it through a contract-first API design, Redis caching, rate limiting, API key protection, and a deployment-ready workflow.
Hayainime API is a backend REST API I built to extract and serve anime data from Otakudesu in a more consistent, structured format that is ready to be consumed by frontend applications or third-party clients. The main goal was not just to scrape pages, but to wrap a fragile data source into an API service that is more stable, well documented, and safe to use as a product foundation.
The project covers endpoints for homepage aggregation, release schedule, ongoing and complete anime lists, genres, anime detail, episode lists, stream mirrors, search, and batch download links. There are also helper endpoints to resolve stream tokens into final URLs, which makes the consumption workflow much more practical for client applications.
Key Features
- Anime Scraping Backend: Pulls anime, episode, genre, schedule, and batch link data from third-party web sources and serves it as a REST API.
- Stream Resolution Helpers: Provides endpoints to resolve single and bulk stream tokens into final URLs that are ready to use.
- Contract-First API Design: Designed with a consistent response envelope, human-readable docs, and a separate OpenAPI specification.
- Operational Hardening: API key protection, per-IP rate limiting, request validation, and a uniform error taxonomy that makes client debugging easier.
- Redis Caching Layer: Scraping results can be cached to reduce repeated requests to external sources and improve service responsiveness.
- Deployment-Ready Setup: Comes with a VPS deploy script, binary update flow, environment contract, and a quality gate for a more disciplined production workflow.
Technical Challenge
The hardest part of this project was turning a scraping source that is fragile and changes often into an API that stays predictable for consumers. The target HTML structure can change at any time, scraping responses can be slow or fail, and stream mirror endpoints need extra handling to stay safe and convenient for clients.
The fix was a layered backend architecture: Handler → Service → Repository Interface → Scraper Implementation. HTTP logic, business flow, and the scraper never sit in the same layer. For reliability, Redis sits in front of the scraper as a cache, middleware enforces API key and rate limiting, and an error taxonomy maps scraper failures into consistent API responses like SCRAPER_UNAVAILABLE, VALIDATION_ERROR, and RATE_LIMITED. This makes the service easier to test, maintain, and extend.
Tech Stack
- Language: Go
- HTTP Framework: Fiber
- Scraping: Colly, GoQuery
- Caching: Redis
- Validation: go-playground/validator
- Architecture: Layered service with repository abstraction and contract-first API docs
