Skip to content
Start here

Get HTML content.

client.BrowserRendering.Content.New(ctx, params) (*string, error)
POST/accounts/{account_id}/browser-rendering/content

Fetches rendered HTML content from provided URL or HTML. Check available options like gotoOptions and waitFor* to control page load behaviour.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Browser Rendering Write
ParametersExpand Collapse
params ContentNewParams
AccountID param.Field[string]

Path param: Account ID.

URL param.Field[string]

Body param: URL to navigate to, eg. https://example.com.

formaturi
CacheTTL param.Field[float64]optional

Query param: Cache TTL default is 5s. Set to 0 to disable.

maximum86400
ActionTimeout param.Field[float64]optional

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.

maximum120000
AddScriptTag param.Field[[]ContentNewParamsVariant0AddScriptTag]optional

Body param: Adds a <script> tag into the page with the desired URL or content.

ID stringoptional
Content stringoptional
Type stringoptional
URL stringoptional
AddStyleTag param.Field[[]ContentNewParamsVariant0AddStyleTag]optional

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.

Content stringoptional
URL stringoptional
AllowRequestPattern param.Field[[]string]optional

Body param: Only allow requests that match the provided regex patterns, eg. '/^.*.(css)'.

AllowResourceTypes param.Field[[]ContentNewParamsVariant0AllowResourceType]optional

Body param: Only allow requests that match the provided resource types, eg. 'image' or 'script'.

const ContentNewParamsVariant0AllowResourceTypeDocument ContentNewParamsVariant0AllowResourceType = "document"
const ContentNewParamsVariant0AllowResourceTypeStylesheet ContentNewParamsVariant0AllowResourceType = "stylesheet"
const ContentNewParamsVariant0AllowResourceTypeImage ContentNewParamsVariant0AllowResourceType = "image"
const ContentNewParamsVariant0AllowResourceTypeMedia ContentNewParamsVariant0AllowResourceType = "media"
const ContentNewParamsVariant0AllowResourceTypeFont ContentNewParamsVariant0AllowResourceType = "font"
const ContentNewParamsVariant0AllowResourceTypeScript ContentNewParamsVariant0AllowResourceType = "script"
const ContentNewParamsVariant0AllowResourceTypeTexttrack ContentNewParamsVariant0AllowResourceType = "texttrack"
const ContentNewParamsVariant0AllowResourceTypeXHR ContentNewParamsVariant0AllowResourceType = "xhr"
const ContentNewParamsVariant0AllowResourceTypeFetch ContentNewParamsVariant0AllowResourceType = "fetch"
const ContentNewParamsVariant0AllowResourceTypePrefetch ContentNewParamsVariant0AllowResourceType = "prefetch"
const ContentNewParamsVariant0AllowResourceTypeEventsource ContentNewParamsVariant0AllowResourceType = "eventsource"
const ContentNewParamsVariant0AllowResourceTypeWebsocket ContentNewParamsVariant0AllowResourceType = "websocket"
const ContentNewParamsVariant0AllowResourceTypeManifest ContentNewParamsVariant0AllowResourceType = "manifest"
const ContentNewParamsVariant0AllowResourceTypeSignedexchange ContentNewParamsVariant0AllowResourceType = "signedexchange"
const ContentNewParamsVariant0AllowResourceTypePing ContentNewParamsVariant0AllowResourceType = "ping"
const ContentNewParamsVariant0AllowResourceTypeCspviolationreport ContentNewParamsVariant0AllowResourceType = "cspviolationreport"
const ContentNewParamsVariant0AllowResourceTypePreflight ContentNewParamsVariant0AllowResourceType = "preflight"
const ContentNewParamsVariant0AllowResourceTypeOther ContentNewParamsVariant0AllowResourceType = "other"
Authenticate param.Field[ContentNewParamsVariant0Authenticate]optional

Body param: Provide credentials for HTTP authentication.

Password string
minLength1
Username string
minLength1
BestAttempt param.Field[bool]optional

Body param: Attempt to proceed when 'awaited' events fail or timeout.

Cookies param.Field[[]ContentNewParamsVariant0Cookie]optional

