Dynamic Script - execute code and return browser session details.
client.BrowserRendering.Script.New(ctx, params) (*ScriptNewResponseUnion, error)
POST/accounts/{account_id}/browser-rendering/script
Acquires a browser session and runs the provided code in it. The session stays open for reuse; close it with DELETE /devtools/browser/:sessionId or browser.close(), otherwise it ends at the idle timeout.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Dynamic Script - execute code and return browser session details.
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"),
)
script, err := client.BrowserRendering.Script.New(context.TODO(), browser_rendering.ScriptNewParams{
AccountID: cloudflare.F("account_id"),
Code: cloudflare.F("code"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", script)
}
{
"result": "string",
"success": true
}{
"errors": [
{
"code": 2001,
"message": "Rate limit exceeded"
}
],
"success": false
}Returns Examples
{
"result": "string",
"success": true
}{
"errors": [
{
"code": 2001,
"message": "Rate limit exceeded"
}
],
"success": false
}