Installation
Async API (Recommended)
Sync API (Scripts and Notebooks)
High-Level Session Helper
Thebap_session context manager handles browser launch, page creation, and cleanup:
Semantic Selectors
AI Agent Methods
observe -- AI-optimized page snapshots
observe -- AI-optimized page snapshots
act -- Multi-step sequences
act -- Multi-step sequences
extract -- Structured data extraction
extract -- Structured data extraction
Multi-Context Support
Create isolated browser contexts with separate cookies and storage:Frame Support
Error Handling
Starting the Server
The Python SDK requires a running BAP server:The Python SDK connects to a BAP server over WebSocket. The server itself is a Node.js process —
install it via npm.
Requirements
- Python >= 3.10
- A running BAP Playwright server