Skip to main content

cdpwave

Chrome DevTools Protocol for Python — direct, typed, async

60 CDP domains · 692 typed methods · zero Node.js · zero ChromeDriver · zero browser downloads


CI PyPI Python License: MIT Docs

Chrome DevTools Protocol for Python — direct, typed, async. cdpwave talks to Chrome over a raw WebSocket. No Node.js, no ChromeDriver, no browser downloads. Just pure Python with full type hints and async-first design.

Quick demo

30 seconds to your first CDP call.

pip install cdpwave
import asyncio
from cdpwave import CDPClient

async def main() -> None:
    async with await CDPClient.launch(headless=True) as client:
        session = await client.new_page("https://example.com")
        result = await session.runtime.evaluate("document.title", return_by_value=True)
        print(result["result"]["value"])  # "Example Domain"
        await session.close()

asyncio.run(main())

Why cdpwave?

cdpwave is a low-level Chrome DevTools Protocol client for Python. It talks directly to Chrome's WebSocket endpoint — no Node.js, no ChromeDriver, no Selenium, no Playwright. Just pure async Python with full type hints.

It is the CDP backend that powers wavexis and wavexis-mcp.

Key features

  • Broad CDP coverage — 60 domains with 692 typed methods (~95% of the protocol), plus session.send() for the rest
  • Direct WebSocket — single connection to Chrome's DevTools Protocol, no intermediate layers
  • Fully typed — mypy --strict across the entire codebase, IDE autocomplete everywhere
  • Async-first — built on asyncio, no threading, no blocking calls
  • Browser detection — finds Chrome, Edge, Brave, or Chromium already on your system
  • Flatten sessions — one WebSocket for all tabs via Target.attachToTarget + sessionId
  • Escape hatch — session.send("Any.CDPMethod", params) for any uncovered command
  • HTTP discovery — typed access to /json/version and /json/list endpoints
  • WebSocket keepalive — automatic ping/pong with configurable interval and timeout
  • Direct WebSocket URL — CDPClient.connect(ws_url=...) bypasses HTTP discovery
  • Event helpers — session.wait_for_event() and session.on() for async event handling
  • Multi-tab sessions — client.sessions property tracks all active sessions
  • 1437 integration tests — against a real Chromium browser covering all domains

How it works

Your Python code
  → CDPClient.launch() finds and starts Chrome
    → Connects to Chrome's WebSocket endpoint
      → session.runtime.evaluate("document.title")
        → Chrome executes and returns the result
      ← Typed response parsed into Python dicts
    ← Session stays open for chained calls
  ← Browser closes on context exit

Core concepts

  • CDPClient — The top-level client. Launches Chrome, manages the WebSocket connection, and creates sessions.
  • Session — A CDP target (tab, page, worker). Each session has its own method namespace (session.runtime, session.page, session.network, etc.).
  • Domain — A CDP namespace like Runtime, Page, Network, DOM. Each domain has typed methods with full parameter validation.
  • Escape hatch — session.send("Any.CDPMethod", params) lets you call any CDP method, even if cdpwave doesn't have a typed wrapper for it.

Requirements

  • Python 3.11 or higher
  • A Chromium-based browser (Chrome, Edge, Brave, or Chromium) already installed
  • No Node.js, no ChromeDriver, no separate Chromium download

Install

pip install cdpwave

Quick start

import asyncio
from cdpwave import CDPClient

async def main() -> None:
    # Launch Chrome and connect
    async with await CDPClient.launch(headless=True) as client:
        # Open a new tab
        session = await client.new_page("https://example.com")

        # Evaluate JavaScript
        result = await session.runtime.evaluate(
            "document.title", return_by_value=True
        )
        print(result["result"]["value"])  # "Example Domain"

        # Take a screenshot (data is base64-encoded PNG)
        screenshot = await session.page.capture_screenshot()
        with open("screenshot.png", "wb") as f:
            import base64
            f.write(base64.b64decode(screenshot["data"]))

        # Navigate somewhere else
        await session.page.navigate("https://example.org")
        await session.close()

asyncio.run(main())

Connect to an existing browser

from cdpwave import CDPClient

# Connect to a browser already running with --remote-debugging-port
async with await CDPClient.connect(host="localhost", port=9222) as client:
    session = await client.new_page("https://example.com")
    # ...

Export to PDF

import base64

session = await client.new_page("https://example.com")
await session.wait_for_load_state("load")

pdf = await session.page.print_to_pdf(print_background=True)
with open("page.pdf", "wb") as f:
    f.write(base64.b64decode(pdf["data"]))

