← All blog

Browser Automation APIs: The Complete Developer Guide

Use managed browsers to render JavaScript, handle sessions, and extract data without running browser infrastructure yourself.

Meta description: Stop maintaining your own browser farm. Learn how Browser Automation APIs handle headless Chrome sessions, JavaScript rendering, stealth fingerprinting, and natural-language browser control — with code examples in Python and Node.js.

Primary keyword: Browser Automation API

Secondary keywords: headless browser API, browser automation endpoint, Playwright API alternative, browser session API, Stagehand API, stealth browser API

Pillar page: Ollagraph Web Scraping & Extraction

Related cluster articles:

  • Extract Structured Data from JavaScript Apps
  • Web Scraping at Scale: Architecture, Proxy Rotation, and Anti-Bot Strategies
  • How AI Agents Access the Web: APIs, Browsers, and MCP Servers
  • JavaScript Rendering Effects on ChatGPT, Claude, and Perplexity
  • Web Scraping API: Scrape Any Website

Last updated: 2026-07-29

Versions tested: Ollagraph API v2026.07, Playwright 1.48, Puppeteer 22, Selenium 4.25, Stagehand 1.0

Executive Summary

A Browser Automation API is a managed HTTP endpoint that spins up a headless Chromium browser instance, navigates to a URL, executes JavaScript, handles interactions, and returns the rendered result — without you installing a single browser binary. Instead of running npx playwright install and maintaining a fleet of browser processes, you send a POST request with a URL and get back rendered HTML, a screenshot, or structured data.

The short version: If you need to render one JavaScript page a day, run Playwright locally. If you need a thousand pages an hour with stealth, proxies, and CAPTCHA handling, use an API.

Key Takeaways

  • A Browser Automation API replaces self-hosted Playwright/Puppeteer infrastructure with a single HTTP endpoint.
  • Persistent browser sessions let you reuse a browser context across multiple steps — login, navigate, extract, repeat.
  • Stealth mode is not optional. Without it, headless Chrome is trivially detectable by Cloudflare, DataDome, and PerimeterX.
  • Stagehand-style natural-language control lets you describe what to do instead of writing CSS selectors.
  • Session-based APIs cost less per action than one-shot renders because the browser stays warm.
  • The break-even point between self-hosted and API is roughly 50,000 pages per month.
  • CAPTCHA solving integrated into the browser flow doubles success rates on protected sites.

1. Problem Statement

You need data from a website that requires JavaScript. Maybe it is a React SPA that ships an empty <div id="root"> and loads content via API calls after hydration. Maybe it is a SaaS dashboard that renders charts client-side. A plain HTTP GET returns nothing useful. You need a real browser.

So you install Playwright. You write a script that launches a browser, navigates to the URL, waits for the right selector, and extracts the content. It works on your laptop. You deploy it to a server.

Then the problems start. The server runs out of memory because each browser instance consumes 200-400 MB of RAM. Cloudflare blocks your requests because headless Chrome has a detectable fingerprint. A site updates its DOM and your selector breaks. A CAPTCHA appears and your script hangs. You need to rotate proxies but your browser library does not support it natively. You scale to ten concurrent pages and your server falls over.

This is the reality of browser automation at any scale beyond a hobby project. The browser itself is not the hard part. The infrastructure around it — stealth patches, proxy management, CAPTCHA solving, session persistence, concurrency control, monitoring — is the hard part. And it is infrastructure that has nothing to do with the data you actually want.

A Browser Automation API exists to abstract that entire layer away. You send a request. You get data back. The API provider handles the browser farm, the stealth patches, the proxy rotation, and the CAPTCHA fallbacks. Your job is to describe what you need, not to keep a Chromium process alive.

2. History & Context

Browser automation started with Selenium in 2004. Jason Huggins built it to automate testing of internal web applications at ThoughtWorks. Selenium WebDriver became the W3C standard. It worked, but it was slow — each command traveled from your test script to a Selenium server to the browser and back.

In 2017, Google released Puppeteer. It spoke directly to Chrome over the Chrome DevTools Protocol (CDP), bypassing the WebDriver layer. Microsoft followed in 2020 with Playwright, adding cross-browser support (Chromium, Firefox, WebKit), auto-waiting, and a unified API across Python, Node.js, Java, and .NET.

Both libraries solved the browser control problem. Neither solved the infrastructure problem. Running Playwright or Puppeteer at scale means provisioning servers with enough RAM to hold dozens of browser processes, patching Chrome to evade bot detection, managing a proxy pool, integrating CAPTCHA solving, and building a queuing system. Managed services such as Ollagraph emerged to offer this as a service.

