> ## 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.

# File Download

Anchor Browser supports two methods for downloading files during your browser sessions:

1. **Traditional Downloads**: Files are downloaded to the browser instance and then stored by Anchor for retrieval

> [!NOTE]
>
> To download PDF files directly instead of viewing them in the browser, set `pdf_viewer` to `false` when creating your session.

2. **P2P Downloads**: Files are captured directly in the browser using peer-to-peer technology, available instantly without waiting for Anchor storage

## Traditional File Downloads

The following examples demonstrate how to download a file using the traditional method and retrieve it from the browser session.

**1. Create a browser session**

Use the [create session](api-reference/browser-sessions/start-browser-session) API to create a new browser session.
To enable automatic PDF downloads, include the following `browser` configuration:

```tsx node.js theme={null}
browser: {
    pdf_viewer: {
        active: false
        }
    }
```

```python python theme={null}
"browser": {
    "pdf_viewer": {
        "active": False
        }
    }
```

**2. Browse and download a file**

Use the following example to perform a file download

```tsx node.js theme={null}
await page.goto("https://browser-tests-alpha.vercel.app/api/download-test");

await Promise.all([page.waitForEvent("download"), page.locator("#download").click()]); // The download has completed
```

```python python theme={null}
await page.goto("https://browser-tests-alpha.vercel.app/api/download-test")

async with page.expect_download() as download_info:
    await page.locator("#download").click()

download = await download_info.value
```

**3. Fetch the file from the browser session**

You can retrieve the downloaded file from the browser session using the [get session downloads](https://docs.anchorbrowser.io/api-reference/browser-sessions/list-session-downloads.md) API

## Keep downloads across sessions

Downloads are normally stored per session. To keep them in a folder your team owns, mount a [volume](https://docs.anchorbrowser.io/advanced/volumes.md) into the session: every download then lands in the volume's `downloads/` folder, and any later session that mounts the same volume sees it.

## P2P Downloads

For real-time download notifications and direct file streaming without waiting for Anchor storage, see the [P2P Download Guide](https://docs.anchorbrowser.io/advanced/p2p-downloads.md). Files are available immediately when the download completes — no polling required.


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