Extract structured data using CSS selectors.
Request body
| Field | Type | Description |
|---|
url | string | Required. The URL to process. |
options | object | Optional configuration (see below). |
Options
| Option | Type | Description |
|---|
selectors* | object | Required. Key-value pairs of name to CSS selector. |
waitForSelector | string | Wait for a CSS selector before scraping. |
waitUntil | string | "networkidle0", "networkidle2", "load", "domcontentloaded". Default: "networkidle0". |
curl -X POST https://crawlapi.dev/api/scrape \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url":"https://example.com","options":{"selectors":{"title":"h1","links":"a"}}}'
{
"success": true,
"data": {
"url": "https://example.com",
"results": {
"title": {
"text": "Example Domain",
"html": "Example Domain",
"attributes": {}
},
"links": {
"text": "More information...",
"html": "More information...",
"attributes": {
"href": "https://www.iana.org/domains/example"
}
}
}
},
"credits_used": 2,
"credits_remaining": 498
}
Error codes
| Status | Meaning |
|---|
400 | Missing or invalid URL / bad options |
401 | Missing or invalid API key |
403 | Insufficient credits |
405 | Wrong HTTP method (use POST) |
429 | Rate limit exceeded (60/min) |
500 | Server error |