Control how long crawlapi spends on a request with the timeout field, and set your HTTP client timeout at least 5 seconds longer so your client never gives up right as the API finishes.
Setting timeout
| Setting | Range | Default | Behavior when exceeded |
|---|---|---|---|
timeout (request body) |
1,000–60,000 ms |
30,000 ms |
Returns 408 TIMEOUT (retryable: true) |
| HTTP client timeout | timeout + 5 seconds |
35–65 s |
Gives the server time to return its response cleanly |
curl -sS --max-time 50 https://api.crawlapi.dev/v1/scrape \
-H "Authorization: Bearer $CRAWLAPI_API_KEY" \
-H 'content-type: application/json' \
--data '{"url": "https://example.com", "timeout": 45000}'const response = await fetch('https://api.crawlapi.dev/v1/scrape', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRAWLAPI_API_KEY}`,
'content-type': 'application/json',
},
body: JSON.stringify({ url: 'https://example.com', timeout: 45000 }),
signal: AbortSignal.timeout(50_000),
});
const body = await response.json();
if (!body.success) throw new Error(`${body.error.code}: ${body.error.message}`);
console.log(body.data.markdown);import os
import requests
response = requests.post(
"https://api.crawlapi.dev/v1/scrape",
headers={"Authorization": f"Bearer {os.environ['CRAWLAPI_API_KEY']}"},
json={"url": "https://example.com", "timeout": 45000},
timeout=50,
)
body = response.json()
if not body["success"]:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
print(body["data"]["markdown"])Client timeouts and disconnects
- Client disconnects: Closing the connection early cancels in-flight work on the server.
- Avoid duplicate retries: Keep your HTTP client timeout longer than the request
timeout. If your client drops the socket right as the server finishes and immediately retries, the retry runs as a second request.
Choosing a deadline
| Workload | Request timeout |
HTTP client timeout |
|---|---|---|
| User-facing / interactive requests | 15,000–30,000 ms |
20–35 s |
| JavaScript-heavy apps or large PDFs | 45,000–60,000 ms |
50–65 s |
| Background jobs and URL batches | 30,000–60,000 ms |
65 s (or use crawl -i) |
Locale
Pages are requested in a locale matching the site’s country domain or URL path when present (such as .fr or /de-de/), and en-US otherwise.