Body param: Check options.

Name string

Cookie name.

Value string
Domain stringoptional
Expires float64optional
HTTPOnly booloptional
PartitionKey stringoptional
Path stringoptional
Priority ContentNewParamsVariant0CookiesPriorityoptional
One of the following:
const ContentNewParamsVariant0CookiesPriorityLow ContentNewParamsVariant0CookiesPriority = "Low"
const ContentNewParamsVariant0CookiesPriorityMedium ContentNewParamsVariant0CookiesPriority = "Medium"
const ContentNewParamsVariant0CookiesPriorityHigh ContentNewParamsVariant0CookiesPriority = "High"
SameParty booloptional
SameSite ContentNewParamsVariant0CookiesSameSiteoptional
One of the following:
const ContentNewParamsVariant0CookiesSameSiteStrict ContentNewParamsVariant0CookiesSameSite = "Strict"
const ContentNewParamsVariant0CookiesSameSiteLax ContentNewParamsVariant0CookiesSameSite = "Lax"
const ContentNewParamsVariant0CookiesSameSiteNone ContentNewParamsVariant0CookiesSameSite = "None"
Secure booloptional
SourcePort float64optional
SourceScheme ContentNewParamsVariant0CookiesSourceSchemeoptional
One of the following:
const ContentNewParamsVariant0CookiesSourceSchemeUnset ContentNewParamsVariant0CookiesSourceScheme = "Unset"
const ContentNewParamsVariant0CookiesSourceSchemeNonSecure ContentNewParamsVariant0CookiesSourceScheme = "NonSecure"
const ContentNewParamsVariant0CookiesSourceSchemeSecure ContentNewParamsVariant0CookiesSourceScheme = "Secure"
URL stringoptional
EmulateMediaType param.Field[string]optional

Body param

GotoOptions param.Field[ContentNewParamsVariant0GotoOptions]optional

Body param: Check options.

Referer stringoptional
ReferrerPolicy stringoptional
Timeout float64optional
maximum60000
WaitUntil ContentNewParamsVariant0GotoOptionsWaitUntilUnionoptional
One of the following:
ContentNewParamsVariant0GotoOptionsWaitUntilString
One of the following:
const ContentNewParamsVariant0GotoOptionsWaitUntilStringLoad ContentNewParamsVariant0GotoOptionsWaitUntilString = "load"
const ContentNewParamsVariant0GotoOptionsWaitUntilStringDomcontentloaded ContentNewParamsVariant0GotoOptionsWaitUntilString = "domcontentloaded"
const ContentNewParamsVariant0GotoOptionsWaitUntilStringNetworkidle0 ContentNewParamsVariant0GotoOptionsWaitUntilString = "networkidle0"
const ContentNewParamsVariant0GotoOptionsWaitUntilStringNetworkidle2 ContentNewParamsVariant0GotoOptionsWaitUntilString = "networkidle2"
ContentNewParamsVariant0GotoOptionsWaitUntilArray
One of the following:
const ContentNewParamsVariant0GotoOptionsWaitUntilArrayLoad ContentNewParamsVariant0GotoOptionsWaitUntilArray = "load"
const ContentNewParamsVariant0GotoOptionsWaitUntilArrayDomcontentloaded ContentNewParamsVariant0GotoOptionsWaitUntilArray = "domcontentloaded"
const ContentNewParamsVariant0GotoOptionsWaitUntilArrayNetworkidle0 ContentNewParamsVariant0GotoOptionsWaitUntilArray = "networkidle0"
const ContentNewParamsVariant0GotoOptionsWaitUntilArrayNetworkidle2 ContentNewParamsVariant0GotoOptionsWaitUntilArray = "networkidle2"
RejectRequestPattern param.Field[[]string]optional

Body param: Block undesired requests that match the provided regex patterns, eg. '/^.*.(css)'.

RejectResourceTypes param.Field[[]ContentNewParamsVariant0RejectResourceType]optional

Body param: Block undesired requests that match the provided resource types, eg. 'image' or 'script'.