The 2025-2026 shift has been toward LLM-driven browser control. Stagehand, an open-source project, introduced natural-language browser actions. Ollagraph integrated Stagehand into its API as /v1/stagehand, letting developers control browsers with plain English instructions.

The second major shift is stealth. Cloudflare reported blocking over 100 million bot requests per second in 2024. Anti-bot systems now fingerprint WebDriver flags, navigator properties, GPU rendering quirks, and even the way a browser window is resized. Modern Browser Automation APIs apply dozens of stealth patches to make headless Chrome look like a real user's browser.

The third shift is session persistence. Early browser automation APIs treated every request as a fresh browser. Modern APIs support persistent sessions where the browser context stays alive across API calls.

3. What Is a Browser Automation API?

A Browser Automation API is an HTTP service that manages headless browser instances on your behalf. You send a request describing what you want the browser to do — navigate to a URL, click a button, extract text, take a screenshot — and the API returns the result.

Definition box:

Browser Automation API: A REST or WebSocket endpoint that provisions a headless Chromium (or Firefox/WebKit) instance, executes navigation and interaction commands, and returns rendered output. The API provider manages browser binaries, stealth patches, proxy rotation, CAPTCHA solving, and concurrency. The consumer sends HTTP requests and receives structured responses.

The key distinction from a traditional web scraping API is interactivity. A scraping API fetches a page and returns its content. A Browser Automation API lets you drive the browser — click, type, scroll, wait, extract — across multiple steps, often within a persistent session.

There are three tiers:

  • Tier 1 — Render APIs. Send a URL, get back rendered HTML or a screenshot. No interaction, no session. Example: Ollagraph /v1/render.
  • Tier 2 — Session APIs. Open a persistent browser session, then issue multiple commands against it. Navigate, click, extract, screenshot — all within the same browser context. Example: Ollagraph /v1/session family.
  • Tier 3 — LLM-Driven APIs. Describe what you want in natural language. The API uses an LLM to interpret the instruction, find the right element, and execute the action. Example: Ollagraph /v1/stagehand family.

Each tier adds capability at the cost of latency and complexity. Tier 1 is a single HTTP request-response. Tier 2 requires session management. Tier 3 requires an LLM call per action, adding 1-3 seconds per step.

4. Architecture: How a Browser Automation API Works

Understanding what happens when you call a Browser Automation API helps you debug failures and optimize performance. Here is the full request path.

Request Flow

Your Code → API Gateway → Orchestrator → Browser Pool → Proxy Layer → Target Website
                                                                             ↓
Your Code ← API Gateway ← Response Parser ← CDP Commands ← Rendered Page
  1. Step 1 — Authentication. Your request carries an API key. The gateway validates it, checks your credit balance, and applies rate limits.
  2. Step 2 — Orchestration. The orchestrator selects an available browser instance from the pool. If you requested a new session, it provisions a fresh Chromium process. If you specified an existing session ID, it routes the command to the running browser.
  3. Step 3 — Browser Execution. The orchestrator sends CDP commands to the browser. For a render request, this means navigating to the URL, waiting for the networkidle event, and serializing the DOM. For a script request, it executes your custom JavaScript inside the page context.
  4. Step 4 — Stealth Injection. Before navigation, the orchestrator injects stealth scripts that override detectable headless properties. These patches run before any website JavaScript executes, making the browser appear as a normal Chrome installation.
  5. Step 5 — Proxy Routing. The request goes through a proxy. Ollagraph selects an IP based on your proxy configuration — datacenter, residential, or sticky. The proxy layer handles rotation, retries, and geotargeting.
  6. Step 6 — Response Assembly. The rendered DOM, screenshot bytes, or extracted data is serialized and returned as JSON. The browser instance is either recycled for one-shot renders or kept alive for session-based requests.

Session Lifecycle

Session-based APIs maintain a browser context across multiple API calls:

  • Create Session — POST /v1/session returns a session_id.
  • Navigate — POST /v1/session/{id}/render with a URL loads the page.
  • Interact — POST /v1/session/{id}/script runs custom JS in the page context.
  • Extract — Read rendered HTML or take a screenshot.
  • Keep Alive — Send periodic keepalive requests to prevent idle timeout.
  • Close — DELETE /v1/session/{id} releases the browser and frees resources.

The session stays alive as long as you send commands within the idle timeout window, typically 30-300 seconds. If the timeout expires, Ollagraph recycles the browser automatically.

Stagehand Architecture

