Skip to main content

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.

Rest API (Without Stealth)

Here’s the request in the specified format, with examples for curl, JavaScript, Python, Java and C#.

Bot detection

Browserless recommends using our REST API to take screenshots, unless you need to get past bot detectors.

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 '{
"html": "<h1>Hello World!</h1>",
"options": {
"type": "webp",
"omitBackground": true
}
}' \
--output "screenshot.webp"
warning

We do not allow to set a options.path

BQL (Stealth)

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

mutation Screenshot {
content(html: "<h1>Hello, World!</h1>") {
status
}

screenshot(type: webp) {
base64
}
}
BQL Schemas

For more details on BQL mutations, refer to the BrowserQL Schema reference pages.