Skip to main content

/screenshot API

The /screenshot API returns a PNG/JPEG/WebP screenshot of a page with Puppeteer options supported via options.

You can view the complete Screenshot API OpenAPI specification.

Quick Start

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>

Additional Examples and Configuration

bot detection

If the /screenshot API is getting blocked by bot detectors, then we would recommend trying BrowserQL GraphQL API.

Setting HTML Content

You can set the HTML content of the page to render dynamically generated content.

danger
  • When this propriety is set, the url propriety must not be present.
  • Browserless does't allow setting a options.path for /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

Browserless offers ways to load additional stylesheets and script tags to the page.

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"

Additional Configuration Options

The /screenshot API supports additional configuration options that are shared across multiple REST API endpoints. See the Request Configuration page for detailed documentation on:

  • Waiting for Things: Wait for events, functions, selectors, or timeouts before capturing the screenshot
  • Navigation Options: Customize navigation behavior using gotoOptions
  • Rejecting Undesired Requests: Block specific resources using rejectResourceTypes and rejectRequestPattern
  • Continue on Error: Use bestAttempt to proceed when async events fail or timeout