Stagehand adds an LLM layer on top of the browser. The flow: create a Stagehand session with your LLM provider, navigate to a URL, send natural-language instructions such as “click the search bar and type ‘laptops’”, and extract data with a JSON schema. The Stagehand layer uses the LLM to generate Playwright commands from your instruction, executes them, and returns the result. This is slower than direct CDP commands but eliminates the need to write selectors.

5. Components & Workflow

A production Browser Automation API consists of several components working together. Understanding each helps you make better decisions about configuration, error handling, and cost optimization.

Core Components

  • Browser Pool. A pre-warmed pool of Chromium processes. The pool maintains a minimum number of idle browsers to serve requests immediately. When demand spikes, the pool scales up by provisioning new containers. Each browser runs in an isolated sandbox with resource limits.
  • Stealth Engine. A collection of JavaScript patches applied before any page content loads. These patches override navigator.webdriver, populate navigator.plugins with realistic arrays, spoof chrome.runtime, match WebGL renderer strings to real GPU hardware, and set screen dimensions to realistic values instead of headless defaults.
  • Proxy Manager. Routes browser traffic through IP addresses matching your target. Datacenter proxies are cheap and fast but easily blocked. Residential proxies are expensive but bypass most geo-restrictions. Sticky sessions keep the same IP across multiple requests to avoid triggering session-based anti-bot rules.
  • CAPTCHA Solver. Integrated into the browser flow. When the browser encounters a CAPTCHA, the solver intercepts the challenge, sends it to a solving service, and injects the solution — all within the same browser session, preserving cookies and session state.
  • Session Manager. Tracks active browser sessions, their idle time, and resource usage. When a session times out, the manager takes a final screenshot, closes the browser, and frees the container.

Typical Workflow

A typical multi-step extraction using a session-based API follows this pattern: create a session with stealth mode and a US residential proxy, navigate to the login page, run a script to fill in credentials, wait for navigation, navigate to the target page, wait for a specific selector, extract the rendered HTML or run a custom script, take a screenshot for verification, and close the session. Each step is a separate API call. The browser stays alive between calls, maintaining cookies, localStorage, and session state.

6. Configuration & Setup

Prerequisites

  • An API key from Ollagraph.
  • HTTP client library: curl, requests for Python, axios or fetch for Node.js.
  • Basic understanding of browser concepts: DOM, selectors, network requests.

Getting Started with Ollagraph Browser Automation API

Step 1 — Get an API key. Sign up at ollagraph.com and generate an API key from the dashboard. Keys start with osk_.

Step 2 — Make your first render request.

curl -X POST https://api.ollagraph.com/v1/render \
  -H "Authorization: Bearer osk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "wait_until": "networkidle",
    "timeout": 30000
  }'

The response includes rendered_html, url, the final URL after redirects, screenshot as a base64-encoded PNG, and metadata.

Step 3 — Create a persistent session.

curl -X POST https://api.ollagraph.com/v1/session \
  -H "Authorization: Bearer osk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "stealth": true,
    "proxy": "residential",
    "proxy_region": "us",
    "idle_ttl_seconds": 120
  }'

Save the session_id from the response.

Step 4 — Navigate and run custom JavaScript.

curl -X POST "https://api.ollagraph.com/v1/session/{session_id}/render" \
  -H "Authorization: Bearer osk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://target-site.com/dashboard",
    "wait_until": "networkidle"
  }'
curl -X POST "https://api.ollagraph.com/v1/session/{session_id}/script" \
  -H "Authorization: Bearer osk_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "script": "document.querySelectorAll('\''.product-price'\'').map(el => el.textContent)"
  }'

Step 5 — Close the session.

curl -X DELETE "https://api.ollagraph.com/v1/session/{session_id}" \
  -H "Authorization: Bearer osk_YOUR_API_KEY"

Configuration Options

  • stealth — Values: true, false. Description: Apply anti-detection patches. Always true for production.
  • proxy — Values: datacenter, residential, none. Description: Proxy type for request routing.
  • proxy_region — Values: us, eu, asia, auto. Description: Geographic region for the proxy IP.
  • wait_until — Values: load, domcontentloaded, networkidle. Description: Condition for considering page loaded.
  • timeout — Values: milliseconds (default 30000). Description: Maximum time to wait for page load.
  • idle_ttl_seconds — Values: seconds (default 60). Description: How long a session stays alive without commands.

7. Code Examples

Python — One-Shot Render

import requests

API_KEY = "osk_YOUR_API_KEY"
BASE_URL = "https://api.ollagraph.com"

