This document describes our "capture a screenshot of a URL/webpage" functionality (API endpoint), its associated HTTP header options, and possible error responses. See example usage here or scroll down.
Endpoint: service.headless-render-api.com
Screenshot Path: /screenshot/$URL
Example URL:
https://service.headless-render-api.com/screenshot/https://example.com/
The target $URL
is obviously part of the path, but do not re-encode or re-escape it beyond what you'd enter into a browser URL field. Both UTF-8 encoding and percent-encoding are acceptable.
Related links:
X-Prerender-Token
curl --header "X-Prerender-Token: secret-token"
A webpage screenshot API. Try it in your browser: service.headless-render-api.com/screenshot/https://example.com
cURL
curl https://service.headless-render-api.com/screenshot/https://example.com/ > out.png
Node.js client
// npm install prerendercloud
await prerendercloud.screenshot("https://example.com/", {
deviceWidth: 800,
deviceHeight: 600,
viewportWidth: 640,
viewportHeight: 480,
viewportX: 0,
viewportY: 0,
format: "webp", // Default: png, other options: webp, jpeg
// viewportQuerySelector: "#open-graph-div",
// viewportQuerySelectorPadding: 10,
// emulatedMedia: "screen",
// viewportScale: 2, // Default: 1, min: 0.1, max: 3.0
// isMobile: false, // Default: false, whether the meta viewport tag is taken into account
});
prerender-device-width
curl --header "prerender-device-width: 800"
prerender-device-height
curl --header "prerender-device-height: 600"
prerender-device-is-mobile
curl --header "prerender-device-is-mobile: true"
prerender-viewport-query-selector
curl --header "Prerender-Viewport-Query-Selector: #open-graph-div"
prerender-viewport-query-selector-padding
curl --header "prerender-viewport-query-selector-padding: 10"
prerender-viewport-width
curl --header "prerender-viewport-width: 100"
prerender-viewport-height
curl --header "prerender-viewport-height: 100"
prerender-viewport-x
curl --header "prerender-viewport-x: 0"
prerender-viewport-y
curl --header "prerender-viewport-y: 0"
prerender-viewport-scale
curl --header "prerender-viewport-scale: 1.5"
prerender-screenshot-format
curl --header "prerender-screenshot-format: webp"
prerender-emulated-media
curl --header "Prerender-Emulated-Media: screen"
prerender-wait-extra-long
{ waitUntil: 'networkidle' }
. Useful for
pages that depend on AJAX/XHR that fire late or IPFS hosted pagescurl --header "Prerender-Wait-Extra-Long: true"
prerender-dont-wait-for-web-sockets
curl --header "prerender-dont-wait-for-web-sockets: true"
prerender-block-cookies
curl --header "prerender-block-cookies: true"
400
content-type: application/octet-stream
429
500
502
503
504