POST/api/scrape2 credits

Extract structured data using CSS selectors.

Request body

FieldTypeDescription
urlstringRequired. The URL to process.
optionsobjectOptional configuration (see below).

Options

OptionTypeDescription
selectors*objectRequired. Key-value pairs of name to CSS selector.
waitForSelectorstringWait for a CSS selector before scraping.
waitUntilstring"networkidle0", "networkidle2", "load", "domcontentloaded". Default: "networkidle0".

Example request

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"}}}'

Example response

{
"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

StatusMeaning
400Missing or invalid URL / bad options
401Missing or invalid API key
403Insufficient credits
405Wrong HTTP method (use POST)
429Rate limit exceeded (60/min)
500Server error