Browser API

Connect Playwright or Puppeteer to Anakin's stealth browser

What is Browser API?

Browser API gives you a stealth browser in the cloud that you control with your own code. Connect Playwright, Puppeteer, or any CDP-compatible client to Anakin's anti-detection browser via a single WebSocket URL.

Unlike traditional scraping APIs where you submit a URL and get results back, Browser API gives you full browser control: navigate pages, click buttons, fill forms, take screenshots, extract data — all through your own automation scripts.


Why use Browser API?

  • Anti-detection built in — Stealth browser with aligned fingerprint, locale, and timezone signals. A UK session reports Europe/London + en-GB, not UTC + en-US.
  • Playwright and Puppeteer support — Connect with connect_over_cdp (Playwright) or browser.connect() (Puppeteer). No code changes beyond the connection URL.
  • Residential exits in 20+ countries — Pass ?country=GB for a UK residential IP, ?country=JP for Japan, etc. See Geo-Targeting.
  • Saved sessions — Reuse a logged-in session across runs. Cookies + localStorage stored on disconnect, replayed on the next connect. See Saved Sessions.
  • Opt-in recording — Add ?record=true to capture a WebM video of any session. No extra cost. See Recording.
  • Nothing to install or manage — No browsers, no displays, no containers on your side. Just connect and scrape.
  • Same API key — Uses your existing Anakin API key. No separate auth flow.

Quick Start

import asyncio
from playwright.async_api import async_playwright

API_KEY = "your_api_key"

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp(
            "wss://api.anakin.io/v1/browser-connect",
            headers={"X-API-Key": API_KEY},
        )
        page = browser.contexts[0].pages[0]

        # Navigate and extract data
        await page.goto("https://books.toscrape.com", wait_until="domcontentloaded")
        print("Title:", await page.title())

        # Extract structured data
        books = await page.evaluate("""
            Array.from(document.querySelectorAll('article.product_pod')).slice(0, 5).map(el => ({
                title: el.querySelector('h3 a')?.title,
                price: el.querySelector('.price_color')?.textContent,
            }))
        """)
        print("Books:", books)

        # Take a screenshot
        await page.screenshot(path="screenshot.png")

        await browser.close()

asyncio.run(main())

Supported Features

Playwright

FeatureStatus
page.goto()
page.title() / page.content()
page.evaluate()
page.screenshot()
page.locator() — count, text, attributes
page.wait_for_selector() / page.wait_for_function()
page.inner_text() / page.text_content()
page.set_extra_http_headers()
page.on('request') / page.on('response')
page.on('console') (all severities)
page.on('websocket') with framesent/framereceived
page.on('pageerror') (uncaught exceptions)
Mouse and keyboard input
Scroll / pagination
Cross-site navigation
Multiple pages per context (context.newPage())
Stealth (webdriver=false) + geo-aligned fingerprint
page.route() / context.route() — fulfill / abort / continue
page.unroute()

Puppeteer

FeatureStatus
page.goto()
page.title() / page.content()
page.evaluate()
page.screenshot()
page.$$() — querySelectorAll
page.$eval() — scoped evaluate
page.waitForSelector()
page.setExtraHTTPHeaders()
Mouse and keyboard input
Scroll / pagination
Cross-site navigation
browser.pages() / browser.newPage()
page.waitForNavigation()

Not supported

  • Selenium / ChromeDriver — only CDP-native clients (Playwright, Puppeteer, chromedp) are supported. Use Playwright or Puppeteer instead.

Scraping Example: Extract Product Data

import asyncio
from playwright.async_api import async_playwright

async def scrape_books():
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp(
            "wss://api.anakin.io/v1/browser-connect",
            headers={"X-API-Key": "your_api_key"},
        )
        page = browser.contexts[0].pages[0]
        await page.goto("https://books.toscrape.com", wait_until="domcontentloaded")

        # Wait for products to load
        await page.wait_for_selector("article.product_pod")

        # Extract all books on the page
        books = await page.evaluate("""
            Array.from(document.querySelectorAll('article.product_pod')).map(el => ({
                title: el.querySelector('h3 a')?.title,
                price: el.querySelector('.price_color')?.textContent,
                rating: el.querySelector('.star-rating')?.className.replace('star-rating ', ''),
                inStock: !!el.querySelector('.instock'),
                link: el.querySelector('h3 a')?.href,
            }))
        """)

        print(f"Scraped {len(books)} books")
        for book in books[:3]:
            print(f"  {book['title']}{book['price']}")

        await browser.close()

asyncio.run(scrape_books())

Next steps