Skip to main content
Browser Automation Protocol

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.

Run managed stealth out of the box
Pick your browser endpoint and stealth is handled – fingerprint randomization, human-like delays, and evasion logic run natively inside the engine.
Solve CAPTCHAs with one method
Call page.solve() when a challenge appears, and BAP handles it – no third-party CAPTCHA service to integrate or manage.
Route residential proxies by location
Geo-target a residential proxy by country or city directly on the page object, with no external proxy service to configure.
Debug sessions in real time
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.
Extract structured data in one request
page.mapSelector() maps every matching element to structured data in a single call, while page.markdown() pulls a page down as Markdown.
Hand back to Puppeteer or Playwright any time
BAP doesn't lock you in. You can pass the session back to native Puppeteer or Playwright at any point, while your existing code keeps running.

What you can create with BAP

BAP covers the browser automation use cases that break under native Puppeteer or Playwright.

Scrape bot-protected sites
Run against sites with active Cloudflare, DataDome, or fingerprinting defenses – managed stealth is built in, not something you configure per target.
Build reliable AI agent workflows
Give your AI agents a browser that handles anti-bot systems, CAPTCHAs, and session state automatically, so agent workflows don't fail on protected pages.
Automate multi-step form flows
Fill forms, click through paginated results, and maintain session state across complex interactions, with human-like timing built in.
Monitor competitor pages at scale
Schedule automated runs against product, pricing, docs, or marketing pages with stealth active, so monitoring pipelines don't get blocked over time.
Generate screenshots and PDFs with context
Capture authenticated pages, cookie-gated content, and JavaScript-heavy dashboards that REST API screenshot endpoints can't reach without a session.
Build multi-step extraction pipelines
Chain 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-ts

Python SDK

Playwright-shaped

  • Matching sync and async surfaces – bap for asyncio, bap.sync_api for 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-py

Get running in a handful of lines

Both SDKs connect the same way. Install the package, grab a token, and it runs as-is.

1

Install the package

Pick your language and install from the package registry.

npm install @browserless.io/bap-ts
2

Connect 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();
3

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. 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. 2

    Replace the connection

    Swap your existing puppeteer.connect() or chromium.connectOverCDP() call for Browserless.connect() with your token and chosen endpoint.

  3. 3

    Run your existing page code

    Most page.goto(), page.click(), and page.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. 4

    Add stealth where you need it

    Switch the endpoint to /stealth/bql for full fingerprint hardening, or call page.solve() and page.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.
Read the BAP docs

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.
Explore Browsers as a Service

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.
Explore the REST APIs

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.

  1. BAP
    TypeScript / Python SDK
  2. BrowserQL
    GraphQL protocol over WebSocket
  3. Browserless stealth engine
    Managed 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.