/screenshot API
The screenshot API allows for simple navigation to a site and capturing a screenshot. browserless will respond with either a png
or jpg
content-type (depending on parameters). This API exposes most of puppeteer's screenshot API through the posted JSON payload.
If you want to see all the options check out the schema for it here on GitHub.
Take a PNG of example.com
// JSON body
// `options` are the options available via puppeteer's .screenshot method
{
"url": "https://example.com/",
"options": {
"fullPage": true,
"type": "jpeg",
"quality": 75
}
}
cURL (with an API token)
curl -X POST \
https://chrome.browserless.io/screenshot?token=MY_API_TOKEN \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"options": {
"fullPage": true,
"type": "jpeg",
"quality": 75
}
}'
Custom options
The /screenshot
route has a few special custom options that make it more usable and configurable. We've added these options based on feedback from you in hope that it will help gather best-practices in a single place.
gotoOptions
The gotoOptions
is an object that's passed directly into puppeteer's page.goto
call so that you can specify things like alternative loaded events. See puppeteer's goto options for more information.
cURL (with an API token)
curl -X POST \
https://chrome.browserless.io/screenshot?token=MY_API_TOKEN \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"gotoOptions": {
"waitUntil": "networkidle2",
}
}'