# Browser Rendering
# Content
## Get HTML content.
`client.browserRendering.content.create(ContentCreateParamsparams, RequestOptionsoptions?): ContentCreateResponse`
**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.
### Parameters
- `ContentCreateParams = Variant0 | Variant1`
- `ContentCreateParamsBase`
- `Variant0 extends ContentCreateParamsBase`
- `Variant1 extends ContentCreateParamsBase`
### Returns
- `ContentCreateResponse = string`
HTML content.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const content = await client.browserRendering.content.create({
account_id: 'account_id',
url: 'https://www.example.com/',
});
console.log(content);
```
#### Response
```json
{
"meta": {
"status": 0,
"title": "title"
},
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
],
"result": "result"
}
```
## Domain Types
### Content Create Response
- `ContentCreateResponse = string`
HTML content.
# PDF
## Get PDF.
`client.browserRendering.pdf.create(PDFCreateParamsparams, RequestOptionsoptions?): Response`
**post** `/accounts/{account_id}/browser-rendering/pdf`
Fetches rendered PDF from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.
### Parameters
- `PDFCreateParams = Variant0 | Variant1`
- `PDFCreateParamsBase`
- `Variant0 extends PDFCreateParamsBase`
- `Variant1 extends PDFCreateParamsBase`
### Returns
- `unnamed_schema_12 = Response`
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const pdf = await client.browserRendering.pdf.create({
account_id: 'account_id',
html: '
Hello World!
',
});
console.log(pdf);
const content = await pdf.blob();
console.log(content);
```
#### Response
```json
{
"errors": [
{
"code": 2001,
"message": "Rate limit exceeded"
}
],
"success": false
}
```
# Scrape
## Scrape elements.
`client.browserRendering.scrape.create(ScrapeCreateParamsparams, RequestOptionsoptions?): ScrapeCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/scrape`
Get meta attributes like height, width, text and others of selected elements.
### Parameters
- `ScrapeCreateParams = Variant0 | Variant1`
- `ScrapeCreateParamsBase`
- `Variant0 extends ScrapeCreateParamsBase`
- `Variant1 extends ScrapeCreateParamsBase`
### Returns
- `ScrapeCreateResponse = Array`
- `results: Results`
- `attributes: Array`
- `name: string`
Attribute name.
- `value: string`
Attribute value.
- `height: number`
Element height.
- `html: string`
HTML content.
- `left: number`
Element left.
- `text: string`
Text content.
- `top: number`
Element top.
- `width: number`
Element width.
- `selector: string`
Selector.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const scrapes = await client.browserRendering.scrape.create({
account_id: 'account_id',
elements: [{ selector: 'h1' }],
html: 'Hello World!
',
});
console.log(scrapes);
```
#### Response
```json
{
"result": [
{
"results": {
"attributes": [
{
"name": "name",
"value": "value"
}
],
"height": 0,
"html": "html",
"left": 0,
"text": "text",
"top": 0,
"width": 0
},
"selector": "selector"
}
],
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Domain Types
### Scrape Create Response
- `ScrapeCreateResponse = Array`
- `results: Results`
- `attributes: Array`
- `name: string`
Attribute name.
- `value: string`
Attribute value.
- `height: number`
Element height.
- `html: string`
HTML content.
- `left: number`
Element left.
- `text: string`
Text content.
- `top: number`
Element top.
- `width: number`
Element width.
- `selector: string`
Selector.
# Screenshot
## Get screenshot.
`client.browserRendering.screenshot.create(ScreenshotCreateParamsparams, RequestOptionsoptions?): ScreenshotCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/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.
### Parameters
- `ScreenshotCreateParams = Variant0 | Variant1`
- `ScreenshotCreateParamsBase`
- `Variant0 extends ScreenshotCreateParamsBase`
- `Variant1 extends ScreenshotCreateParamsBase`
### Returns
- `ScreenshotCreateResponse`
- `success: boolean`
Response status.
- `errors?: Array`
- `code: number`
Error code.
- `message: string`
Error message.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const screenshot = await client.browserRendering.screenshot.create({
account_id: 'account_id',
html: 'Hello World!
',
});
console.log(screenshot.success);
```
#### Response
```json
{
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Domain Types
### Screenshot Create Response
- `ScreenshotCreateResponse`
- `success: boolean`
Response status.
- `errors?: Array`
- `code: number`
Error code.
- `message: string`
Error message.
# Snapshot
## Get HTML content and screenshot.
`client.browserRendering.snapshot.create(SnapshotCreateParamsparams, RequestOptionsoptions?): SnapshotCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/snapshot`
Returns the page's HTML content and screenshot. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.
### Parameters
- `SnapshotCreateParams = Variant0 | Variant1`
- `SnapshotCreateParamsBase`
- `Variant0 extends SnapshotCreateParamsBase`
- `Variant1 extends SnapshotCreateParamsBase`
### Returns
- `SnapshotCreateResponse`
- `content: string`
HTML content.
- `screenshot: string`
Base64 encoded image.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const snapshot = await client.browserRendering.snapshot.create({
account_id: 'account_id',
html: 'Hello World!
',
});
console.log(snapshot.content);
```
#### Response
```json
{
"meta": {
"status": 0,
"title": "title"
},
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
],
"result": {
"content": "content",
"screenshot": "screenshot"
}
}
```
## Domain Types
### Snapshot Create Response
- `SnapshotCreateResponse`
- `content: string`
HTML content.
- `screenshot: string`
Base64 encoded image.
# Json
## Get json.
`client.browserRendering.json.create(JsonCreateParamsparams, RequestOptionsoptions?): JsonCreateResponse`
**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.
### Parameters
- `JsonCreateParams = Variant0 | Variant1`
- `JsonCreateParamsBase`
- `Variant0 extends JsonCreateParamsBase`
- `Variant1 extends JsonCreateParamsBase`
### Returns
- `JsonCreateResponse = Record`
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const json = await client.browserRendering.json.create({
account_id: 'account_id',
html: 'Hello World!
',
});
console.log(json);
```
#### Response
```json
{
"result": {
"foo": {}
},
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Domain Types
### Json Create Response
- `JsonCreateResponse = Record`
# Links
## Get Links.
`client.browserRendering.links.create(LinkCreateParamsparams, RequestOptionsoptions?): LinkCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/links`
Get links from a web page.
### Parameters
- `LinkCreateParams = Variant0 | Variant1`
- `LinkCreateParamsBase`
- `Variant0 extends LinkCreateParamsBase`
- `Variant1 extends LinkCreateParamsBase`
### Returns
- `LinkCreateResponse = Array`
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const links = await client.browserRendering.links.create({
account_id: 'account_id',
html: 'Hello World!
',
});
console.log(links);
```
#### Response
```json
{
"result": [
"string"
],
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Domain Types
### Link Create Response
- `LinkCreateResponse = Array`
# Markdown
## Get markdown.
`client.browserRendering.markdown.create(MarkdownCreateParamsparams, RequestOptionsoptions?): MarkdownCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/markdown`
Gets markdown of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options.
### Parameters
- `MarkdownCreateParams = Variant0 | Variant1`
- `MarkdownCreateParamsBase`
- `Variant0 extends MarkdownCreateParamsBase`
- `Variant1 extends MarkdownCreateParamsBase`
### Returns
- `MarkdownCreateResponse = string`
Markdown content.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const markdown = await client.browserRendering.markdown.create({
account_id: 'account_id',
url: 'https://www.example.com/',
});
console.log(markdown);
```
#### Response
```json
{
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
],
"result": "result"
}
```
## Domain Types
### Markdown Create Response
- `MarkdownCreateResponse = string`
Markdown content.
# Crawl
## Crawl websites.
`client.browserRendering.crawl.create(CrawlCreateParamsparams, RequestOptionsoptions?): CrawlCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/crawl`
Starts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.
### Parameters
- `CrawlCreateParams = Variant0 | Variant1`
- `CrawlCreateParamsBase`
- `Variant0 extends CrawlCreateParamsBase`
- `Variant1 extends CrawlCreateParamsBase`
### Returns
- `CrawlCreateResponse = string`
Crawl job ID.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const crawl = await client.browserRendering.crawl.create({
account_id: 'account_id',
url: 'https://example.com',
});
console.log(crawl);
```
#### Response
```json
{
"result": "result",
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Get crawl result.
`client.browserRendering.crawl.get(stringjobId, CrawlGetParamsparams, RequestOptionsoptions?): CrawlGetResponse`
**get** `/accounts/{account_id}/browser-rendering/crawl/{job_id}`
Returns the result of a crawl job.
### Parameters
- `jobId: string`
Crawl job ID.
- `params: CrawlGetParams`
- `account_id: string`
Path param: Account ID.
- `cacheTTL?: number`
Query param: Cache TTL default is 5s. Set to 0 to disable.
- `cursor?: number`
Query param: Cursor for pagination.
- `limit?: number`
Query param: Limit for pagination.
- `status?: "queued" | "errored" | "completed" | 3 more`
Query param: Filter by URL status.
- `"queued"`
- `"errored"`
- `"completed"`
- `"disallowed"`
- `"skipped"`
- `"cancelled"`
### Returns
- `CrawlGetResponse`
- `id: string`
Crawl job ID.
- `browserSecondsUsed: number`
Total seconds spent in browser so far.
- `finished: number`
Total number of URLs that have been crawled so far.
- `records: Array`
List of crawl job records.
- `metadata: Metadata`
- `status: number`
HTTP status code of the crawled page.
- `url: string`
Final URL of the crawled page.
- `title?: string`
Title of the crawled page.
- `status: "queued" | "errored" | "completed" | 3 more`
Current status of the crawled URL.
- `"queued"`
- `"errored"`
- `"completed"`
- `"disallowed"`
- `"skipped"`
- `"cancelled"`
- `url: string`
Crawled URL.
- `html?: string`
HTML content of the crawled URL.
- `json?: Record`
JSON of the content of the crawled URL.
- `markdown?: string`
Markdown of the content of the crawled URL.
- `skipped: number`
Total number of URLs that were skipped due to include/exclude/subdomain filters. Skipped URLs are included in records but are not counted toward total/finished.
- `status: string`
Current crawl job status.
- `total: number`
Total current number of URLs in the crawl job.
- `cursor?: string`
Cursor for pagination.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const crawl = await client.browserRendering.crawl.get('x', { account_id: 'account_id' });
console.log(crawl.id);
```
#### Response
```json
{
"result": {
"id": "id",
"browserSecondsUsed": 0,
"finished": 0,
"records": [
{
"metadata": {
"status": 0,
"url": "url",
"title": "title"
},
"status": "queued",
"url": "url",
"html": "html",
"json": {
"foo": {}
},
"markdown": "markdown"
}
],
"skipped": 0,
"status": "status",
"total": 0,
"cursor": "cursor"
},
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Cancel a crawl job.
`client.browserRendering.crawl.delete(stringjobId, CrawlDeleteParamsparams, RequestOptionsoptions?): CrawlDeleteResponse`
**delete** `/accounts/{account_id}/browser-rendering/crawl/{job_id}`
Cancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs.
### Parameters
- `jobId: string`
The ID of the crawl job to cancel.
- `params: CrawlDeleteParams`
- `account_id: string`
Account ID.
### Returns
- `CrawlDeleteResponse`
- `job_id: string`
The ID of the cancelled job.
- `message: string`
Cancellation confirmation message.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const crawl = await client.browserRendering.crawl.delete('job_id', { account_id: 'account_id' });
console.log(crawl.job_id);
```
#### Response
```json
{
"result": {
"job_id": "job_id",
"message": "message"
},
"success": true,
"errors": [
{
"code": 0,
"message": "message"
}
]
}
```
## Domain Types
### Crawl Create Response
- `CrawlCreateResponse = string`
Crawl job ID.
### Crawl Get Response
- `CrawlGetResponse`
- `id: string`
Crawl job ID.
- `browserSecondsUsed: number`
Total seconds spent in browser so far.
- `finished: number`
Total number of URLs that have been crawled so far.
- `records: Array`
List of crawl job records.
- `metadata: Metadata`
- `status: number`
HTTP status code of the crawled page.
- `url: string`
Final URL of the crawled page.
- `title?: string`
Title of the crawled page.
- `status: "queued" | "errored" | "completed" | 3 more`
Current status of the crawled URL.
- `"queued"`
- `"errored"`
- `"completed"`
- `"disallowed"`
- `"skipped"`
- `"cancelled"`
- `url: string`
Crawled URL.
- `html?: string`
HTML content of the crawled URL.
- `json?: Record`
JSON of the content of the crawled URL.
- `markdown?: string`
Markdown of the content of the crawled URL.
- `skipped: number`
Total number of URLs that were skipped due to include/exclude/subdomain filters. Skipped URLs are included in records but are not counted toward total/finished.
- `status: string`
Current crawl job status.
- `total: number`
Total current number of URLs in the crawl job.
- `cursor?: string`
Cursor for pagination.
### Crawl Delete Response
- `CrawlDeleteResponse`
- `job_id: string`
The ID of the cancelled job.
- `message: string`
Cancellation confirmation message.
# Devtools
# Session
## List sessions.
`client.browserRendering.devtools.session.list(SessionListParamsparams, RequestOptionsoptions?): SessionListResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/session`
List active browser sessions.
### Parameters
- `params: SessionListParams`
- `account_id: string`
Path param: Account ID.
- `limit?: number`
Query param
- `offset?: number`
Query param
### Returns
- `SessionListResponse = Array`
- `sessionId: string`
Session ID.
- `closeReason?: string`
Reason for session closure.
- `closeReasonText?: string`
Human-readable close reason.
- `connectionEndTime?: number`
Connection end time.
- `connectionId?: string`
Connection ID.
- `connectionStartTime?: number`
Connection start time.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `endTime?: number`
Session end time.
- `lastUpdated?: number`
Last updated timestamp.
- `startTime?: number`
Session start time.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const sessions = await client.browserRendering.devtools.session.list({ account_id: 'account_id' });
console.log(sessions);
```
#### Response
```json
[
{
"sessionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"closeReason": "closeReason",
"closeReasonText": "closeReasonText",
"connectionEndTime": 0,
"connectionId": "connectionId",
"connectionStartTime": 0,
"devtoolsFrontendUrl": "devtoolsFrontendUrl",
"endTime": 0,
"lastUpdated": 0,
"startTime": 0,
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
]
```
## Get session details.
`client.browserRendering.devtools.session.get(stringsessionId, SessionGetParamsparams, RequestOptionsoptions?): SessionGetResponse | null`
**get** `/accounts/{account_id}/browser-rendering/devtools/session/{session_id}`
Get details for a specific browser session.
### Parameters
- `sessionId: string`
Session ID.
- `params: SessionGetParams`
- `account_id: string`
Account ID.
### Returns
- `SessionGetResponse`
- `sessionId: string`
Session ID.
- `closeReason?: string`
Reason for session closure.
- `closeReasonText?: string`
Human-readable close reason.
- `connectionEndTime?: number`
Connection end time.
- `connectionId?: string`
Connection ID.
- `connectionStartTime?: number`
Connection start time.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `endTime?: number`
Session end time.
- `lastUpdated?: number`
Last updated timestamp.
- `startTime?: number`
Session start time.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const session = await client.browserRendering.devtools.session.get(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(session.sessionId);
```
#### Response
```json
{
"sessionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"closeReason": "closeReason",
"closeReasonText": "closeReasonText",
"connectionEndTime": 0,
"connectionId": "connectionId",
"connectionStartTime": 0,
"devtoolsFrontendUrl": "devtoolsFrontendUrl",
"endTime": 0,
"lastUpdated": 0,
"startTime": 0,
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
```
## Domain Types
### Session List Response
- `SessionListResponse = Array`
- `sessionId: string`
Session ID.
- `closeReason?: string`
Reason for session closure.
- `closeReasonText?: string`
Human-readable close reason.
- `connectionEndTime?: number`
Connection end time.
- `connectionId?: string`
Connection ID.
- `connectionStartTime?: number`
Connection start time.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `endTime?: number`
Session end time.
- `lastUpdated?: number`
Last updated timestamp.
- `startTime?: number`
Session start time.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Session Get Response
- `SessionGetResponse`
- `sessionId: string`
Session ID.
- `closeReason?: string`
Reason for session closure.
- `closeReasonText?: string`
Human-readable close reason.
- `connectionEndTime?: number`
Connection end time.
- `connectionId?: string`
Connection ID.
- `connectionStartTime?: number`
Connection start time.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `endTime?: number`
Session end time.
- `lastUpdated?: number`
Last updated timestamp.
- `startTime?: number`
Session start time.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
# Browser
## Get a browser session ID.
`client.browserRendering.devtools.browser.create(BrowserCreateParamsparams, RequestOptionsoptions?): BrowserCreateResponse`
**post** `/accounts/{account_id}/browser-rendering/devtools/browser`
Get a browser session ID.
### Parameters
- `params: BrowserCreateParams`
- `account_id: string`
Path param: Account ID.
- `keep_alive?: number`
Query param: Keep-alive time in milliseconds.
- `lab?: boolean`
Query param: Use experimental browser.
- `recording?: boolean`
Query param
- `targets?: boolean`
Query param: Include browser targets in response.
### Returns
- `BrowserCreateResponse`
- `sessionId: string`
Browser session ID.
- `webSocketDebuggerUrl?: string`
WebSocket URL for the session.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const browser = await client.browserRendering.devtools.browser.create({ account_id: 'account_id' });
console.log(browser.sessionId);
```
#### Response
```json
{
"sessionId": "sessionId",
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
```
## Acquire and connect to browser session.
`client.browserRendering.devtools.browser.launch(BrowserLaunchParamsparams, RequestOptionsoptions?): void`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser`
Acquires and establishes a WebSocket connection to a browser session.
### Parameters
- `params: BrowserLaunchParams`
- `account_id: string`
Path param: Account ID.
- `keep_alive?: number`
Query param: Keep-alive time in ms (only valid when acquiring new session).
- `lab?: boolean`
Query param: Use experimental browser.
- `recording?: boolean`
Query param
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
await client.browserRendering.devtools.browser.launch({ account_id: 'account_id' });
```
## Connect to browser session.
`client.browserRendering.devtools.browser.connect(stringsessionId, BrowserConnectParamsparams, RequestOptionsoptions?): void`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}`
Establishes a WebSocket connection to an existing browser session.
### Parameters
- `sessionId: string`
Browser session ID to connect to.
- `params: BrowserConnectParams`
- `account_id: string`
Path param: Account ID.
- `keep_alive?: number`
Query param: Keep-alive time in ms (only valid when acquiring new session).
- `lab?: boolean`
Query param: Use experimental browser.
- `recording?: boolean`
Query param
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
await client.browserRendering.devtools.browser.connect('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
account_id: 'account_id',
});
```
## Close browser session.
`client.browserRendering.devtools.browser.delete(stringsessionId, BrowserDeleteParamsparams, RequestOptionsoptions?): BrowserDeleteResponse`
**delete** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}`
Closes an existing browser session.
### Parameters
- `sessionId: string`
Browser session ID to close.
- `params: BrowserDeleteParams`
- `account_id: string`
Account ID.
### Returns
- `BrowserDeleteResponse`
- `status: "closing" | "closed"`
- `"closing"`
- `"closed"`
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const browser = await client.browserRendering.devtools.browser.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(browser.status);
```
#### Response
```json
{
"status": "closing"
}
```
## Get browser version metadata.
`client.browserRendering.devtools.browser.version(stringsessionId, BrowserVersionParamsparams, RequestOptionsoptions?): BrowserVersionResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version`
Get browser version metadata.
### Parameters
- `sessionId: string`
Browser session ID.
- `params: BrowserVersionParams`
- `account_id: string`
Account ID.
### Returns
- `BrowserVersionResponse`
- `Browser: string`
Browser name and version.
- `"Protocol-Version": string`
Chrome DevTools Protocol version.
- `"User-Agent": string`
User agent string.
- `"V8-Version": string`
V8 JavaScript engine version.
- `"WebKit-Version": string`
WebKit version.
- `webSocketDebuggerUrl: string`
WebSocket URL for debugging the browser.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const response = await client.browserRendering.devtools.browser.version(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(response.Browser);
```
#### Response
```json
{
"Browser": "Browser",
"Protocol-Version": "Protocol-Version",
"User-Agent": "User-Agent",
"V8-Version": "V8-Version",
"WebKit-Version": "WebKit-Version",
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
```
## Get Chrome DevTools Protocol schema.
`client.browserRendering.devtools.browser.protocol(stringsessionId, BrowserProtocolParamsparams, RequestOptionsoptions?): BrowserProtocolResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/protocol`
Returns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface.
### Parameters
- `sessionId: string`
Browser session ID.
- `params: BrowserProtocolParams`
- `account_id: string`
Account ID.
### Returns
- `BrowserProtocolResponse`
- `domains: Array`
List of protocol domains.
- `domain: string`
Domain name.
- `commands?: Array>`
Available commands.
- `dependencies?: Array`
Domain dependencies.
- `events?: Array>`
Available events.
- `experimental?: boolean`
Whether this domain is experimental.
- `types?: Array>`
Type definitions.
- `version?: Version`
Protocol version.
- `major: string`
Major version.
- `minor: string`
Minor version.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const response = await client.browserRendering.devtools.browser.protocol(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(response.domains);
```
#### Response
```json
{
"domains": [
{
"domain": "domain",
"commands": [
{
"foo": {}
}
],
"dependencies": [
"string"
],
"events": [
{
"foo": {}
}
],
"experimental": true,
"types": [
{
"foo": {}
}
]
}
],
"version": {
"major": "major",
"minor": "minor"
}
}
```
## Domain Types
### Browser Create Response
- `BrowserCreateResponse`
- `sessionId: string`
Browser session ID.
- `webSocketDebuggerUrl?: string`
WebSocket URL for the session.
### Browser Delete Response
- `BrowserDeleteResponse`
- `status: "closing" | "closed"`
- `"closing"`
- `"closed"`
### Browser Version Response
- `BrowserVersionResponse`
- `Browser: string`
Browser name and version.
- `"Protocol-Version": string`
Chrome DevTools Protocol version.
- `"User-Agent": string`
User agent string.
- `"V8-Version": string`
V8 JavaScript engine version.
- `"WebKit-Version": string`
WebKit version.
- `webSocketDebuggerUrl: string`
WebSocket URL for debugging the browser.
### Browser Protocol Response
- `BrowserProtocolResponse`
- `domains: Array`
List of protocol domains.
- `domain: string`
Domain name.
- `commands?: Array>`
Available commands.
- `dependencies?: Array`
Domain dependencies.
- `events?: Array>`
Available events.
- `experimental?: boolean`
Whether this domain is experimental.
- `types?: Array>`
Type definitions.
- `version?: Version`
Protocol version.
- `major: string`
Major version.
- `minor: string`
Minor version.
# Page
## Connect to a specific Chrome DevTools page.
`client.browserRendering.devtools.browser.page.get(stringsessionId, stringtargetId, PageGetParamsparams, RequestOptionsoptions?): void`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/page/{target_id}`
Establishes a WebSocket connection to a specific Chrome DevTools target or page.
### Parameters
- `sessionId: string`
Browser session ID.
- `targetId: string`
Target ID, e.g. page ID.
- `params: PageGetParams`
- `account_id: string`
Account ID.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
await client.browserRendering.devtools.browser.page.get(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'target_id',
{ account_id: 'account_id' },
);
```
# Targets
## Open a new browser tab.
`client.browserRendering.devtools.browser.targets.create(stringsessionId, TargetCreateParamsparams, RequestOptionsoptions?): TargetCreateResponse`
**put** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new`
Opens a new tab in the browser. Optionally specify a URL to navigate to.
### Parameters
- `sessionId: string`
Browser session ID.
- `params: TargetCreateParams`
- `account_id: string`
Path param: Account ID.
- `url?: string`
Query param
### Returns
- `TargetCreateResponse`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const target = await client.browserRendering.devtools.browser.targets.create(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(target.id);
```
#### Response
```json
{
"id": "id",
"type": "type",
"url": "url",
"description": "description",
"devtoolsFrontendUrl": "devtoolsFrontendUrl",
"title": "title",
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
```
## List targets.
`client.browserRendering.devtools.browser.targets.list(stringsessionId, TargetListParamsparams, RequestOptionsoptions?): TargetListResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list`
Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.
### Parameters
- `sessionId: string`
Browser session ID.
- `params: TargetListParams`
- `account_id: string`
Account ID.
### Returns
- `TargetListResponse = Array`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const targets = await client.browserRendering.devtools.browser.targets.list(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{ account_id: 'account_id' },
);
console.log(targets);
```
#### Response
```json
[
{
"id": "id",
"type": "type",
"url": "url",
"description": "description",
"devtoolsFrontendUrl": "devtoolsFrontendUrl",
"title": "title",
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
]
```
## Get a target by ID.
`client.browserRendering.devtools.browser.targets.get(stringsessionId, stringtargetId, TargetGetParamsparams, RequestOptionsoptions?): TargetGetResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}`
Returns the debuggable target with the given ID.
### Parameters
- `sessionId: string`
Browser session ID.
- `targetId: string`
Target ID.
- `params: TargetGetParams`
- `account_id: string`
Account ID.
### Returns
- `TargetGetResponse`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const target = await client.browserRendering.devtools.browser.targets.get(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'target_id',
{ account_id: 'account_id' },
);
console.log(target.id);
```
#### Response
```json
{
"id": "id",
"type": "type",
"url": "url",
"description": "description",
"devtoolsFrontendUrl": "devtoolsFrontendUrl",
"title": "title",
"webSocketDebuggerUrl": "webSocketDebuggerUrl"
}
```
## Activate a browser target.
`client.browserRendering.devtools.browser.targets.activate(stringsessionId, stringtargetId, TargetActivateParamsparams, RequestOptionsoptions?): TargetActivateResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}`
Activates (brings to front) a specific browser target by its ID.
### Parameters
- `sessionId: string`
Browser session ID.
- `targetId: string`
Target ID to activate.
- `params: TargetActivateParams`
- `account_id: string`
Account ID.
### Returns
- `TargetActivateResponse`
- `message: string`
Target activated.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const response = await client.browserRendering.devtools.browser.targets.activate(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'target_id',
{ account_id: 'account_id' },
);
console.log(response.message);
```
#### Response
```json
{
"message": "message"
}
```
## Close a browser target.
`client.browserRendering.devtools.browser.targets.close(stringsessionId, stringtargetId, TargetCloseParamsparams, RequestOptionsoptions?): TargetCloseResponse`
**get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/close/{target_id}`
Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found.
### Parameters
- `sessionId: string`
Browser session ID.
- `targetId: string`
Target ID to close.
- `params: TargetCloseParams`
- `account_id: string`
Account ID.
### Returns
- `TargetCloseResponse`
- `message: string`
Target is closing.
### Example
```node
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const response = await client.browserRendering.devtools.browser.targets.close(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'target_id',
{ account_id: 'account_id' },
);
console.log(response.message);
```
#### Response
```json
{
"message": "message"
}
```
## Domain Types
### Target Create Response
- `TargetCreateResponse`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Target List Response
- `TargetListResponse = Array`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Target Get Response
- `TargetGetResponse`
- `id: string`
Target ID.
- `type: string`
Target type (page, background_page, worker, etc.).
- `url: string`
URL of the target.
- `description?: string`
Target description.
- `devtoolsFrontendUrl?: string`
DevTools frontend URL.
- `title?: string`
Title of the target.
- `webSocketDebuggerUrl?: string`
WebSocket URL for debugging this target.
### Target Activate Response
- `TargetActivateResponse`
- `message: string`
Target activated.
### Target Close Response
- `TargetCloseResponse`
- `message: string`
Target is closing.