A comprehensive RESTful API for scraping anime content from toonstream.one
Optimized for Cloudflare Workers
Features • Installation • Configuration • Deployment • API Endpoints
- Home Page Data - Latest series, movies, and schedules
- Search Engine - Full-text search with pagination
- Anime Details - Comprehensive information with related content
- Episode Streaming - Extract video sources and links
- Category Browsing - Filter by genre, language, type
- Release Schedule - Weekly anime release calendar
- Embed Player - Optimized, ad-free player embed
- Random Content - Get random movies or series
- Latest Content - Get latest movies or series
- Serverless - Built for Cloudflare Workers
- High Performance - Edge caching system
- Error Handling - Comprehensive error responses
- API Documentation - Interactive Swagger UI
- Cloudflare Bypass - Axios + cookie jar support
- Ad Blocking - Brave-style ad blocking for embeds
- Node.js (v18+)
- Wrangler CLI
- Cloudflare Account
# Clone repository
git clone https://github.com/ryanwtf88/toonstream-api.git
cd toonstream-api
# Install dependencies
npm install
# Start development server
npm run devThe server will be running at http://localhost:8787
Edit wrangler.toml:
name = "toonstream-api"
main = "src/worker.js"
compatibility_date = "2024-11-29"
compatibility_flags = ["nodejs_compat"]
account_id = "your-cloudflare-account-id" # Replace with your Cloudflare Account ID
[observability]
enabled = trueFinding Your Account ID:
- Log in to Cloudflare Dashboard
- Select your account
- Copy Account ID from the right sidebar
Edit config.js:
export default {
port: 3030,
baseUrl: 'https://toonstream.one',
cacheTTL: 3600,
rateLimit: {
windowMs: 60000,
maxRequests: 100
}
};npx wrangler loginUpdate wrangler.toml with your Cloudflare Account ID:
account_id = "your-cloudflare-account-id"npm run deployYour API will be deployed to: https://toonstream-api.<your-subdomain>.workers.dev
- Go to Cloudflare Dashboard
- Navigate to Workers & Pages
- Select your worker
- Go to Settings > Triggers
- Add Custom Domain
https://your-worker.workers.dev
- Interactive Docs:
GET /(Swagger UI) - JSON Endpoint List:
GET /docs - OpenAPI Spec:
GET /api/openapi.json
GET /api/homeGet homepage data with latest series, movies, and schedule.
Response:
{
"latestSeries": [...],
"latestMovies": [...],
"trending": [...],
"schedule": {...}
}GET /api/search?keyword={query}&page={page}Search for anime by keyword.
Parameters:
keyword(required) - Search querypage(optional) - Page number (default: 1)
Response:
{
"success": true,
"results": [...],
"pagination": {...}
}GET /api/search/suggestions?keyword={query}Get search suggestions for autocomplete.
GET /api/anime/{id}Get detailed information about a specific anime.
Response:
{
"success": true,
"id": "anime-id",
"title": "Anime Title",
"poster": "...",
"description": "...",
"genres": [...],
"languages": [...],
"seasons": {...},
"related": [...]
}GET /api/episode/{id}Get streaming links for an episode.
Response:
{
"success": true,
"sources": [...],
"downloads": [...],
"servers": [...]
}GET /api/episode/{id}/servers/{serverId}Get specific server links for an episode.
GET /api/categoriesGet list of all available categories.
GET /api/category/{name}?page={page}Get anime by category.
Examples:
/api/category/action/api/category/romance?page=2
GET /api/category/language/{lang}?page={page}Get anime by language.
Supported Languages:
hinditamilteluguenglish
GET /api/category/type/movies?page={page}Get anime movies.
GET /api/category/type/series?page={page}Get anime series.
GET /api/category/latest/movies?page={page}Get latest anime movies.
GET /api/category/latest/series?page={page}Get latest anime series.
GET /api/category/random/movieGet a random anime movie.
GET /api/category/random/seriesGet a random anime series.
GET /api/scheduleGet weekly release schedule.
Response:
{
"success": true,
"schedule": {
"monday": [...],
"tuesday": [...],
...
}
}GET /api/schedule/{day}Get schedule for a specific day.
Days: monday, tuesday, wednesday, thursday, friday, saturday, sunday
GET /embed/{id}Get optimized, ad-free player embed.
Features:
- Clean iframe extraction
- Ad blocking
- Loading overlay
- Caching
{
"success": true,
"data": {
...
}
}{
"success": false,
"error": "Error message"
}toonstream-api/
├── config.js # Configuration
├── src/
│ ├── worker.js # Cloudflare Worker Entry Point
│ ├── app.js # Main Hono Application
│ ├── routes/ # API Routes
│ │ ├── home.js
│ │ ├── search.js
│ │ ├── anime.js
│ │ ├── episodes.js
│ │ ├── categories.js
│ │ ├── schedule.js
│ │ └── embed.js
│ ├── scrapers/ # Web Scrapers
│ │ ├── home.js
│ │ ├── search.js
│ │ ├── anime.js
│ │ ├── streaming.js
│ │ ├── categories.js
│ │ └── schedule.js
│ └── utils/
│ ├── scraper.js # Scraping Utilities
│ └── cache.js # Worker-Compatible Cache
├── package.json
├── wrangler.toml # Cloudflare Configuration
└── README.md
| Technology | Purpose |
|---|---|
| Edge Platform | |
| Web Framework | |
| HTTP Client | |
| HTML Parsing |
# Development mode with hot reload
npm run dev
# Deploy to Cloudflare Workers
npm run deploy
# Lint code
npm run lint
# Format code
npm run lint:fixAccount ID Missing
Error: Missing account_id in wrangler.tomlSolution: Add your Cloudflare Account ID to wrangler.toml
Authentication Error
Error: Not authenticatedSolution: Run npx wrangler login
Build Errors
Error: nodejs_compat flag requiredSolution: Ensure compatibility_flags = ["nodejs_compat"] is in wrangler.toml
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Warning: This API is for educational purposes only. Web scraping may violate the website's Terms of Service. Use responsibly and at your own risk.