Skip to content
Start here

Get json.

client.BrowserRendering.Json.New(ctx, params) (*JsonNewResponse, error)
POST/accounts/{account_id}/browser-rendering/json

Gets json from a webpage from a provided URL or HTML. Pass prompt or schema in the body. Control page loading with gotoOptions and waitFor* options.

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 JsonNewParams
AccountID param.Field[string]

Path param: Account ID.

CacheTTL param.Field[float64]Optional

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

maximum86400
minimum0
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[[]JsonNewParamsAddScriptTag]Optional

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

ID stringOptional
Content stringOptional
Type stringOptional
URL stringOptional
formaturi
AddStyleTag param.Field[[]JsonNewParamsAddStyleTag]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
formaturi
AllowRequestPattern param.Field[[]string]Optional

Body param: Only allow requests that match the provided regex patterns, eg. ’/^.*.(css)’. Reject rules are applied first.

AllowResourceTypes param.Field[[]JsonNewParamsAllowResourceType]Optional

Body param: Only allow requests that match the provided resource types, eg. ‘image’ or ‘script’. Reject rules are applied first.

const JsonNewParamsAllowResourceTypeDocument JsonNewParamsAllowResourceType = "document"
const JsonNewParamsAllowResourceTypeStylesheet JsonNewParamsAllowResourceType = "stylesheet"
const JsonNewParamsAllowResourceTypeImage JsonNewParamsAllowResourceType = "image"
const JsonNewParamsAllowResourceTypeMedia JsonNewParamsAllowResourceType = "media"
const JsonNewParamsAllowResourceTypeFont JsonNewParamsAllowResourceType = "font"
const JsonNewParamsAllowResourceTypeScript JsonNewParamsAllowResourceType = "script"
const JsonNewParamsAllowResourceTypeTexttrack JsonNewParamsAllowResourceType = "texttrack"
const JsonNewParamsAllowResourceTypeXHR JsonNewParamsAllowResourceType = "xhr"
const JsonNewParamsAllowResourceTypeFetch JsonNewParamsAllowResourceType = "fetch"
const JsonNewParamsAllowResourceTypePrefetch JsonNewParamsAllowResourceType = "prefetch"
const JsonNewParamsAllowResourceTypeEventsource JsonNewParamsAllowResourceType = "eventsource"
const JsonNewParamsAllowResourceTypeWebsocket JsonNewParamsAllowResourceType = "websocket"
const JsonNewParamsAllowResourceTypeManifest JsonNewParamsAllowResourceType = "manifest"
const JsonNewParamsAllowResourceTypeSignedexchange JsonNewParamsAllowResourceType = "signedexchange"
const JsonNewParamsAllowResourceTypePing JsonNewParamsAllowResourceType = "ping"
const JsonNewParamsAllowResourceTypeCspviolationreport JsonNewParamsAllowResourceType = "cspviolationreport"
const JsonNewParamsAllowResourceTypePreflight JsonNewParamsAllowResourceType = "preflight"
const JsonNewParamsAllowResourceTypeOther JsonNewParamsAllowResourceType = "other"
Authenticate param.Field[JsonNewParamsAuthenticate]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[[]JsonNewParamsCookie]Optional

Body param: Check options.

Name string

Cookie name.

Value string
Domain stringOptional
Expires float64Optional
HTTPOnly boolOptional
PartitionKey stringOptional
Path stringOptional
Priority JsonNewParamsCookiesPriorityOptional
One of the following:
const JsonNewParamsCookiesPriorityLow JsonNewParamsCookiesPriority = "Low"
const JsonNewParamsCookiesPriorityMedium JsonNewParamsCookiesPriority = "Medium"
const JsonNewParamsCookiesPriorityHigh JsonNewParamsCookiesPriority = "High"
SameParty boolOptional
SameSite JsonNewParamsCookiesSameSiteOptional
One of the following:
const JsonNewParamsCookiesSameSiteStrict JsonNewParamsCookiesSameSite = "Strict"
const JsonNewParamsCookiesSameSiteLax JsonNewParamsCookiesSameSite = "Lax"
const JsonNewParamsCookiesSameSiteNone JsonNewParamsCookiesSameSite = "None"
Secure boolOptional
SourcePort float64Optional
SourceScheme JsonNewParamsCookiesSourceSchemeOptional
One of the following:
const JsonNewParamsCookiesSourceSchemeUnset JsonNewParamsCookiesSourceScheme = "Unset"
const JsonNewParamsCookiesSourceSchemeNonSecure JsonNewParamsCookiesSourceScheme = "NonSecure"
const JsonNewParamsCookiesSourceSchemeSecure JsonNewParamsCookiesSourceScheme = "Secure"
URL stringOptional
CustomAI param.Field[[]JsonNewParamsCustomAI]Optional

Body param: Optional list of custom AI models to use for the request. The models will be tried in the order provided, and in case a model returns an error, the next one will be used as fallback.

Model string

AI model to use for the request. Must be formed as <provider>/<model_name>, e.g. workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast.

Authorization stringOptional

Authorization token for the AI model: Bearer <token>. Not needed for workers-ai models.

EmulateMediaType param.Field[string]Optional

Body param

GotoOptions param.Field[JsonNewParamsGotoOptions]Optional

