High-Performance, 100% Self-Hostable Web Scraping, Search & Screenshot REST API Engine for AI Agents
agents-api is a 100% self-hostable, open-source, Firecrawl & Tavily-compatible REST API engine designed for AI agents (Claude Code, Cursor, Windsurf, LangChain, LlamaIndex, AutoGen). Built with TypeScript, Patchright, CapSolver, LightPanda CDP, SearXNG, and Browserless Stealth.
Unlike proprietary cloud scraping services with per-request fees, bandwidth limits, and third-party data tracking:
- π 100% Data Privacy: Your scraped data, queries, and credentials stay entirely on your own infrastructure.
- β‘ Zero Per-Request Costs: Host on a low-cost VPS (Coolify, Hetzner, DigitalOcean, AWS) and run unlimited requests.
- π₯· Built-in Anti-Bot & Anti-Detection: Integrated Patchright binary-level stealth, CapSolver CAPTCHA auto-solving, and proxy rotation out of the box.
- π οΈ Full Control & Customizable: Spin up in 5 minutes via Docker Compose with zero external cloud dependencies.
- π Flexible Authentication: Run in open self-hosted mode or secure with your own Bearer API keys.
- π Meta-Search (
POST /v1/search): Aggregates search results from Google, Bing, DuckDuckGo simultaneously via built-in SearXNG β no paid API keys required. - π Web Scraping (
POST /v1/scrape): Convert any webpage into clean Markdown, HTML, Text, Links, or Screenshots using LightPanda CDP or Patchright Stealth engine. - πΈ Full-Page Screenshots (
POST /v1/screenshot): Capture full-page, high-resolution PNG/JPEG screenshots of complex SPAs and bot-protected sites. - π₯· Anti-Bot & CAPTCHA Solver: Built-in Patchright (binary-patched Chromium), CapSolver (Turnstile, reCAPTCHA, hCaptcha auto-solving), and Humanization.
- π Proxy Rotation & Sticky Sessions: Supports round-robin proxy lists, single rotating gateways (Webshare, Bright Data), and sticky sessions for crawling.
- πΈοΈ Async BFS Crawler (
POST /v1/crawl&GET /v1/crawl/:id): Asynchronously crawl entire domains with sticky proxy sessions, track progress, and poll results. - πΊοΈ URL Mapper (
POST /v1/map): Rapidly discover internal links on any site for sitemap generation or crawl planning. - π Built-in Docs SPA (
GET /): Embedded single-page documentation site with live code tabs, dark theme, and search. - π‘οΈ Enterprise Security: Timing-safe Bearer token auth, SSRF protection against internal IP ranges, and strict Zod runtime schema validation.
agents-api addresses all 4 layers of modern bot detection (Cloudflare, DataDome, Akamai, PerimeterX):
| Layer | Solution | Description |
|---|---|---|
| TLS & CDP Stealth | patchright |
Patches Chromium binary-level CDP signals (Runtime.enable), navigator.webdriver, and headless signatures without fragile JS injections. |
| CAPTCHA Challenges | CapSolver / 2Captcha | Auto-detects Cloudflare Turnstile, reCAPTCHA v2/v3, and hCaptcha widgets, solves via API, and injects solution tokens directly into page DOM. |
| IP Reputation | Dual-Mode ProxyManager |
Round-robin proxy list rotation, single rotating gateway endpoint support, and sticky session proxy locks. |
| Behavioral Telemetry | HumanizeUtils |
Generates Bezier-curved mouse trajectories, human typing delays (50msβ170ms), variable scroll cadence, and jittered pauses. |
βββββββββββββββββββββββββββββββββββββββββββ
β Client / AI Agent β
βββββββββββββββββββββ¬ββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β agents-api (Express + TypeScript :3000) β
β βββ Auth Middleware (Timing-Safe Bearer Token) β
β βββ Anti-Bot Suite (Patchright + CapSolver + ProxyManager + Humanize) β
β βββ SSRF Protection (Internal IP & Cloud Metadata Blocker) β
β βββ Zod Runtime Input Validation β
ββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββββββ¬ββββββ
β β β β
βΌ βΌ βΌ βΌ
π SearXNG πΌ LightPanda π Chrome π₯· Chrome-Stealth
(HTTP :8080) (CDP :9222) (CDP :3000) (CDP :3000)
Meta-Search Fast Web Scraping Heavy SPA Backup Anti-Fingerprint
Google+Bing+DDG & Crawling Complex SPAs Screenshots
git clone https://github.com/raakkan/agents-api.git
cd agents-apicp .env.example .envConfiguration variables in .env:
PORT=3000
API_KEY= # Optional: Bearer token (empty = open self-hosted mode)
NODE_ENV=production
# Proxy Configuration
PROXY_ENABLED=false # Set true to enable proxy rotation
PROXY_LIST= # Comma-separated list OR single rotating gateway URL
PROXY_STICKY_SESSIONS=false
# CAPTCHA Solver Configuration
CAPTCHA_SOLVER=capsolver # capsolver | 2captcha | anticaptcha
CAPTCHA_API_KEY= # Your CapSolver or 2Captcha API keydocker compose up -dcurl http://localhost:3000/healthResponse:
{ "success": true, "status": "ok", "version": "1.0.0", "uptime": 12.4 }Query Google, Bing, and DuckDuckGo in parallel.
curl -X POST http://localhost:3000/v1/search \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"renewable energy trends", "limit": 3}'Scrape any URL into Markdown, HTML, Text, or Links with optional proxy, humanization, and CAPTCHA solving.
curl -X POST http://localhost:3000/v1/scrape \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"formats": ["markdown", "html", "links"],
"profile": "fast",
"humanize": true,
"solveCaptcha": true,
"proxy": "http://user:pass@proxy.example.com:8080"
}'Capture a high-resolution PNG or JPEG screenshot.
curl -X POST http://localhost:3000/v1/screenshot \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"width": 1280,
"height": 800,
"format": "png",
"humanize": true
}' --output screenshot.pngExtract all same-domain internal links from a URL.
curl -X POST http://localhost:3000/v1/map \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://news.ycombinator.com", "limit": 10}'Asynchronously crawl an entire website up to maxPages with sticky proxy support.
# Start Crawl Job
CRAWL_RES=$(curl -s -X POST http://localhost:3000/v1/crawl \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"maxPages": 5,
"humanize": true,
"solveCaptcha": true
}')
# Extract Job ID and Poll Status
JOB_ID=$(echo $CRAWL_RES | jq -r '.jobId')
curl -s http://localhost:3000/v1/crawl/$JOB_ID -H "Authorization: Bearer $API_KEY"agents-api includes built-in security protections for production deployment:
- SSRF Protection: Automatically blocks requests attempting to target internal Docker services (
searxng,lightpanda,chrome), private IP ranges (127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16), or cloud metadata endpoints (169.254.169.254). - Timing-Safe Auth: Uses Node.js
crypto.timingSafeEqual()for Bearer token validation to eliminate side-channel timing attacks. - Zod Validation: Rejects invalid payloads before execution with detailed field-level error messages.
- Helmet & Rate Limiting: Includes security headers and configurable IP rate limiting out of the box.
agents-api is 100% self-hostable on Coolify or any Linux VPS.
- In Coolify, create a New Resource β Public/Private Git Repository.
- Connect your repo
https://github.com/raakkan/agents-api.git. - Set Build Pack to Docker Compose.
- Set Docker Compose Location to
/docker-compose.yml. - Enter your public domain in Coolify UI (e.g.
https://api.yourdomain.com). - Set Environment Variables in Coolify UI (
PORT=3000,API_KEY=your_secret,PROXY_LIST=...,CAPTCHA_API_KEY=...). - Click Deploy!
# Install dependencies
npm install
# Run TypeScript build
npm run build
# Run Jest unit & integration test suite (34 tests)
npm test
# Run test coverage
npm run test:coverageDistributed under the MIT License. See LICENSE for details.