Registry / http-networking / cdp-use

cdp-use

JSON →
library1.4.5pypypi✓ verified 28d ago

CDP-Use is a type-safe Python client library for the Chrome DevTools Protocol (CDP). It provides auto-generated, strongly-typed commands and events, allowing for interaction with browsers like Chrome and Edge, or browser automation tools like Playwright and Puppeteer. It is actively maintained with regular releases, currently at version 1.4.5.

pip install cdp-use
INSTALL
IMPORT
SIG · CDP-USE
C
cdp-use
http-networkingpythonv1.4.5
Install
2.6s avg
Import
363ms
Disk
25MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.4.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 2.8s
py 3.12
✓ —
✓ 2.5s
py 3.13
✓ —
✓ 2.6s
py 3.9
✕ build_error
✕ build_error
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CDPClient
✓ from cdp_use import CDPClient
✗ from cdp_use import CDP
client
✓ from cdp_use import client

This quickstart demonstrates how to connect to a browser's CDP endpoint, navigate to a URL, and fetch some basic page information. Ensure you have a browser running with remote debugging enabled (e.g., `chrome --remote-debugging-port=9222`).

import asyncio from cdp_use import CDP from cdp_use.target import Target import os async def main(): # Ensure Chrome/Edge is running with --remote-debugging-port=9222 # or connect to a Playwright/Puppeteer launched browser. # The URL can be an HTTP endpoint ('http://...') or a WebSocket URL ('ws://...') cdp_url = os.environ.get("CDP_DEBUGGING_URL", "http://127.0.0.1:9222") async with CDP(Target(cdp_url)) as cdp: page = cdp.page await page.enable() print(f"Navigating to example.com via CDP...") await page.navigate("https://www.example.com") # Wait for navigation to complete (e.g., load event) await page.await_load_event() current_url = await page.get_navigated_history().result.current_entry.url print(f"Current URL: {current_url}") # Example: Get document layout metrics layout_metrics = await page.get_layout_metrics() print(f"Document content width: {layout_metrics.content_size.width}") await asyncio.sleep(2) # Keep the connection alive briefly for inspection asyncio.run(main())
Debug
Known issues
breakingThe library was renamed from `cdp-py` to `cdp-use` starting with version 1.0.0. All previous imports (`from cdp_py import ...`) and parts of the API surface are incompatible with `cdp-use`.
fix
Update imports from `cdp_py` to `cdp_use` and refactor code to match the new API design. Refer to the `cdp-use` documentation for the updated API.
affects: 1.0.0+
gotchaCDP-Use connects to an existing Chrome DevTools Protocol endpoint. You must have a browser (Chrome, Edge, Playwright-launched, etc.) running with remote debugging enabled and accessible at the specified `Target` URL.
fix
Ensure your browser is launched with `--remote-debugging-port=<port>` (e.g., `chrome --remote-debugging-port=9222`) or that your browser automation setup (Playwright, Puppeteer) exposes a CDP endpoint.
affects: All
gotchaThe `CDP` client is an asynchronous context manager. It's crucial to use it within an `async with` statement to ensure proper connection establishment and graceful closure of the WebSocket connection.
fix
Always instantiate and manage the `CDP` client using `async with CDP(Target(...)) as cdp:` within an `async` function.
affects: All
Upgrade
Version history
1.4.5latest on PyPI · released Feb 22, 2026
Audit
Dependencies
websocketsrequiredRequired for establishing WebSocket connections to CDP endpoints.
pydanticrequiredUsed for type validation and data parsing of CDP messages.
Agent activity
38 hits · last 30 days
node
34
OpenAI (training)
1
Resources
cdp-use — pip install cdp-use · libregistry