POST /v2/scrape takes
{"url": "https://example.com", "responseOptions": {"format": "html", "onlyMainContent": false}, "timeout": 10000};
timeout is 1000 to 20000 ms.
{"success": true, "data": {"html": "<!doctype html>...", "metadata": {
"sourceURL": "https://example.com", "url": "https://example.com", "statusCode": 200, "contentType": "text/html; charset=utf-8"}}}metadata.urlis the URL after redirects,sourceURLthe one sent. Redirects carry the cookies the site sets. Without request headers, redirects are followed to any site; with them, see Request headers.- A page that failed is still a 200 document, with no
htmlsince its body is not stored.metadata.errorsays why andmetadata.errorCodeis one ofhttp_status,non_public_address,port_not_allowed,invalid_url,dns,timeout,tls,connection,too_many_redirects,cross_site_redirect,proxy_error(see Proxy),read_body,page_too_large,unsupported_content_type,storage,attempts_exhaustedandrequest_options_unreadable(the server could not decrypt the headers, e.g. after its encryption key changed).statusCodeandcontentTypeare absent when no response arrived. - A page not scraped within
timeoutanswers 202 with{"success": true, "id": "...", "url": "..."}: the scrape keeps running, andurl, also sent asLocation, is its status,GET /v2/scrape/{id}. An anonymous caller polls it too, without a key, by the scrape id.
Status
GET /v2/scrape/{id} answers:
{"success": true, "status": "completed", "createdAt": "...", "expiresAt": "...", "completedAt": "...",
"data": {"html": "<!doctype html>...", "metadata": {...}}}statusisscrapinguntil the page has its result, thencompleted;completedAtmarks it anddatais the documentPOST /v2/scrapewould have answered.- A read that carries
datacounts against the scrape’s 10 result reads an hour; polling before that does not. - A scrape lives 1 day, then answers 404
SCRAPE_NOT_FOUND, as does an unknown id, another caller’s scrape or a batch scrape id. Scrapes cannot be cancelled. - Every page is capped at 10 MiB after decoding; a larger one fails with
page_too_large.