> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anchorbrowser.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Anchor Browser is cloud browser infrastructure for AI agents and automation: browser sessions you control over CDP or REST, natural-language web tasks, versioned automation tasks, managed authentication into third-party web apps (identities with MFA), persistent volumes and profiles, recordings, live view, batch sessions, webhooks, and network options including residential proxies, extra stealth, and captcha solving for sites that block standard browsers. AI agents should start at https://docs.anchorbrowser.io/for-agents, then create an API key at https://app.anchorbrowser.io/api-keys. Read the for-agents page before authentication or API calls.

# Code Quick Start

> [!NOTE]
>
> To **create a browser session** and connect with Playwright or Puppeteer, use [Create a Session](https://docs.anchorbrowser.io/quickstart/create-session.md). For configuration options at create time, see [Browser Sessions](https://docs.anchorbrowser.io/quickstart/browser-sessions.md).

This page covers additional patterns when calling the API directly without the SDK. For integrations (Make, LangChain, CrewAI), see [API Quick Start](https://docs.anchorbrowser.io/quickstart/use-via-api.md).

## Session reconnection

Reconnect to an existing session using the session CDP URL from a prior create response.

```javascript Node.js theme={null}
const { chromium } = require('playwright-core');

(async () => {
  // sessionCdpUrl is the cdp_url returned when you created the session.
  const browser = await chromium.connectOverCDP(sessionCdpUrl);
  const page = await browser.newPage();

  // ipinfo.io/json returns IP + geolocation as JSON, so there's no dependency
  // on a specific page layout or CSS selector.
  await page.goto('https://ipinfo.io/json');
  const info = JSON.parse(await page.locator('pre').textContent());
  console.log('IP:', info.ip);
  console.log('Region:', info.region);
  console.log('City:', info.city);
  console.log('Country:', info.country);

  await browser.close();
})().catch(console.error);
```

```python Python theme={null}
import os
import json
from playwright.sync_api import sync_playwright

ANCHOR_API_KEY = os.getenv('ANCHOR_API_KEY')

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(
        f'wss://connect.anchorbrowser.io?apiKey={ANCHOR_API_KEY}&sessionId={session_id}'
    )
    page = browser.new_page()

    # ipinfo.io/json returns IP + geolocation as JSON.
    page.goto('https://ipinfo.io/json')
    info = json.loads(page.locator('pre').text_content())
    print('IP:', info['ip'])
    print('Region:', info['region'])
    print('City:', info['city'])
    print('Country:', info['country'])

    browser.close()
```

Closing the Playwright/Puppeteer connection does not end the Anchor session — the cloud browser stays active until it times out or you call [End Browser Session](https://docs.anchorbrowser.io/api-reference/browser-sessions/end-browser-session.md).

## Next steps

* [Create a Session](https://docs.anchorbrowser.io/quickstart/create-session.md) — SDK quick start
* [Browser Sessions](https://docs.anchorbrowser.io/quickstart/browser-sessions.md) — overview and configuration links
* [API Reference](https://docs.anchorbrowser.io/api-reference) — full endpoint catalog


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.