An unofficial REST API for Animepahe that provides access to anime information, episodes, and streaming links with direct download support.
β οΈ IMPORTANT NOTICE: API MAYBE Temporarily Paused
The API maybe temporarily paused due to suspiciously too many requests. My hosted version of this API is only for testing purposes. You MUST host your own instance to use the API.
- π― Get currently airing anime
- π Search for specific anime
- π Browse complete anime list
- πΊ Get anime details and episodes
- π¬ Get streaming links with multiple resolutions
- π₯ Direct download links with quality options
- β‘ Optimized parallel processing for faster responses
- π± Check encoding queue status
- π Redis support for improved performance
- π‘οΈ Built-in DDoS protection bypass
- π Automatic cookie management
git clone https://github.com/ElijahCodes12345/animepahe-api.git
cd animepahe-api
npm install
npx playwright install
copy .env.example .envYou can also use this project as a Node.js library directly in your code without running a server.
Installation:
npm install github:ElijahCodes12345/animepahe-apiExample Usage:
const animepahe = require('animepahe-api');
// Search for anime
const searchResults = await animepahe.search('title');
console.log(searchResults);
// Get anime info
const info = await animepahe.getInfo('title');
console.log(info);
// Get episode releases
const episodes = await animepahe.getReleases('title', 'episode_desc', 1);
console.log(episodes);
// Get streaming links (m3u8 URLs and download links)
const streamingData = await animepahe.getStreamingLinks('anime-session-id', 'episode-session-id');
console.log(streamingData.sources); // HLS streams
console.log(streamingData.downloads); // Direct download linksIt works as it is but if you want you can create a .env file in the root directory:
PORT=3000 # Optional
BASE_URL=https://animepahe.pw # Optional
USER_AGENT= # Optional
COOKIES= # Optional - for manual cookie management
USE_PROXY=false
IFRAME_BASE_URL=kwik.cx # Optional - Base URL for the video iframe (default: kwik.cx)
PROXIES= # Optional - comma-separated proxy URLs
REDIS_URL= # Optional - Redis connection URL for caching (e.g., redis://user:pass@host:port)
ALLOWED_ORIGINS= # Optional - CORS configuration (see below)
RATE_LIMIT_SECRET= # Only set this if you want rate limiting (see Rate Limiting section below)
RATE_LIMIT_MAX=100 # Max requests per window (when rate limiting is active)
RATE_LIMIT_WINDOW=900 # Time window in seconds (when rate limiting is active)By default, the API will allow requests from all origins (*). To restrict access to specific domains:
# Allow all origins (default)
ALLOWED_ORIGINS=*
# Allow single origin
ALLOWED_ORIGINS=http://localhost:5173
# Allow multiple origins (comma-separated)
ALLOWED_ORIGINS=http://localhost:5173,https://mywebsite.com,https://another-site.comThe API supports Redis caching to improve performance and reduce load on the Animepahe servers. When REDIS_URL is provided, responses will be cached with the following durations:
- Queue status: 30 seconds
- Anime list: 1 hour
- Anime info: 1 day
- Play/stream info: 5 hours
You may edit these values as you see fit.
If REDIS_URL is not provided, the API will still work without caching.
This API includes optional rate limiting that only activates when the RATE_LIMIT_SECRET environment variable is set. This allows you to add rate limiting to your own deployment (like your Vercel instance) without affecting other people who might host their own instances.
To enable rate limiting on your deployment:
- Set a unique
RATE_LIMIT_SECRETvalue (e.g., a random UUID) - Configure
RATE_LIMIT_MAX(default: 100 requests per window) - Configure
RATE_LIMIT_WINDOWin seconds (default: 900 seconds = 15 minutes) - Configure
REDIS_URLfor persistent rate limiting across server instances (recommended for production use)
Note: Rate limiting requires Redis to function properly. If REDIS_URL is not configured, rate limiting will be automatically disabled even if RATE_LIMIT_SECRET is set. This ensures that other deployments without Redis continue to work normally.
When rate limiting is active, the API will return HTTP 429 status codes when limits are exceeded, along with rate limit headers:
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remaining in current windowX-RateLimit-Reset: Time when the current window resets
GET /api/airing
GET /api/airing?page=2
GET /api/search?q=your_search_query
GET /api/search?q=your_search_query&page=2
GET /api/anime
GET /api/anime?tab=A
GET /api/anime/:tag1/:tag2
GET /api/anime/:tag1/:tag2?tab=D
tag1 being eg: genre, Theme, etc. tag2 being eg: action, adventure, historical etc. Note: For tab use 'hash' instead of '#'
GET /api/:session # Get anime details using anime session ID
GET /api/:session/releases?sort=episode_desc&page=1 # Get episode list
GET /api/play/:session?episodeId=example # With downloads (default)
GET /api/play/:session?episodeId=example&downloads=false # Without downloads (faster)
GET /api/play/download-links?url=https://pahe.win/XYZ # To only get one download link
Note:
:sessionis the anime's unique identifierepisodeIdis the episode's unique identifier from the /releases endpoint- Use
downloads=falsefor faster responses if you only need streaming links- Important: When downloading the direct
.mp4video (thedownloadURL), you MUST pass the provideddownloadPageURL as theRefererheader to avoid errors.
GET /api/queue
The API returns errors in this format:
{
"status": 503,
"message": "Request failed"
}- Node.js
- Express
- Playwright
- @sparticuz/chromium
- Cheerio
- Axios
- cloudscraper
- jsdom
- vm
Special thanks to:
- Pal-droid for assistance in improving the project's logic and features.
- All the developers whose libraries made this project possible.
This project is licensed under the MIT License.
This project is not affiliated with or endorsed by Animepahe. It's an unofficial API created for educational purposes.
If you find this project helpful, please give it a βοΈ on GitHub!