Skip to main content
Use Scrape Bytes to retrieve a resource without converting it to Markdown or rendering JavaScript. It returns a JSON response with base64-encoded bytes and download metadata. A successful download costs 1 credit and can contain up to 20 MiB of decoded resource data. The endpoint does not cache responses. A restricted API key needs data:execute; see API key permissions.

Download and decode a resource

Set CONTEXT_DEV_API_KEY on your server and install an SDK if needed. This example downloads the HTML source of example.com; replace the URL and output filename for your own image, PDF, or other resource.
These examples use the SDKs’ low-level request methods to send the current API contract, including fields not yet exposed by the 2.14.0 typed helpers. Authentication, retries, and error handling still come from the SDK. See SDK compatibility.
The cURL example prints the JSON response. Decode its bytes field with a base64 decoder to recover the file, as the SDK examples do. The value has no data: URI prefix.

Read download metadata

HTTP content compression is decoded before the bytes are returned. contentLength measures the resulting resource, not the larger JSON/base64 response body.

Headers, location, and privacy

Use country for supported country routing. Supply target request headers as a JSON-encoded headers query value or deep-object keys such as headers[Referer]. The API bearer key goes in the API request’s Authorization header. A target site’s own credential, when needed and authorized, goes inside headers. Do not forward your Context.dev API key to the target. Host, Content-Length, and hop-by-hop headers are rejected; target authorization and cookies are removed when a redirect changes origin. Set zdr=enabled when Zero Data Retention is enabled for your organization, and check X-Context-ZDR: true. The endpoint requires a public HTTP(S) destination and validates redirects.

Deadlines and limits

timeoutOpts.milliseconds accepts 1–300,000. Bytes supports only behavior: "fail": the entire download must complete, so partial-result mode is rejected. Failed downloads are not charged. See timeouts and troubleshooting for shared errors. Use Parse documents to convert a document to Markdown; Parse accepts uploads up to 50 MiB. Use Extract page images to discover images referenced by a page, or Scrape a webpage when you need rendered page text.