Skip to main content

Screenshot API

Capture PNG, JPEG, or WebP screenshots of a page. Pass Puppeteer-style settings through the options object.

Endpoint

  • Method: POST
  • Path: /screenshot
  • Auth: token query parameter (?token=)
  • Content-Type: application/json
  • Response: image/png (or image/jpeg, image/webp based on options.type)

See the OpenAPI reference for complete details.

Quickstart

curl -X POST \
"https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"options": {
"fullPage": true,
"type": "png"
}
}' \
--output "screenshot.png"

Response

HTTP/1.1 200 OK
Content-Type: image/png

<binary>

Examples

bot detection

If the /screenshot API is getting blocked by bot detectors, try BrowserQL GraphQL API.

Setting HTML content

Use html to render inline content instead of navigating to a URL.

danger
  • When you send html, do not include url in the same request.
  • Browserless doesn't allow setting options.path for the /screenshot API.
curl -X POST \
"https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"options": {
"type": "webp",
"omitBackground": true
}
}' \
--output "screenshot.webp"

Adding custom styles and scripts

Use addScriptTag and addStyleTag to inject scripts and styles before the screenshot is taken.

curl -X POST \
"https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN_HERE" \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
"url": "https://example.com/",
"addScriptTag": [
{ "url": "https://code.jquery.com/jquery-3.7.1.min.js" },
{ "content": "document.querySelector(`h1`).innerText = `Hello Word!`" }
],
"addStyleTag": [
{
"content": "body { height: 100vh; background: linear-gradient(45deg, #da5a44, #a32784); }"
},
{
"url": "https://interactive-examples.mdn.mozilla.net/live-examples/css-examples/text-decoration/text-decoration-color.css"
}
]
}' \
--output "screenshot.png"

Configuration options

The /screenshot API supports shared request configuration options that apply across REST endpoints:

  • Waiting for things: Wait for events, functions, selectors, or timeouts before capturing the screenshot
  • Navigation options: Customize navigation behavior with gotoOptions
  • Rejecting undesired requests: Block resources with rejectResourceTypes and rejectRequestPattern
  • Continue on error: Use bestAttempt to continue when async events fail or time out