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, notUTC+en-US. - Playwright and Puppeteer support — Connect with
connect_over_cdp(Playwright) orbrowser.connect()(Puppeteer). No code changes beyond the connection URL. - Residential exits in 20+ countries — Pass
?country=GBfor a UK residential IP,?country=JPfor 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=trueto 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())const { chromium } = require('playwright');
const API_KEY = 'your_api_key';
(async () => {
const browser = await chromium.connectOverCDP(
'wss://api.anakin.io/v1/browser-connect',
{ headers: { 'X-API-Key': API_KEY } }
);
const page = browser.contexts()[0].pages()[0];
await page.goto('https://books.toscrape.com', { waitUntil: 'domcontentloaded' });
console.log('Title:', await page.title());
const 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,
}))
);
console.log('Books:', books);
await page.screenshot({ path: 'screenshot.png' });
await browser.close();
})();const puppeteer = require('puppeteer-core');
const API_KEY = 'your_api_key';
(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint: 'wss://api.anakin.io/v1/browser-connect',
headers: { 'X-API-Key': API_KEY },
});
const page = (await browser.pages())[0] || await browser.newPage();
await page.goto('https://books.toscrape.com', {
waitUntil: 'domcontentloaded',
timeout: 30000,
});
console.log('Title:', await page.title());
console.log('HTML:', (await page.content()).length, 'chars');
await page.screenshot({ path: 'screenshot.png' });
await browser.disconnect();
})();Supported Features
Playwright
| Feature | Status |
|---|---|
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
| Feature | Status |
|---|---|
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
- Geo-Targeting — Route through residential proxies in specific countries
- Saved Sessions — Connect with pre-authenticated cookies + localStorage
- Limits & Billing — Rate limits, idle timeout, billing model