> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.scrapybara.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.scrapybara.com/_mcp/server.

# Browser

#### Python

#### Start an instance

```python
from scrapybara import Scrapybara

client = Scrapybara(api_key="your_api_key")
instance = client.start_ubuntu()
```

#### Start a browser session

```python
cdp_url = instance.browser.start().cdp_url
```

#### Authenticate the session (optional)

To save the authenticated state of a browser session, use the `saveAuth` method.

```python
auth_state_id = instance.browser.save_auth(name="default").auth_state_id
```

Now, you can reuse the saved auth state on other instances by passing the `auth_state_id` to the `authenticate` method. The browser needs to be started first.

```python
instance.browser.authenticate(auth_state_id=auth_state_id)
```

#### Connect to the browser

```python
from playwright.sync_api import sync_playwright

playwright = sync_playwright().start()
browser = playwright.chromium.connect_over_cdp(cdp_url)
```

#### Interact with the browser

```python
page = browser.new_page()
page.goto("https://scrapybara.com")
screenshot = page.screenshot()
```

#### Stop the browser session

```python
instance.browser.stop()
```

#### TypeScript

#### Start an instance

```typescript
import { ScrapybaraClient } from "scrapybara";

const client = new ScrapybaraClient({ apiKey: "your_api_key" });
const instance = await client.startUbuntu();
```

#### Start a browser session

```typescript
const cdpUrl = await instance.browser.start().cdpUrl;
```

#### Authenticate the session (optional)

To save the authenticated state of a browser session, use the `saveAuth` method.

```typescript
const authStateId = await instance.browser.saveAuth({
  name: "default",
}).authStateId;
```

Now, you can reuse the saved auth state on other instances by passing the `authStateId` to the `authenticate` method. The browser needs to be started first.

```typescript
await instance.browser.authenticate({ authStateId });
```

#### Connect to the browser

```typescript
import { chromium } from "playwright";

const browser = await chromium.connectOverCDP(cdpUrl);
```

#### Interact with the browser

```typescript
const page = await browser.newPage();
await page.goto("https://scrapybara.com");
const screenshot = await page.screenshot();
```

#### Stop the browser session

```typescript
await instance.browser.stop();
```