https://api.crawlapi.dev/v1/scrapeRequest
curl -sS https://api.crawlapi.dev/v1/scrape \
-H "Authorization: Bearer $CRAWLAPI_API_KEY" \
-H 'content-type: application/json' \
--data '{"url": "https://example.com", "format": "markdown"}'import os
import httpx
response = httpx.post(
"https://api.crawlapi.dev/v1/scrape",
headers={"Authorization": f"Bearer {os.environ['CRAWLAPI_API_KEY']}"},
json={"url": "https://example.com", "format": "markdown"},
timeout=60.0,
)
body = response.json()
if not body["success"]:
print(body["error"]["code"], body["error"]["retryable"])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', format: 'markdown' }),
});
const body = await response.json();
if (!response.ok) {
console.log(body.error.code, body.error.retryable);
}Authorization
Every request carries a key from app.crawlapi.dev/keys. A missing, unknown, revoked or suspended key answers 401 UNAUTHORIZED, and so do two different keys in one request (both headers with the same key is one key).
Every request carries a key from app.crawlapi.dev/keys, as Authorization: Bearer <key> or x-api-key. A missing, unknown, revoked or suspended key answers 401 UNAUTHORIZED, and so do two different keys in one request (both headers with the same key is one key).
| Header | Value |
|---|---|
Authorization | Bearer <key> |
x-api-key | <key> |
Body
A JSON object, at most 64 KiB, sent within 5 seconds; it is read as JSON whatever its content-type. An unknown field, a wrong type or an out-of-range value answers 400 INVALID_REQUEST. Any method but POST answers 405, and a path with a trailing slash 404.
A JSON object, at most 64 KiB. An unknown field or an out-of-range value answers 400 INVALID_REQUEST.
urlstringrequiredThe page to read. Public http and https on the ports 80, 443, 8080, 8443 only; private and reserved addresses, credentials in the URL and other ports are UNSAFE_URL.
formatone of markdown, jsonoptionalmarkdown returns the page’s text; json returns its structured data.
timeoutinteger or nulloptionalDeadline in milliseconds for the whole request. Defaults to 30000.
Response
One JSON object. data carries markdown or json, never both. usage.credits says what the page cost.
data carries markdown or json, never both. usage.credits says what the page cost.
successtruerequiredtrue on a success, including a login wall.
request_idstringrequiredThe request’s id; the same value is in x-request-id.
dataobjectrequiredThe page: its metadata and links, and markdown or json.
4 fields: metadata, links, markdown, json
metadataobjectrequiredWhat the page says about itself, and how the request ended.
7 fields: title, description, language, status, final_url, truncated, login_required
titlestringrequiredThe page’s title, up to 1,000 characters.
descriptionstringrequiredThe page’s meta description, up to 1,000 characters.
languagestring or nullrequiredThe page’s language, when it declares one.
statusintegerrequiredThe HTTP status the site answered with.
final_urlstringrequiredThe URL the page was read from, after redirects, without the query parameters that only track visitors or that a bot check left behind; an X post’s own address.
truncatedbooleanoptionalA cap cut the page: a byte cap, or the 2 MiB output cap.
login_requiredbooleanoptionalA sign-in wall: the wall’s own text, 0 credits.
linksarray of stringrequiredEvery absolute URL on the page, in document order, up to 5,000.
markdownstring or nulloptionalThe page’s text, at most 2 MiB. Present when format is markdown.
jsonobject or nulloptionalThe page’s structured data. Present when format is json.
4 fields: structured, tables, jsonld, embedded
structuredobject or nulloptionalThe one object the page declares itself to be, read as its most specific type, or an X post; left out when the page declares none.
tablesarray of objectrequiredRecord tables: JSON-LD and embedded arrays first, then HTML tables, then the page’s repeated cards.
jsonldarray of objectrequiredThe page’s JSON-LD blocks, as written.
embeddedarray of objectrequiredThe page’s state blobs (__NEXT_DATA__, application/json scripts, …), largest first.
usageobjectrequiredWhat this request charged, and what is left to spend.
2 fields: credits, remaining
creditsintegerrequiredThe credits this request charged: the price of the page’s level, 0 on a failure or a login wall.
remainingintegerrequiredThe balance left after this request.
{
"success": true,
"request_id": "req_1dc0a514d6ee71c4524b",
"data": {
"metadata": {
"title": "Example Domain",
"description": "",
"language": "en",
"status": 200,
"final_url": "https://example.com/"
},
"links": [],
"markdown": "# Example Domain\n\nThis domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes."
},
"usage": { "credits": 1, "remaining": 9999 }
}{
"success": false,
"request_id": "req_fe9963033461e4fcc81c",
"error": {
"code": "NOT_FOUND",
"message": "The site says this page does not exist (HTTP 404).",
"retryable": false,
"doc_url": "https://docs.crawlapi.dev/errors#NOT_FOUND",
"target_status": 404
}
}{
"success": false,
"request_id": "req_41e813f088955c316776",
"error": {
"code": "BLOCKED",
"message": "The site's bot protection (Akamai) refused access.",
"retryable": true,
"doc_url": "https://docs.crawlapi.dev/errors#BLOCKED",
"target_status": 403,
"vendor": "akamai"
}
}{
"success": false,
"request_id": "req_3115cab0d43d3ab5a090",
"error": {
"code": "RATE_LIMITED",
"message": "This account's limit of requests at once (5) is reached; retry when one finishes.",
"retryable": true,
"doc_url": "https://docs.crawlapi.dev/errors#RATE_LIMITED"
}
}| Header | Value |
|---|---|
x-request-id | the request’s id |
retry-after | on a 429, and on a 500 while our database is down: seconds until you can try again |
ratelimit-policy | on every answer to a valid key: the account's limits, "minute";q= and "concurrency";q= |
ratelimit | what is left: "minute";r= requests that can start now, t= seconds until one more can, "concurrency";r= free slots. Rate limits |
Errors
A failure answers success: false and an error. Every response carries x-request-id.
A failure answers success: false and an error with a code, a message and a retryable flag.
successfalseoptionalfalse on a failure.
request_idstringrequiredThe request’s id; the same value is in x-request-id.
errorobjectrequiredWhy it failed and whether a retry can help.
6 fields: code, message, retryable, doc_url, target_status, vendor
codeone of 17 codesrequiredThe reason code. Every code is on Errors and retries.
messagestringrequiredOne to three sentences for the caller, at most 220 characters.
retryablebooleanrequiredThe same request may succeed later, after Retry-After when sent.
doc_urlstringrequiredThis code’s entry on Errors and retries: what it means and what to do.
target_statusinteger or nulloptionalThe HTTP status the site answered with, when the site answered.
vendorstring or nulloptionalThe bot protection that refused the page, when it is known.
{
"success": false,
"request_id": "req_fe9963033461e4fcc81c",
"error": {
"code": "NOT_FOUND",
"message": "The site says this page does not exist (HTTP 404).",
"retryable": false,
"doc_url": "https://docs.crawlapi.dev/errors#NOT_FOUND",
"target_status": 404
}
}{
"success": false,
"request_id": "req_41e813f088955c316776",
"error": {
"code": "BLOCKED",
"message": "The site's bot protection (Akamai) refused access.",
"retryable": true,
"doc_url": "https://docs.crawlapi.dev/errors#BLOCKED",
"target_status": 403,
"vendor": "akamai"
}
}{
"success": false,
"request_id": "req_3115cab0d43d3ab5a090",
"error": {
"code": "RATE_LIMITED",
"message": "This account's limit of requests at once (5) is reached; retry when one finishes.",
"retryable": true,
"doc_url": "https://docs.crawlapi.dev/errors#RATE_LIMITED"
}
}| Status | Codes |
|---|---|
200 | success |
400 | INVALID_REQUEST, UNSAFE_URL |
401 | UNAUTHORIZED |
402 | INSUFFICIENT_CREDITS |
404 | NOT_FOUND |
405 | INVALID_REQUEST, the method is not allowed on this path |
408 | TIMEOUT |
410 | GONE |
422 | BLOCKED, HOST_NOT_FOUND, LOGIN_REQUIRED, NO_CONTENT, SCANNED_PDF, TARGET_ERROR, UNSUPPORTED_CONTENT |
429 | RATE_LIMITED |
500 | ENGINE_FAILED, INTERNAL |
What each code means and whether a retry can help: Errors and retries.
Limits
| Limit | Value |
|---|---|
timeout | 1000–60000 ms, 30000 ms by default |
url | at most 8,192 characters |
| Requests | per minute and at once, one limit per account: Rate limits |
| Credits | the price of the page’s level; a failure costs 0: Credits |