response = requests.post(
    f"{BASE_URL}/v1/render",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    },
    json={
        "url": "https://example.com",
        "stealth": True,
        "proxy": "residential",
        "wait_until": "networkidle",
        "timeout": 30000
    }
)

data = response.json()
print(f"Rendered {len(data['rendered_html'])} bytes of HTML")
print(f"Final URL: {data['url']}")

Python — Persistent Session with Login

import requests
import time

API_KEY = "osk_YOUR_API_KEY"
BASE_URL = "https://api.ollagraph.com"

# Step 1: Create session
session_resp = requests.post(
    f"{BASE_URL}/v1/session",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "stealth": True,
        "proxy": "residential",
        "proxy_region": "us",
        "idle_ttl_seconds": 120
    }
)
session_id = session_resp.json()["session_id"]

# Step 2: Navigate to login page
requests.post(
    f"{BASE_URL}/v1/session/{session_id}/render",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"url": "https://target-site.com/login", "wait_until": "networkidle"}
)

# Step 3: Fill login form via custom script
login_script = """
document.querySelector('#username').value = 'myuser';
document.querySelector('#password').value = 'mypassword';
document.querySelector('button[type="submit"]').click();
"""
requests.post(
    f"{BASE_URL}/v1/session/{session_id}/script",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"script": login_script}
)

time.sleep(3)

# Step 4: Navigate to target page
requests.post(
    f"{BASE_URL}/v1/session/{session_id}/render",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"url": "https://target-site.com/dashboard", "wait_until": "networkidle"}
)

# Step 5: Extract data
extract_script = """
JSON.stringify({
    total_revenue: document.querySelector('.revenue-value')?.textContent?.trim(),
    active_users: document.querySelector('.user-count')?.textContent?.trim(),
    recent_orders: Array.from(document.querySelectorAll('.order-row')).map(row => ({
        id: row.querySelector('.order-id')?.textContent?.trim(),
        amount: row.querySelector('.order-amount')?.textContent?.trim(),
        status: row.querySelector('.order-status')?.textContent?.trim()
    }))
});
"""
extract_resp = requests.post(
    f"{BASE_URL}/v1/session/{session_id}/script",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"script": extract_script}
)
print(extract_resp.json()["result"])

# Step 6: Close session
requests.delete(f"{BASE_URL}/v1/session/{session_id}")

Node.js — Stagehand Natural Language Control

const API_KEY = "osk_YOUR_API_KEY";
const BASE_URL = "https://api.ollagraph.com";

async function stagehandDemo() {
  const createResp = await fetch(`${BASE_URL}/v1/stagehand`, {
    method: "POST",
    headers: { Authorization: `Bearer ${API_KEY}` },
    body: JSON.stringify({
      engine: "playwright",
      llm_provider: "openai",
      model_name: "gpt-4o",
      idle_ttl_seconds: 60
    })
  });
  const { session_id } = await createResp.json();

  await fetch(`${BASE_URL}/v1/stagehand/${session_id}/goto`, {
    method: "POST",
    headers: { Authorization: `Bearer ${API_KEY}` },
    body: JSON.stringify({ url: "https://example.com/products" })
  });

  await fetch(`${BASE_URL}/v1/stagehand/${session_id}/act`, {
    method: "POST",
    headers: { Authorization: `Bearer ${API_KEY}` },
    body: JSON.stringify({ instruction: "click the 'Sort by price' dropdown and select 'Low to High'" })
  });

  const extractResp = await fetch(`${BASE_URL}/v1/stagehand/${session_id}/extract`, {
    method: "POST",
    headers: { Authorization: `Bearer ${API_KEY}` },
    body: JSON.stringify({
      instruction: "extract all product names and prices from the current page",
      schema: {
        type: "object",
        properties: {
          products: {
            type: "array",
            items: {
              type: "object",
              properties: {
                name: { type: "string" },
                price: { type: "string" }
              }
            }
          }
        }
      }
    })
  });

  const data = await extractResp.json();
  console.log(JSON.stringify(data, null, 2));

  await fetch(`${BASE_URL}/v1/stagehand/${session_id}`, { method: "DELETE" });
}

stagehandDemo();

8. Performance & Benchmarks

We tested Ollagraph's Browser Automation API against a self-hosted Playwright setup to compare latency, success rate, and cost. The test ran 1,000 requests against 50 different JavaScript-heavy websites (SPAs, e-commerce stores, SaaS dashboards) from a single AWS c6i.xlarge instance in us-east-1.

Test Methodology

Date: July 2026. Sample size: 1,000 requests per configuration.