const ContentNewParamsVariant0RejectResourceTypeDocument ContentNewParamsVariant0RejectResourceType = "document"
const ContentNewParamsVariant0RejectResourceTypeStylesheet ContentNewParamsVariant0RejectResourceType = "stylesheet"
const ContentNewParamsVariant0RejectResourceTypeImage ContentNewParamsVariant0RejectResourceType = "image"
const ContentNewParamsVariant0RejectResourceTypeMedia ContentNewParamsVariant0RejectResourceType = "media"
const ContentNewParamsVariant0RejectResourceTypeFont ContentNewParamsVariant0RejectResourceType = "font"
const ContentNewParamsVariant0RejectResourceTypeScript ContentNewParamsVariant0RejectResourceType = "script"
const ContentNewParamsVariant0RejectResourceTypeTexttrack ContentNewParamsVariant0RejectResourceType = "texttrack"
const ContentNewParamsVariant0RejectResourceTypeXHR ContentNewParamsVariant0RejectResourceType = "xhr"
const ContentNewParamsVariant0RejectResourceTypeFetch ContentNewParamsVariant0RejectResourceType = "fetch"
const ContentNewParamsVariant0RejectResourceTypePrefetch ContentNewParamsVariant0RejectResourceType = "prefetch"
const ContentNewParamsVariant0RejectResourceTypeEventsource ContentNewParamsVariant0RejectResourceType = "eventsource"
const ContentNewParamsVariant0RejectResourceTypeWebsocket ContentNewParamsVariant0RejectResourceType = "websocket"
const ContentNewParamsVariant0RejectResourceTypeManifest ContentNewParamsVariant0RejectResourceType = "manifest"
const ContentNewParamsVariant0RejectResourceTypeSignedexchange ContentNewParamsVariant0RejectResourceType = "signedexchange"
const ContentNewParamsVariant0RejectResourceTypePing ContentNewParamsVariant0RejectResourceType = "ping"
const ContentNewParamsVariant0RejectResourceTypeCspviolationreport ContentNewParamsVariant0RejectResourceType = "cspviolationreport"
const ContentNewParamsVariant0RejectResourceTypePreflight ContentNewParamsVariant0RejectResourceType = "preflight"
const ContentNewParamsVariant0RejectResourceTypeOther ContentNewParamsVariant0RejectResourceType = "other"
SetExtraHTTPHeaders param.Field[map[string, string]]optional

Body param

SetJavaScriptEnabled param.Field[bool]optional

Body param

UserAgent param.Field[string]optional

Body param

Viewport param.Field[ContentNewParamsVariant0Viewport]optional

Body param: Check options.

Height float64
Width float64
DeviceScaleFactor float64optional
HasTouch booloptional
IsLandscape booloptional
IsMobile booloptional
WaitForSelector param.Field[ContentNewParamsVariant0WaitForSelector]optional

Body param: Wait for the selector to appear in page. Check options.

Selector string
Hidden ContentNewParamsVariant0WaitForSelectorHiddenoptional
Timeout float64optional
maximum120000
Visible ContentNewParamsVariant0WaitForSelectorVisibleoptional
WaitForTimeout param.Field[float64]optional

Body param: Waits for a specified timeout before continuing.

maximum120000
ReturnsExpand Collapse
type ContentNewResponseEnvelopeResult string

HTML content.

Get HTML content.

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"),
  )
  content, err := client.BrowserRendering.Content.New(context.TODO(), browser_rendering.ContentNewParams{
    AccountID: cloudflare.F("account_id"),
    Body: browser_rendering.ContentNewParamsBodyObject{
      URL: cloudflare.F("https://www.example.com/"),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", content)
}
{
  "meta": {
    "status": 0,
    "title": "title"
  },
  "success": true,
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": "result"
}
{
  "errors": [
    {
      "code": 2001,
      "message": "Rate limit exceeded"
    }
  ],
  "success": false
}
Returns Examples
{
  "meta": {
    "status": 0,
    "title": "title"
  },
  "success": true,
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": "result"
}
{
  "errors": [
    {
      "code": 2001,
      "message": "Rate limit exceeded"
    }
  ],
  "success": false
}