Body param: Check options.

Referer stringOptional
ReferrerPolicy stringOptional
Timeout float64Optional
maximum60000
WaitUntil JsonNewParamsGotoOptionsWaitUntilUnionOptional
One of the following:
type JsonNewParamsGotoOptionsWaitUntilString string
One of the following:
const JsonNewParamsGotoOptionsWaitUntilStringLoad JsonNewParamsGotoOptionsWaitUntilString = "load"
const JsonNewParamsGotoOptionsWaitUntilStringDomcontentloaded JsonNewParamsGotoOptionsWaitUntilString = "domcontentloaded"
const JsonNewParamsGotoOptionsWaitUntilStringNetworkidle0 JsonNewParamsGotoOptionsWaitUntilString = "networkidle0"
const JsonNewParamsGotoOptionsWaitUntilStringNetworkidle2 JsonNewParamsGotoOptionsWaitUntilString = "networkidle2"
type JsonNewParamsGotoOptionsWaitUntilArray []JsonNewParamsGotoOptionsWaitUntilArray
One of the following:
const JsonNewParamsGotoOptionsWaitUntilArrayItemLoad JsonNewParamsGotoOptionsWaitUntilArrayItem = "load"
const JsonNewParamsGotoOptionsWaitUntilArrayItemDomcontentloaded JsonNewParamsGotoOptionsWaitUntilArrayItem = "domcontentloaded"
const JsonNewParamsGotoOptionsWaitUntilArrayItemNetworkidle0 JsonNewParamsGotoOptionsWaitUntilArrayItem = "networkidle0"
const JsonNewParamsGotoOptionsWaitUntilArrayItemNetworkidle2 JsonNewParamsGotoOptionsWaitUntilArrayItem = "networkidle2"
HTML param.Field[string]Optional

Body param: Set the content of the page, eg: <h1>Hello World!!</h1>. Either html or url must be set.

minLength1
Prompt param.Field[string]Optional

Body param

RejectRequestPattern param.Field[[]string]Optional

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

RejectResourceTypes param.Field[[]JsonNewParamsRejectResourceType]Optional

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

const JsonNewParamsRejectResourceTypeDocument JsonNewParamsRejectResourceType = "document"
const JsonNewParamsRejectResourceTypeStylesheet JsonNewParamsRejectResourceType = "stylesheet"
const JsonNewParamsRejectResourceTypeImage JsonNewParamsRejectResourceType = "image"
const JsonNewParamsRejectResourceTypeMedia JsonNewParamsRejectResourceType = "media"
const JsonNewParamsRejectResourceTypeFont JsonNewParamsRejectResourceType = "font"
const JsonNewParamsRejectResourceTypeScript JsonNewParamsRejectResourceType = "script"
const JsonNewParamsRejectResourceTypeTexttrack JsonNewParamsRejectResourceType = "texttrack"
const JsonNewParamsRejectResourceTypeXHR JsonNewParamsRejectResourceType = "xhr"
const JsonNewParamsRejectResourceTypeFetch JsonNewParamsRejectResourceType = "fetch"
const JsonNewParamsRejectResourceTypePrefetch JsonNewParamsRejectResourceType = "prefetch"
const JsonNewParamsRejectResourceTypeEventsource JsonNewParamsRejectResourceType = "eventsource"
const JsonNewParamsRejectResourceTypeWebsocket JsonNewParamsRejectResourceType = "websocket"
const JsonNewParamsRejectResourceTypeManifest JsonNewParamsRejectResourceType = "manifest"
const JsonNewParamsRejectResourceTypeSignedexchange JsonNewParamsRejectResourceType = "signedexchange"
const JsonNewParamsRejectResourceTypePing JsonNewParamsRejectResourceType = "ping"
const JsonNewParamsRejectResourceTypeCspviolationreport JsonNewParamsRejectResourceType = "cspviolationreport"
const JsonNewParamsRejectResourceTypePreflight JsonNewParamsRejectResourceType = "preflight"
const JsonNewParamsRejectResourceTypeOther JsonNewParamsRejectResourceType = "other"
ResponseFormat param.Field[JsonNewParamsResponseFormat]Optional

Body param

Type string
JsonSchema map[string, unknown]Optional

Schema for the response format. More information here: https://developers.cloudflare.com/workers-ai/json-mode/

SetExtraHTTPHeaders param.Field[map[string, string]]Optional

Body param

SetJavaScriptEnabled param.Field[bool]Optional

Body param

URL param.Field[string]Optional

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

formaturi
UserAgent param.Field[string]Optional

Body param

Viewport param.Field[JsonNewParamsViewport]Optional

Body param: Check options.

Height float64
Width float64
DeviceScaleFactor float64Optional
HasTouch boolOptional
IsLandscape boolOptional
IsMobile boolOptional
WaitForSelector param.Field[JsonNewParamsWaitForSelector]Optional

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

Selector string
Hidden JsonNewParamsWaitForSelectorHiddenOptional
Timeout float64Optional
maximum120000
Visible JsonNewParamsWaitForSelectorVisibleOptional
WaitForTimeout param.Field[float64]Optional

Body param: Waits for a specified timeout before continuing.

maximum120000
ReturnsExpand Collapse
type JsonNewResponse map[string, unknown]

Get json.

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