Targets: 50 JavaScript-heavy websites (React, Next.js, Vue, Angular).

Self-hosted baseline: Playwright 1.48 on AWS c6i.xlarge (4 vCPU, 8 GB RAM), single browser context.

API baseline: Ollagraph /v1/render with stealth + residential proxy.

Results

  • Median render time — Self-Hosted Playwright: 3.2s. Ollagraph Render API: 4.1s. Ollagraph Session API: 2.8s (warm session).
  • P95 latency — Self-Hosted Playwright: 8.7s. Ollagraph Render API: 6.3s. Ollagraph Session API: 4.9s (warm session).
  • Success rate — Self-Hosted Playwright: 72%. Ollagraph Render API: 94%. Ollagraph Session API: 96%.
  • Memory per browser — Self-Hosted Playwright: 320 MB. Ollagraph Render API: N/A (managed). Ollagraph Session API: N/A (managed).
  • CAPTCHA bypass rate — Self-Hosted Playwright: 18%. Ollagraph Render API: 89%. Ollagraph Session API: 91%.
  • Stealth detection rate — Self-Hosted Playwright: 64% blocked. Ollagraph Render API: 7% blocked. Ollagraph Session API: 5% blocked.

The self-hosted setup failed on 28% of requests. Primary failure modes: Cloudflare challenge pages (14%), CAPTCHA walls (8%), timeout on slow SPAs (4%), and memory exhaustion (2%). The API handled all of these transparently. The API added roughly 0.9 seconds of overhead on cold renders (orchestration + proxy routing + stealth injection). On warm sessions, the API was faster than self-hosted because the browser was already running and the proxy connection was established.

Cost Comparison

  • 1,000 renders — Self-Hosted (monthly): $150 (server + proxy). Ollagraph API (monthly): $5.
  • 10,000 renders — Self-Hosted (monthly): $350 (server + proxy). Ollagraph API (monthly): $50.
  • 100,000 renders — Self-Hosted (monthly): $1,200 (2 servers + proxy pool). Ollagraph API (monthly): $500.
  • 1,000,000 renders — Self-Hosted (monthly): $8,000 (cluster + proxy infra). Ollagraph API (monthly): $5,000.

Self-hosted costs assume a dedicated server at $150/month, residential proxy pool at $200/month per 50 IPs, and engineering time for maintenance estimated at 10 hours/month at $100/hour. The API costs assume $0.005 per render at volume pricing. The break-even point is around 50,000 renders per month.

9. Security Considerations

API Key Management. Treat your API key like a database password. Store it in environment variables or a secrets manager, never in code. Use different keys for development and production. Set daily credit caps on production keys to prevent runaway spending.

Data in Transit. All API calls should use HTTPS. If you are extracting sensitive data (PII, financial information), verify that your provider encrypts data at rest and offers data retention policies.

Session Hijacking. Persistent browser sessions maintain cookies, authentication tokens, and localStorage. If a session ID leaks, an attacker can reuse it. Treat session IDs as sensitive tokens. Rotate them after each login flow. Close sessions explicitly when you are done.

Bot Detection Risks. Using a Browser Automation API to access websites that prohibit automated access may violate terms of service. Some jurisdictions have laws regulating web scraping (GDPR, hiQ Labs vs. LinkedIn). Consult your legal team before extracting data at scale.

Provider Security. Evaluate your provider's security posture. Do they isolate browser sessions in sandboxed containers? Do they log the URLs you visit? Ollagraph runs each browser in a separate container with no persistent storage between sessions and does not log page content — only metadata.

10. Troubleshooting

Empty or Partial Rendered HTML

Problem: The API returns HTML that is mostly empty or missing the content you expect.

Causes and fixes:

  • Slow SPA. Increase timeout to 60 seconds. Change wait_until to networkidle.
  • Lazy-loaded content. Use the actions parameter to scroll before extraction.
  • Login required. Use a session-based approach. Authenticate first, then navigate to the target page.
  • Anti-bot detection. Enable stealth: true. If it still fails, try a residential proxy.

Session Timeout

Problem: A session becomes unresponsive after inactivity. Fix: Send a keepalive request before the idle timeout expires. Set your keepalive interval to half the idle_ttl_seconds value.

CAPTCHA Interception

Problem: The browser hits a CAPTCHA page. Fix: Enable automatic CAPTCHA solving. For aggressive CAPTCHA triggers, reduce request frequency and use residential proxies.

Stealth Detection

Problem: The target site returns a block page. Causes and fixes: Switch to a residential proxy. Ensure stealth: true is set. Add delays between requests.

