Skip to content

HTTP API

PAM Crawl includes an HTTP API that speaks Crawl4AI’s request and response shapes on Crawl4AI’s port, 11235. Existing Crawl4AI clients can point at it unchanged, and any language can use it to fetch Markdown, crawl sites, extract data or discover URLs.

The server runs on the PAM runtime’s built-in HTTP server: persistent workers, no framework and no web server in front. Warm HTTP/2 connections, robots.txt rules and caches survive between requests inside each worker.

Terminal window
pam crawl serve --port 11235 # one worker on 127.0.0.1:11235
pam crawl serve --workers 4 --token secret # PAM cluster with bearer auth

Outside a PAM project, use pam vendor/bin/crawl serve with the same options. You may also start the bundled front controller directly with pam start:

Terminal window
CRAWL_HOST=0.0.0.0 pam start vendor/pushinbr/pam-crawl/server.php --workers 4
Option Environment variable Default
--host CRAWL_HOST 127.0.0.1
--port, -p CRAWL_PORT 11235
--workers, -w 1
--token CRAWL_API_TOKEN none
--allow-private CRAWL_ALLOW_PRIVATE=1 off
--cache [path] CRAWL_CACHE=path or 1 off

The server listens on 127.0.0.1 by default; pass --host 0.0.0.0 only when you mean to expose it. Open http://127.0.0.1:11235/playground to build requests interactively and /dashboard for live statistics.

For development on plain PHP, serve falls back to PHP’s built-in web server (a single process). Under PHP-FPM, use server.php as the front controller, or call Pam\Crawl\Server\Bootstrap::handleGlobals() from a route:

Terminal window
php -S 127.0.0.1:11235 vendor/pushinbr/pam-crawl/server.php

Every endpoint takes and returns JSON. When the server has a token, send it as a bearer token:

Terminal window
B=http://127.0.0.1:11235
AUTH='Authorization: Bearer secret'
curl -s $B/health
curl -s -X POST $B/md -H "$AUTH" -H 'content-type: application/json' \
-d '{"url": "https://example.com", "f": "fit"}'
Response
{"url":"https://example.com","filter":"fit","query":null,"cache":"0","markdown":"...","success":true}

POST /md returns one page as Markdown. f selects the filter: fit (main content), raw (whole page), bm25 (sections relevant to q), pruning or llm:

Terminal window
curl -s -X POST $B/md -H 'content-type: application/json' \
-d '{"url": "https://docs.python.org/3/library/asyncio-task.html", "f": "bm25", "q": "task cancellation timeout"}'

POST /crawl takes up to 100 URLs and returns Crawl4AI result objects (Markdown, links, media, metadata). POST /crawl/stream returns the same results as NDJSON, one per line as they complete, followed by {"status":"completed"}:

Terminal window
curl -s -X POST $B/crawl -H 'content-type: application/json' \
-d '{"urls": ["https://example.com", "https://quotes.toscrape.com/"]}'
curl -sN -X POST $B/crawl/stream -H 'content-type: application/json' \
-d '{"urls": ["https://example.com", "https://quotes.toscrape.com/"]}'

Pass Crawl4AI’s crawler_config for deep crawls and other run options:

Terminal window
curl -s -X POST $B/crawl -H 'content-type: application/json' -d '{
"urls": ["https://docs.python.org/3/tutorial/index.html"],
"crawler_config": {"type": "CrawlerRunConfig", "params": {
"deep_crawl_strategy": {"type": "BFSDeepCrawlStrategy", "params": {"max_depth": 1, "max_pages": 5}}}}}'

POST /extract runs a Crawl4AI CSS/XPath schema, or hydrates a DTO class with dto (and optionally each):

Terminal window
curl -s -X POST $B/extract -H 'content-type: application/json' -d '{
"url": "https://quotes.toscrape.com/",
"schema": {"baseSelector": "div.quote", "fields": [
{"name": "text", "selector": "span.text", "type": "text"},
{"name": "author", "selector": "small.author", "type": "text"}]}}'

POST /seed lists a domain’s URLs from sitemaps and, with "source": "sitemap+cc", Common Crawl:

Terminal window
curl -s -X POST $B/seed -H 'content-type: application/json' \
-d '{"domain": "www.php.net", "source": "sitemap", "pattern": "*ChangeLog*", "limit": 5}'

Long crawls can run as jobs. POST /crawl/job answers 202 with a task_id; poll GET /crawl/job/{id} until the status is final, or add a webhook_config to be notified:

Terminal window
curl -s -X POST $B/crawl/job -H 'content-type: application/json' -d '{
"urls": ["https://example.com"],
"webhook_config": {
"webhook_url": "https://hooks.example.com/crawl",
"webhook_data_in_payload": true,
"webhook_headers": {"X-Signature": "my-shared-secret"}}}'
curl -s $B/crawl/job/crawl_xxxxxxxxxxxx

The webhook receives task_id, task_type, status, timestamp and urls, plus data (when webhook_data_in_payload is true) or error. Delivery is retried with exponential back-off on network errors, 429 and 5xx responses. Webhook URLs pass the same SSRF guard as crawl targets.

