Integration

Use browser.city with Playwright (Sessions API)

Connect Playwright to a hosted browser.city session. Keep your Playwright scripts and get stealth, egress control, and predictable browser infrastructure.

If you already use Playwright, browser.city is a drop-in infrastructure layer:

  1. Create a session with POST /v1/sessions
  2. Connect with chromium.connect(endpoint, { headers: { Authorization: Bearer token } })
  3. Run your existing Playwright script

1) Set your API key

Set BROWSERCITY_API_KEY in your environment.

2) Create a session and connect

playwright.ts
import { chromium } from 'playwright';const { endpoint, token, id } = await fetch('https://api.browser.city/v1/sessions', {  method: 'POST',  headers: { Authorization: `Bearer ${process.env.BROWSERCITY_API_KEY}`, 'Content-Type': 'application/json' },  body: JSON.stringify({ browser: 'chromium' }),}).then((r) => r.json());try {  const browser = await chromium.connect(endpoint, {    headers: { Authorization: `Bearer ${token}` },  });  const page = browser.contexts().at(0)!.pages().at(0)!;  await page.goto('https://example.com');} finally {  await fetch(`https://api.browser.city/v1/sessions/${id}`, {    method: 'DELETE',    headers: { Authorization: `Bearer ${process.env.BROWSERCITY_API_KEY}` },  });}

3) Practical patterns

Use Request API for pure extraction

If you don’t need interaction, the Request API is simpler than keeping a browser alive:

request.ts
const res = await fetch("https://api.browser.city/v1/requests", {  method: "POST",  headers: { Authorization: `Bearer ${process.env.BROWSERCITY_API_KEY}`, "Content-Type": "application/json" },  body: JSON.stringify({ url: "https://example.com", markdown: true }),}).then((r) => r.json());console.log(res.content);

BYOP proxy

If you already have proxy infrastructure, bring your own:

Use egress: { mode: "byop", connectionString: "http://user:pass@host:port" } in your POST /v1/sessions body.

Pre-seed auth via storage state

If you already have cookies/localStorage from another run, inject them at session creation time via storage so you don’t re-login every time.

5) Migration note (local -> browser.city)

Most migrations are mechanical:

  • replace chromium.launch() with chromium.connect(...)
  • move your “browser boot” concerns into POST /v1/sessions (egress, fingerprint, storage)
  • keep the rest of your Playwright code unchanged
[ 06 / 06 ] — Get Started

Give your AI agents the web.

Start for free. No credit card required. Private sessions by default.