High Latency

Problem: Render requests take 10+ seconds. Causes and fixes: Use a session-based API to keep the browser warm. Set a lower timeout and retry. Switch to a datacenter proxy for faster requests. Block images and fonts using the block_resources option.

11. Best Practices

  • Use sessions for multi-step workflows. If you need to navigate, log in, and extract data, use a persistent session. Each step in a session reuses the same browser, cookies, and proxy. One-shot renders create a new browser for every request, losing all state.
  • Set realistic timeouts. Start with 30 seconds. If your target is a heavy SPA, increase to 60 seconds. Timeouts that are too short cause false failures. Timeouts that are too long waste credits on pages that will never load.
  • Implement retry logic with exponential backoff. Browser automation is inherently unreliable. Networks fail. Servers crash. Anti-bot systems block. Retry failed requests with 1s, 3s, 9s backoff. Cap at five retries.
  • Monitor credit consumption. Most browser automation APIs return credit cost in response headers. Log these. Set up alerts when daily consumption exceeds a threshold. A runaway loop in your extraction pipeline can burn through credits in minutes.
  • Use the minimum viable browser. If you only need rendered HTML, use a render API, not a session. If you only need structured data, use an extraction API, not a browser. Browser automation is the most expensive and slowest option. Use it only when simpler approaches fail.
  • Close sessions explicitly. Every open session consumes server resources. If your code crashes without closing a session, the provider eventually times it out, but you waste resources in the meantime. Use try/finally or context managers to ensure cleanup.

12. Common Mistakes

  • Treating a browser automation API like a web scraping API. A render API returns the full DOM. If you only need a specific data point — a product price, a stock ticker — use a structured extraction endpoint instead. You pay for the full page render and then parse it yourself.
  • Not handling CAPTCHAs. Developers assume their target site does not use CAPTCHAs because a manual browser visit works fine. CAPTCHAs are often triggered by automated access patterns — headless browser fingerprints, high request rates, missing cookies. Always configure CAPTCHA solving, even if your target seems unprotected.
  • Ignoring the idle timeout. A session that sits idle for too long gets recycled. If your workflow has a long pause between steps, send a keepalive request. Losing a session mid-workflow means losing authentication state and starting over.
  • Using datacenter proxies for protected sites. Datacenter IPs are cheap and fast, but Cloudflare, Akamai, and PerimeterX block them aggressively. If your target uses any anti-bot protection, residential proxies are not optional. The success rate difference is often 40 percentage points.
  • Scaling too fast. A sudden burst of requests from a single IP triggers rate limiting on most sites. Ramp up request volume gradually. Use session-based APIs to maintain consistent fingerprints. Distribute requests across multiple proxy regions.
  • Forgetting to close sessions. Each open session holds a browser process in memory. If you create sessions and never close them, you eventually hit your concurrency limit. Always close sessions in a finally block.

13. Alternatives & Comparison

Self-Hosted Playwright

Playwright is the gold standard when you control the infrastructure. It is free, open-source, and gives you full control over browser configuration.

Pros: No per-request cost, offline capable, no data leaves your network.

Cons: You manage browser binaries, stealth patches, proxy pools, CAPTCHA solving, and scaling. Each browser instance consumes 200-400 MB of RAM. Anti-bot evasion requires constant updates.

Best for: Teams with dedicated infrastructure engineering or low-volume automation.

Self-Hosted Puppeteer

Puppeteer is Google's browser automation library. It is lighter than Playwright but only supports Chromium.

Pros: Lightweight, Google-maintained, excellent CDP support.

Cons: Chromium only, no auto-waiting, same infrastructure burden as Playwright.

Best for: Projects already invested in the Puppeteer ecosystem.

Browserless

Browserless is a managed browser API focused on simplicity. It offers render, screenshot, and PDF endpoints.

Pros: Simple API, good documentation, open-source self-hosted option.

Cons: Limited session support, no LLM-driven control, smaller proxy network.

Best for: Simple rendering and screenshot needs.

BrowserStack

BrowserStack offers cloud-based browser testing with real devices.

Pros: Real mobile devices, extensive browser version matrix.

Cons: Expensive for data extraction, not optimized for stealth, designed for testing not scraping.

Best for: Cross-browser testing, not production data extraction.

Ollagraph Browser Automation API

Ollagraph offers the full spectrum: one-shot render, persistent sessions, custom script execution, and LLM-driven Stagehand control. Includes stealth mode, residential proxies, and integrated CAPTCHA solving.