Jobs run in detached processes, and their store is shared by all workers. POST /llm/job and GET /llm/job/{id} work the same way for LLM extraction.

GET /llm/{url}?q=..., POST /llm/job and POST /md with "f": "llm" use the LLM configured in the server’s environment: LLM_PROVIDER (or CRAWL_LLM_PROVIDER) and the provider’s key, such as OPENAI_API_KEY, ANTHROPIC_API_KEY or GEMINI_API_KEY. See LLM Features.

POST /screenshot, POST /pdf and POST /execute_js need the browser plugin. Without it they answer 501 with an install hint. Screenshots and PDFs come back base64-encoded.

Terminal window
curl -s -X POST $B/screenshot -H 'content-type: application/json' \
-d '{"url": "https://example.com"}' | jq -r .screenshot | base64 -d > example.png
Endpoint Body or query Returns
POST /crawl {urls[1..100], crawler_config?, browser_config?, options?, include_html?} {success, results[], server_processing_time_s}
POST /crawl/stream same as /crawl NDJSON, then {"status":"completed"}
POST /md {url, f: fit|raw|bm25|pruning|llm, q?, c?} {url, filter, query, cache, markdown, success}
POST /html {url} {html, url, success} (cleaned, schema-ready)
POST /extract {url, schema} or {url, dto, each?} {success, url, data}
POST /seed {domain, limit?, pattern?, source?, query?} {success, domain, count, urls[]}
POST /crawl/job, GET /crawl/job/{id} crawl body + webhook_config? 202 {task_id}, then {status, result|error}
POST /llm/job, GET /llm/job/{id}, GET /llm/{url}?q= {url, q, schema?} LLM answer or extraction
POST /screenshot, POST /pdf {url, screenshot_wait_for?, wait_for_images?}, {url} {success, screenshot}, {success, pdf}
POST /execute_js {url, scripts[]} crawl result + js_execution_result
POST /mcp, GET /mcp/sse, POST /mcp/messages/ JSON-RPC 2.0 MCP
GET /ask ?query=&context_type=doc|code|all&score_ratio=0.5&max_results=20 BM25 hits over the package’s own README and code
GET /playground, GET /dashboard (/monitor) Request builder, live statistics
GET /health, GET /metrics, GET /schema ?format=json on metrics Status, Prometheus text or JSON, option reference

Errors use HTTP status codes: 400 for invalid input, 401 for a missing token, 413 for an oversized body, 429 when the server is busy (with Retry-After), 501 for a missing plugin and 502 when the crawl or the LLM fails.

/playground and /dashboard are self-contained pages with no CDN or build step. The dashboard polls /metrics?format=json every 2 seconds, and only while its tab is visible. The PAM runtime’s own metrics move to /_pam/metrics so that /metrics serves the crawler’s.

The API is safe to run next to other services out of the box:

  • Authentication. With CRAWL_API_TOKEN set, every endpoint except /health, /playground and /dashboard requires Authorization: Bearer <token>. The public pages carry no data; they call the API with the token you type in.
  • SSRF guard. Private, loopback, link-local and cloud metadata addresses are refused, and the connected peer IP is checked again on every transfer, including redirects and deep-crawl links. CRAWL_ALLOWED_HOSTS (when set, only these hosts and their subdomains) and CRAWL_BLOCKED_HOSTS (always refused) take comma-separated host lists. CRAWL_ALLOW_PRIVATE=1 turns the guard off.
  • Limits. Each request is bounded, and every bound has an environment variable.
Variable Default Limit
CRAWL_MAX_URLS 100 URLs per request
CRAWL_MAX_PAGES 100 Pages per request
CRAWL_MAX_DEPTH 5 Deep-crawl depth
CRAWL_MAX_CONCURRENCY 64 Parallel requests
CRAWL_DEADLINE 120 Seconds per request
CRAWL_MAX_BODY 1048576 Request body bytes
CRAWL_MAX_OUTPUT_CHARS 200000 Characters of output
CRAWL_MAX_JOBS 500 Stored jobs
CRAWL_MAX_RUNNING_JOBS 4 Jobs running at once
CRAWL_JOB_TTL 3600 Seconds a finished job is kept
CRAWL_JOB_TIMEOUT 900 Seconds a job may run
CRAWL_MAX_JOB_BYTES 33554432 Bytes of a stored job result

CRAWL_STATE_DIR holds jobs, metrics and MCP sessions shared by all workers (default: a pam-crawl-<uid> directory in the system temp directory).

The repository includes a Dockerfile and a docker-compose.yml. The image ships the PAM runtime (installed with the official installer), poppler-utils for PDFs and the package, and runs pam start server.php as a non-root user on port 11235:

Terminal window
docker build -t pam-crawl .
docker run -d -p 127.0.0.1:11235:11235 -e CRAWL_API_TOKEN=secret pam-crawl
curl localhost:11235/health
docker compose up -d # resource-limited service with a healthcheck
docker compose --profile browser up -d crawl-browser # Chromium + the browser plugin on :11236

Configure the container with the variables above plus CRAWL_WORKERS (default 2) and your LLM keys. State and metrics live in the /data volume. Pin the runtime version with --build-arg PAM_VERSION=v2.2.27.


This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).