# Devtools # Session ## List sessions. `browser_rendering.devtools.session.list(SessionListParams**kwargs) -> SessionListResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/session` List active browser sessions. ### Parameters - `account_id: Optional[str]` Account ID. - `limit: Optional[float]` - `offset: Optional[float]` ### Returns - `List[SessionListResponseItem]` - `session_id: str` Session ID. - `close_reason: Optional[str]` Reason for session closure. - `close_reason_text: Optional[str]` Human-readable close reason. - `connection_end_time: Optional[float]` Connection end time. - `connection_id: Optional[str]` Connection ID. - `connection_start_time: Optional[float]` Connection start time. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `end_time: Optional[float]` Session end time. - `last_updated: Optional[float]` Last updated timestamp. - `start_time: Optional[float]` Session start time. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) sessions = client.browser_rendering.devtools.session.list( account_id="account_id", ) print(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. `browser_rendering.devtools.session.get(strsession_id, SessionGetParams**kwargs) -> SessionGetResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/session/{session_id}` Get details for a specific browser session. ### Parameters - `account_id: Optional[str]` Account ID. - `session_id: str` Session ID. ### Returns - `class SessionGetResponse: …` - `session_id: str` Session ID. - `close_reason: Optional[str]` Reason for session closure. - `close_reason_text: Optional[str]` Human-readable close reason. - `connection_end_time: Optional[float]` Connection end time. - `connection_id: Optional[str]` Connection ID. - `connection_start_time: Optional[float]` Connection start time. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `end_time: Optional[float]` Session end time. - `last_updated: Optional[float]` Last updated timestamp. - `start_time: Optional[float]` Session start time. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) session = client.browser_rendering.devtools.session.get( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(session.session_id) ``` #### 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 - `List[SessionListResponseItem]` - `session_id: str` Session ID. - `close_reason: Optional[str]` Reason for session closure. - `close_reason_text: Optional[str]` Human-readable close reason. - `connection_end_time: Optional[float]` Connection end time. - `connection_id: Optional[str]` Connection ID. - `connection_start_time: Optional[float]` Connection start time. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `end_time: Optional[float]` Session end time. - `last_updated: Optional[float]` Last updated timestamp. - `start_time: Optional[float]` Session start time. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Session Get Response - `class SessionGetResponse: …` - `session_id: str` Session ID. - `close_reason: Optional[str]` Reason for session closure. - `close_reason_text: Optional[str]` Human-readable close reason. - `connection_end_time: Optional[float]` Connection end time. - `connection_id: Optional[str]` Connection ID. - `connection_start_time: Optional[float]` Connection start time. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `end_time: Optional[float]` Session end time. - `last_updated: Optional[float]` Last updated timestamp. - `start_time: Optional[float]` Session start time. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. # Browser ## Get a browser session ID. `browser_rendering.devtools.browser.create(BrowserCreateParams**kwargs) -> BrowserCreateResponse` **post** `/accounts/{account_id}/browser-rendering/devtools/browser` Get a browser session ID. ### Parameters - `account_id: Optional[str]` Account ID. - `keep_alive: Optional[float]` Keep-alive time in milliseconds. - `lab: Optional[bool]` Use experimental browser. - `recording: Optional[bool]` - `targets: Optional[bool]` Include browser targets in response. ### Returns - `class BrowserCreateResponse: …` - `session_id: str` Browser session ID. - `web_socket_debugger_url: Optional[str]` WebSocket URL for the session. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) browser = client.browser_rendering.devtools.browser.create( account_id="account_id", ) print(browser.session_id) ``` #### Response ```json { "sessionId": "sessionId", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Acquire and connect to browser session. `browser_rendering.devtools.browser.launch(BrowserLaunchParams**kwargs)` **get** `/accounts/{account_id}/browser-rendering/devtools/browser` Acquires and establishes a WebSocket connection to a browser session. ### Parameters - `account_id: Optional[str]` Account ID. - `keep_alive: Optional[float]` Keep-alive time in ms (only valid when acquiring new session). - `lab: Optional[bool]` Use experimental browser. - `recording: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.browser_rendering.devtools.browser.launch( account_id="account_id", ) ``` ## Connect to browser session. `browser_rendering.devtools.browser.connect(strsession_id, BrowserConnectParams**kwargs)` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}` Establishes a WebSocket connection to an existing browser session. ### Parameters - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID to connect to. - `keep_alive: Optional[float]` Keep-alive time in ms (only valid when acquiring new session). - `lab: Optional[bool]` Use experimental browser. - `recording: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.browser_rendering.devtools.browser.connect( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) ``` ## Close browser session. `browser_rendering.devtools.browser.delete(strsession_id, BrowserDeleteParams**kwargs) -> BrowserDeleteResponse` **delete** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}` Closes an existing browser session. ### Parameters - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID to close. ### Returns - `class BrowserDeleteResponse: …` - `status: Literal["closing", "closed"]` - `"closing"` - `"closed"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) browser = client.browser_rendering.devtools.browser.delete( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(browser.status) ``` #### Response ```json { "status": "closing" } ``` ## Get browser version metadata. `browser_rendering.devtools.browser.version(strsession_id, BrowserVersionParams**kwargs) -> BrowserVersionResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/version` Get browser version metadata. ### Parameters - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. ### Returns - `class BrowserVersionResponse: …` - `browser: str` Browser name and version. - `protocol_version: str` Chrome DevTools Protocol version. - `user_agent: str` User agent string. - `v8_version: str` V8 JavaScript engine version. - `web_kit_version: str` WebKit version. - `web_socket_debugger_url: str` WebSocket URL for debugging the browser. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.browser_rendering.devtools.browser.version( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(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. `browser_rendering.devtools.browser.protocol(strsession_id, BrowserProtocolParams**kwargs) -> 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 - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. ### Returns - `class BrowserProtocolResponse: …` - `domains: List[Domain]` List of protocol domains. - `domain: str` Domain name. - `commands: Optional[List[Dict[str, Optional[object]]]]` Available commands. - `dependencies: Optional[List[str]]` Domain dependencies. - `events: Optional[List[Dict[str, Optional[object]]]]` Available events. - `experimental: Optional[bool]` Whether this domain is experimental. - `types: Optional[List[Dict[str, Optional[object]]]]` Type definitions. - `version: Optional[Version]` Protocol version. - `major: str` Major version. - `minor: str` Minor version. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.browser_rendering.devtools.browser.protocol( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(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 - `class BrowserCreateResponse: …` - `session_id: str` Browser session ID. - `web_socket_debugger_url: Optional[str]` WebSocket URL for the session. ### Browser Delete Response - `class BrowserDeleteResponse: …` - `status: Literal["closing", "closed"]` - `"closing"` - `"closed"` ### Browser Version Response - `class BrowserVersionResponse: …` - `browser: str` Browser name and version. - `protocol_version: str` Chrome DevTools Protocol version. - `user_agent: str` User agent string. - `v8_version: str` V8 JavaScript engine version. - `web_kit_version: str` WebKit version. - `web_socket_debugger_url: str` WebSocket URL for debugging the browser. ### Browser Protocol Response - `class BrowserProtocolResponse: …` - `domains: List[Domain]` List of protocol domains. - `domain: str` Domain name. - `commands: Optional[List[Dict[str, Optional[object]]]]` Available commands. - `dependencies: Optional[List[str]]` Domain dependencies. - `events: Optional[List[Dict[str, Optional[object]]]]` Available events. - `experimental: Optional[bool]` Whether this domain is experimental. - `types: Optional[List[Dict[str, Optional[object]]]]` Type definitions. - `version: Optional[Version]` Protocol version. - `major: str` Major version. - `minor: str` Minor version. # Page ## Connect to a specific Chrome DevTools page. `browser_rendering.devtools.browser.page.get(strtarget_id, PageGetParams**kwargs)` **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 - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. - `target_id: str` Target ID, e.g. page ID. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.browser_rendering.devtools.browser.page.get( target_id="target_id", account_id="account_id", session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) ``` # Targets ## Open a new browser tab. `browser_rendering.devtools.browser.targets.create(strsession_id, TargetCreateParams**kwargs) -> 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 - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. - `url: Optional[str]` ### Returns - `class TargetCreateResponse: …` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) target = client.browser_rendering.devtools.browser.targets.create( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(target.id) ``` #### Response ```json { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## List targets. `browser_rendering.devtools.browser.targets.list(strsession_id, TargetListParams**kwargs) -> 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 - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. ### Returns - `List[TargetListResponseItem]` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) targets = client.browser_rendering.devtools.browser.targets.list( session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", account_id="account_id", ) print(targets) ``` #### Response ```json [ { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ] ``` ## Get a target by ID. `browser_rendering.devtools.browser.targets.get(strtarget_id, TargetGetParams**kwargs) -> TargetGetResponse` **get** `/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}` Returns the debuggable target with the given ID. ### Parameters - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. - `target_id: str` Target ID. ### Returns - `class TargetGetResponse: …` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) target = client.browser_rendering.devtools.browser.targets.get( target_id="target_id", account_id="account_id", session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(target.id) ``` #### Response ```json { "id": "id", "type": "type", "url": "url", "description": "description", "devtoolsFrontendUrl": "devtoolsFrontendUrl", "title": "title", "webSocketDebuggerUrl": "webSocketDebuggerUrl" } ``` ## Activate a browser target. `browser_rendering.devtools.browser.targets.activate(strtarget_id, TargetActivateParams**kwargs) -> 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 - `account_id: Optional[str]` Account ID. - `session_id: str` Browser session ID. - `target_id: str` Target ID to activate. ### Returns - `class TargetActivateResponse: …` - `message: str` Target activated. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.browser_rendering.devtools.browser.targets.activate( target_id="target_id", account_id="account_id", session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(response.message) ``` #### Response ```json { "message": "message" } ``` ## Domain Types ### Target Create Response - `class TargetCreateResponse: …` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Target List Response - `List[TargetListResponseItem]` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Target Get Response - `class TargetGetResponse: …` - `id: str` Target ID. - `type: str` Target type (page, background_page, worker, etc.). - `url: str` URL of the target. - `description: Optional[str]` Target description. - `devtools_frontend_url: Optional[str]` DevTools frontend URL. - `title: Optional[str]` Title of the target. - `web_socket_debugger_url: Optional[str]` WebSocket URL for debugging this target. ### Target Activate Response - `class TargetActivateResponse: …` - `message: str` Target activated.