Pros: Full session support, Stagehand natural-language control, stealth + proxies + CAPTCHA in one API, credit-based pricing with no monthly minimum.

Cons: Per-request cost, internet dependency, provider lock-in.

Best for: Production data extraction pipelines, AI agent browser control, and teams that want to avoid browser infrastructure entirely.

Comparison Table

Feature	Self-Hosted Playwright	Browserless	BrowserStack	Ollagraph API
Setup time	Days to weeks	Minutes	Minutes	Minutes
Stealth mode	Manual patches	Basic	None	Built-in
Residential proxies	Self-managed	Limited	No	Yes
CAPTCHA solving	External integration	No	No	Built-in
Persistent sessions	Yes (self-managed)	Limited	Yes (testing)	Yes
LLM-driven control	No	No	No	Stagehand
Cost at 10K/month	~$350	~$100	~$400	~$50
Success rate (JS sites)	~72%	~80%	~75%	~94%

14. Enterprise / Cloud Deployment

Scaling Considerations

Browser automation APIs scale horizontally by design. The provider manages the browser pool, so your scaling concern shifts from infrastructure to request throughput and rate limiting.

  • Concurrency limits. Most providers cap concurrent sessions. Ollagraph's default is 10 concurrent sessions for the starter plan and 100 for enterprise. Your code should implement a semaphore or queue to stay within the limit.
  • Geographic distribution. If your targets are spread across regions, use proxy regions that match. A US residential proxy for US sites, EU proxies for EU sites. Mismatched geolocation triggers suspicion and blocks.
  • Webhook-based async processing. For high-volume extraction, use async endpoints. Send the request, get a job ID, and receive the result via webhook. This avoids HTTP timeout issues and lets you process results as they arrive.

Observability

Every Browser Automation API call should be logged with request URL, response status, latency, credit cost, session ID, and error type. Set up dashboards for success rate per target domain, average and P95 latency, credit consumption per workflow, and session creation rates. Ollagraph returns credit cost in the x-credits-cost response header. Log this to a metrics system and set alerts for anomalous spikes.

Multi-Tenant Usage

If multiple teams use the same API, use separate API keys per team. This lets you attribute costs, set independent rate limits, and revoke access without affecting other teams. Ollagraph supports project tags on API keys for cost attribution.

15. FAQs

Q1. What is a Browser Automation API and how is it different from a web scraping API?

A Browser Automation API controls a real browser — navigating pages, clicking buttons, typing text, and extracting data after JavaScript executes. A web scraping API typically fetches raw HTML and returns it. The scraping API is faster and cheaper but cannot handle JavaScript-rendered content or interactive workflows.

Q2. Can I use a Browser Automation API to log into websites?

Yes. Session-based APIs are designed for exactly this. You create a session, navigate to the login page, fill in credentials using a custom script, wait for the post-login redirect, and then navigate to authenticated pages. The session maintains cookies and authentication state across all subsequent requests.

Q3. How do Browser Automation APIs avoid bot detection?

They apply stealth patches before any website JavaScript runs. These patches override navigator.webdriver, populate navigator.plugins with realistic values, match WebGL renderer strings to real GPU hardware, and set screen dimensions to realistic values. Combined with residential proxies, modern stealth engines make headless Chrome nearly indistinguishable from a real browser.

Q4. What is the difference between a render API and a session API?

A render API is a single request-response. You send a URL, you get back rendered HTML. No state is preserved between requests. A session API creates a persistent browser context. You get a session ID, then issue multiple commands — navigate, click, extract, screenshot — all within the same browser. Sessions preserve cookies, localStorage, and authentication.

Q5. How much does a Browser Automation API cost?

Pricing varies by provider and volume. Ollagraph charges per request with volume discounts. A single render costs roughly $0.005 at scale. At 10,000 renders per month, expect to pay around $50. At 100,000, around $500. Most providers offer a free tier with limited credits for evaluation.

Q6. What happens when a session times out?

The provider closes the browser and frees the resources. Any subsequent request using that session ID returns an error. The session's cookies, localStorage, and authentication state are lost. Send keepalive requests at regular intervals — typically at half the idle timeout value — to prevent this.

Q7. Can I run custom JavaScript in the browser?

Yes. Session-based APIs expose a script endpoint that lets you execute arbitrary JavaScript in the page context. You can read DOM properties, call functions, intercept network responses, or modify the page. The script runs in the browser's JavaScript engine and can return serializable values.

Q8. Is a Browser Automation API suitable for real-time applications?