Emulate a mobile device

# iPhone-sized viewport with a mobile user agent
await session.emulation.set_device_metrics_override(
    width=390, height=844, device_scale_factor=3, mobile=True
)
await session.emulation.set_user_agent_override(
    "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) "
    "AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1"
)
await session.page.navigate("https://example.com")

Intercept and mock requests

async def on_request_paused(params):
    await session.fetch.fulfill_request(
        params["requestId"],
        response_code=200,
        response_headers=[{"name": "Content-Type", "value": "application/json"}],
        body=base64.b64encode(b'{"mocked": true}').decode(),
    )

await session.fetch.enable(patterns=[{"urlPattern": "*/api/*"}])
session.on("Fetch.requestPaused", on_request_paused)
await session.page.navigate("https://example.com")

Type into a page

document = await session.dom.get_document()
node = await session.dom.query_selector(
    document["root"]["nodeId"], "input[name=q]"
)
await session.dom.focus(node["nodeId"])
await session.input.insert_text("hello world")
await session.input.dispatch_key_event("keyDown", key="Enter", code="Enter")
await session.input.dispatch_key_event("keyUp", key="Enter", code="Enter")

Multi-tab sessions

async with await CDPClient.launch() as client:
    tab1 = await client.new_page("https://example.com")
    tab2 = await client.new_page("https://example.org")

    # Each tab is an independent session — screenshot one while the
    # other keeps running
    shot = await tab1.page.capture_screenshot()
    title2 = await tab2.runtime.evaluate("document.title", return_by_value=True)

Synchronous API

Same surface without async/await — useful for scripts and REPLs:

from cdpwave.sync import SyncCDPClient

with SyncCDPClient.launch(headless=True) as client:
    page = client.new_page("https://example.com")
    result = page.runtime.evaluate("document.title", return_by_value=True)
    print(result["result"]["value"])

Escape hatch

Call any CDP method, even if cdpwave doesn't have a typed wrapper:

result = await session.send("Performance.getMetrics", {})
print(result["metrics"])

Event handling

async with await CDPClient.launch() as client:
    session = await client.new_page()

    # Watch every request the page makes
    await session.network.enable()

    def on_request(params):
        print(f"→ {params['request']['method']} {params['request']['url']}")

    session.on("Network.requestWillBeSent", on_request)
    await session.page.navigate("https://example.com")

    # Wait for the page load event
    await session.wait_for_load_state("load")

Documentation

Full documentation at mathiaspaulenko.github.io/cdpwave

Ecosystem

cdpwave is part of the Wave ecosystem — browser automation tools in 100% Python:

Project Description
cdpwave Chrome DevTools Protocol client (this repo)
bidiwave WebDriver BiDi client — cross-browser, W3C standard
wavexis Browser automation CLI — wraps cdpwave + bidiwave
wavexis-mcp MCP server — 220 browser automation tools for LLMs

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines on development setup, code style, testing, and pull request process.

Please read our Code of Conduct before participating.

Security

Found a vulnerability? See SECURITY.md for responsible disclosure.

License

MIT

Metadata

Release files for cdpwave 3.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdpwave 3.3.1
File Size Uploaded Provenance Actions
cdpwave-3.3.1.tar.gz 585.7 kB With provenance Details for cdpwave-3.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cdpwave 3.3.1
File Interpreter ABI Platform Actions
cdpwave-3.3.1-py3-none-any.whl Python 3 none any Details for cdpwave-3.3.1-py3-none-any.whl

Total release size: 773.3 kB

Release files / cdpwave-3.3.1.tar.gz

Download URL cdpwave-3.3.1.tar.gz
Size 585.7 kB
Tags Source
SHA-256 checksum
How to use checksums
60c18e68fa3c715db1835e79fbb6ef518c8e05dd11cbaacaec31031e6ac5a67f
BLAKE2b-256 checksum
How to use checksums
1a64f6c43727cffe6f04caf5f1178022e321030cb0472a26edc495d8aaa65c9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / cdpwave-3.3.1-py3-none-any.whl

Download URL cdpwave-3.3.1-py3-none-any.whl
Size 187.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1884dbeecf8f5950fa81c52ba4c81599e97fdf34c7feb958b96f3bfc41d9d1cc
BLAKE2b-256 checksum
How to use checksums
443240e52ccd815f8a71f64b7948171cb9c1a83c9f671513f41f102a064a0976
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for cdpwave 3.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cdpwave-3.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.3.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page