Browser Automation Protocol: the stealth-first automation SDK
BAP is our typed SDK for TypeScript and Python. Write Puppeteer- and Playwright-shaped code and get managed stealth, residential proxies, and CAPTCHA solving without needing third-party services.
import Browserless from "@browserless.io/bap-ts";
const browser = Browserless.connect({
browserWSEndpoint: "wss://production-sfo.browserless.io/chromium/bql",
token: "YOUR_API_TOKEN",
});
const page = await browser.newPage();Everything you'd have to build yourself, included by default
Stealth, proxies, and CAPTCHA solving are built into BAP, not bolt-ons you configure separately.
page.solve() when a challenge appears, and BAP handles it – no third-party CAPTCHA service to integrate or manage.page.liveURL() returns a shareable link to the running session so you can watch the browser as it navigates and see why a flow stalls.page.mapSelector() maps every matching element to structured data in a single call, while page.markdown() pulls a page down as Markdown.What you can create with BAP
BAP covers the browser automation use cases that break under native Puppeteer or Playwright.
page.mapSelector() calls across multiple pages to get structured datasets from sites that require navigation between pages, not just a single request.Puppeteer and Playwright methods, with stealth you don't have to build
BAP borrows its method names from the libraries your team already uses, so you just need to learn the stealth features, not the API.
TypeScript SDK
Puppeteer-shaped
page.goto(),page.click(),page.type()work as expected.- Fully typed: autocomplete in your editor, errors at the call site, not at runtime.
- Isomorphic: runs in Node and in the browser.
npm install @browserless.io/bap-tsPython SDK
Playwright-shaped
- Matching sync and async surfaces –
bapfor asyncio,bap.sync_apifor synchronous code. - Same method names and options as Playwright, generated from the same BQL schema.
- Keyword argument mismatches raise immediately at the call, not later as a protocol error.
python -m pip install bap-pyGet running in a handful of lines
Both SDKs connect the same way. Install the package, grab a token, and it runs as-is.
Install the package
Pick your language and install from the package registry.
npm install @browserless.io/bap-tsConnect and open a page
Pass your token and the endpoint for your chosen browser. Swap the path to pick stealth level: /chromium/bql is the default, /chrome/bql for a genuine Chrome build, /stealth/bql for full fingerprint hardening.
import Browserless from "@browserless.io/bap-ts";
const browser = Browserless.connect({
browserWSEndpoint: "wss://production-sfo.browserless.io/chromium/bql",
token: "YOUR_API_TOKEN",
});
const page = await browser.newPage();Run your automation
Use familiar method names. The stealth level depends on the endpoint you chose in step 2, with no extra configuration needed either way.
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();Migrate from Puppeteer or Playwright in minutes
BAP isn't a full drop-in replacement, but for most automation workflows the switch is straightforward. Here's what that switch looks like.
- 1
Install BAP alongside your existing code
You don't need to remove Puppeteer or Playwright first. Install BAP, connect a session, and test your core flows before committing.
- 2
Replace the connection
Swap your existing
puppeteer.connect()orchromium.connectOverCDP()call forBrowserless.connect()with your token and chosen endpoint. - 3
Run your existing page code
Most
page.goto(),page.click(), andpage.type()calls work without changes. Where BAP doesn't yet have parity, hand the session back to native Puppeteer or Playwright, and your existing code keeps running. - 4
Add stealth where you need it
Switch the endpoint to
/stealth/bqlfor full fingerprint hardening, or callpage.solve()andpage.proxy()where your pipeline currently fails.
For a full migration guide – including what's supported, what isn't, and how to run BAP and your existing library in parallel – see the migration docs.
Where BAP fits in the Browserless suite
BAP is one of three ways to run browser automation on Browserless. Choose one based on what your code already looks like.
Use BAP if:
- You want managed stealth, proxies, and CAPTCHA solving as typed page methods.
- You're writing TypeScript or Python.
- You want BQL's stealth engine without writing GraphQL.
- You're starting a new automation project.
Use Puppeteer or Playwright directly if:
- You have existing scripts you don't want to rewrite.
- You don't need managed stealth or CAPTCHA solving.
- You want full CDP access and the complete API surface.
Use the REST APIs if:
- You need a single one-off task, such as a screenshot, a PDF, a scrape, or a structured data extraction.
- You don't need a live session.
- You're working in any language over plain HTTP.
BrowserQL: the protocol underneath
BAP is a typed layer on top of BrowserQL (BQL), Browserless's stealth-first GraphQL protocol. Every BAP method call builds and sends a BQL mutation over a WebSocket, one frame per method, which is faster over the wire than a CDP session's thousands of small messages.
You don't need to write BQL to use BAP. But if you're not writing TypeScript or Python, want to generate BQL documents from another tool, or prefer to work directly in the BrowserQL IDE, BQL is fully supported as a first-class interface. All of BAP's capabilities are available through BQL directly.
- BAPTypeScript / Python SDK
- BrowserQLGraphQL protocol over WebSocket
- Browserless stealth engineManaged browsers, proxies, CAPTCHA solving
- Docker pulls
- 173M+
- years in production
- 8
- Type II
- SOC 2
- no credit card required
- Free tier
BAP FAQs
Start building with BAP
Install the SDK, grab a token, and run your first stealth session on the free tier. No credit card required.