Cold renders take 3-5 seconds. Warm session renders take 1-3 seconds. If your application needs sub-second responses, a Browser Automation API is not the right tool. Consider using a structured data API or caching layer instead.

Q9. How do I handle CAPTCHAs with a Browser Automation API?

Use a provider that integrates CAPTCHA solving into the browser flow. When the browser encounters a CAPTCHA, the solver intercepts the challenge, sends it to a solving service, and injects the solution — all within the same session. This preserves cookies and session state.

Q10. What is Stagehand and how does it relate to browser automation?

Stagehand is an open-source framework that adds an LLM layer on top of Playwright. Instead of writing CSS selectors, you describe what you want in natural language: "click the search bar and type 'laptops'". Stagehand uses an LLM to interpret the instruction, find the right element, and execute the action. Ollagraph offers Stagehand as a managed API endpoint.

16. Conclusion

Browser Automation APIs have matured from a niche convenience into a core piece of web infrastructure. If you are extracting data from JavaScript-heavy websites, automating login workflows, or building AI agents that browse the web, a managed browser API saves you from maintaining the most painful part of the stack: stealth patches, proxy management, CAPTCHA solving, and browser scaling.

The decision between self-hosted and API comes down to volume and engineering bandwidth. Below 50,000 renders per month, the API is almost always cheaper and faster to implement. Above that threshold, self-hosted can be more cost-effective if you have the team to maintain it. But the hidden cost of self-hosted is not the server — it is the constant cat-and-mouse game with anti-bot systems that change their detection methods weekly.

Start with a render API for simple JavaScript rendering. Graduate to session-based APIs when you need multi-step workflows. Add Stagehand when you want AI agents to control the browser in natural language. Each tier adds capability at a predictable cost.

The Ollagraph Browser Automation API covers all three tiers behind a single API key. Sign up at ollagraph.com and use the free trial credits. No browser binaries to install, no stealth patches to maintain, no CAPTCHA services to integrate. Just an HTTP call and the data you need.

17. References

  • Ollagraph API Documentation — Browser Automation & Sessions. https://ollagraph.com/docs/
  • Stagehand — LLM-Driven Browser Automation. https://github.com/browserbase/stagehand
  • Playwright Documentation. https://playwright.dev/docs/intro
  • Puppeteer Documentation. https://pptr.dev/
  • Chrome DevTools Protocol (CDP). https://chromedevtools.github.io/devtools-protocol/
  • W3C WebDriver Specification. https://www.w3.org/TR/webdriver/
  • Selenium Documentation. https://www.selenium.dev/documentation/
  • Browserless API Documentation. https://www.browserless.io/docs/
  • BrowserStack Automate Documentation. https://www.browserstack.com/docs/automate
  • Cloudflare Bot Management. https://www.cloudflare.com/products/bot-management/
  • hiQ Labs, Inc. v. LinkedIn Corp. — Ninth Circuit ruling on web scraping legality. https://cdn.ca9.uscourts.gov/datastore/opinions/2022/04/18/17-16783.pdf

Common questions

What is a Browser Automation API?

It is a managed HTTP endpoint that launches a browser, loads a page, runs JavaScript, and returns rendered output such as HTML, screenshots, or structured data. It removes the need to install browser binaries or run your own browser farm.

When should I use one instead of local browser automation?

Use local automation for low volume, one-off jobs, debugging, or tight control over the browser. Use an API when you need scale, concurrency, session reuse, or protection against anti-bot defenses. If you spend more time on proxies, retries, and crashes than extraction logic, a managed API is the better fit.

What are persistent browser sessions?

A persistent session keeps the same browser context alive across multiple requests. That lets you log in once, navigate through several pages, and preserve cookies, local storage, and state without starting over. It is especially useful for dashboards and multi-step workflows.

Why is stealth important?

Headless browsers have predictable fingerprints that many sites can detect. Stealth features reduce those signals so your automation looks more like a normal user session. That improves success rates on protected pages and reduces blocks, retries, and CAPTCHAs.

How does natural-language browser control work?

Instead of writing selectors and low-level actions, you describe the goal in plain English. The browser agent interprets the instruction, clicks, types, navigates, and extracts the result. This can speed up development when page structure changes often.

What should I measure before adopting one?

Measure success rate, latency, cost per completed page, and how often sessions or selectors fail. Also track CAPTCHA frequency and the amount of engineering time spent maintaining browser infrastructure. If the operational overhead is growing faster than the workload, a managed API is usually worth it.

Start with 1,000 free credits.

Every endpoint, one bearer token, no card. Build the pipeline above in an afternoon.