Get screenshot.
Takes a screenshot of a webpage from provided URL or HTML. Control page loading with gotoOptions and waitFor* options. Customize screenshots with viewport, fullPage, clip and others.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYYAPI Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
X-Auth-Email: user@example.comThe previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194Accepted Permissions (at least one required)
Browser Rendering WriteParametersExpand Collapse
params ScreenshotNewParams
Body param: Set the content of the page, eg: <h1>Hello World!!</h1>. Either html or url must be set.
Query param: Cache TTL default is 5s. Set to 0 to disable.
Body param: The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.
AddScriptTag param.Field[[]ScreenshotNewParamsVariant0AddScriptTag]optionalBody param: Adds a <script> tag into the page with the desired URL or content.
Body param: Adds a <script> tag into the page with the desired URL or content.
AddStyleTag param.Field[[]ScreenshotNewParamsVariant0AddStyleTag]optionalBody param: Adds a <link rel="stylesheet"> tag into the page with the desired URL or a <style type="text/css"> tag with the content.
Body param: Adds a <link rel="stylesheet"> tag into the page with the desired URL or a <style type="text/css"> tag with the content.
Body param: Only allow requests that match the provided regex patterns, eg. '/^.*.(css)'.
AllowResourceTypes param.Field[[]ScreenshotNewParamsVariant0AllowResourceType]optionalBody param: Only allow requests that match the provided resource types, eg. 'image' or 'script'.
Body param: Only allow requests that match the provided resource types, eg. 'image' or 'script'.
Body param: Attempt to proceed when 'awaited' events fail or timeout.
Cookies param.Field[[]ScreenshotNewParamsVariant0Cookie]optionalBody param: Check options.
Body param: Check options.
Priority ScreenshotNewParamsVariant0CookiesPriorityoptional
SameSite ScreenshotNewParamsVariant0CookiesSameSiteoptional
SourceScheme ScreenshotNewParamsVariant0CookiesSourceSchemeoptional
Body param: Check options.
Body param: Check options.
WaitUntil ScreenshotNewParamsVariant0GotoOptionsWaitUntilUnionoptional
ScreenshotNewParamsVariant0GotoOptionsWaitUntilString
ScreenshotNewParamsVariant0GotoOptionsWaitUntilArray
Body param: Block undesired requests that match the provided regex patterns, eg. '/^.*.(css)'.
RejectResourceTypes param.Field[[]ScreenshotNewParamsVariant0RejectResourceType]optionalBody param: Block undesired requests that match the provided resource types, eg. 'image' or 'script'.
Body param: Block undesired requests that match the provided resource types, eg. 'image' or 'script'.
Body param: Check options.
Body param: Check options.
Type ScreenshotNewParamsVariant0ScreenshotOptionsTypeoptional
Body param: Check options.
Body param: Check options.
Body param: Wait for the selector to appear in page. Check options.
Body param: Wait for the selector to appear in page. Check options.
Get screenshot.
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/browser_rendering"
"github.com/cloudflare/cloudflare-go/option"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
screenshot, err := client.BrowserRendering.Screenshot.New(context.TODO(), browser_rendering.ScreenshotNewParams{
AccountID: cloudflare.F("account_id"),
Body: browser_rendering.ScreenshotNewParamsBodyObject{
URL: cloudflare.F("https://www.example.com/"),
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", screenshot.Success)
}
{
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}{
"errors": [
{
"code": 2001,
"message": "Rate limit exceeded"
}
],
"success": false
}Returns Examples
{
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}{
"errors": [
{
"code": 2001,
"message": "Rate limit exceeded"
}
],
"success": false
}