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

# ブラウザサンドボックス

> エージェントが Web とやり取りできる安全なブラウザサンドボックス。

> [!NOTE]
>
> エージェントワークフローには [Interact](https://docs.firecrawl.dev/ja/features/interact.md) を使用してください。Interact はサポート対象の CLI/MCP パスであり、スクレイピング後にプロンプトまたはコードで操作できます。MCP では URL から直接開くこともサポートしています。

| 対象 | 用途 | エントリーポイント | エージェント向けインターフェース |
| - | - | - | - |
| ブラウザサンドボックス | サンドボックス、CDP URL、ライブビュー、または永続的なセッションライフサイクルを必要とする API/SDK ユーザー向けのスタンドアロンのブラウザセッション | `POST /v2/interact` | API と SDKs。非表示の CLI browser コマンドはレガシーです |
| Interact | スクレイピングしたページ上での操作。MCP は `firecrawl_interact` の URL モードで URL から開くこともできます | `POST /v2/scrape/{scrapeId}/interact`、スクレイピング後の CLI `interact`、または MCP `firecrawl_interact` | CLI/MCP のエージェントワークフローに推奨 |

Firecrawl ブラウザサンドボックス は、API および SDK のユーザーに、エージェントが Web とやり取りできる安全なブラウザ環境を提供します。フォームへの入力、ボタンのクリック、認証などを実行できます。
ローカルでのセットアップは不要で、Chromium のインストールやドライバーの互換性の問題もありません。agent browser と playwright はプリインストール済みです。

[API](https://docs.firecrawl.dev/ja/api-reference/endpoint/browser-create.md)、[Node SDK](https://docs.firecrawl.dev/ja/sdks/node.md#browser)、[Python SDK](https://docs.firecrawl.dev/ja/sdks/python.md#browser)、および [Vercel AI SDK](https://docs.firecrawl.dev/ja/developer-guides/llm-sdks-and-frameworks/vercel-ai-sdk.md) 経由で利用できます。非表示の `firecrawl browser` CLI コマンドはレガシーです。CLI と MCP のエージェントフローでは、代わりに scrape + interact を使用してください。

AI コーディングエージェント (Claude Code、Codex、Open Code、Cursor など) に Interact 対応を追加するには、Firecrawl スキルをインストールします。

```bash theme={null}
npx -y firecrawl-cli@latest init --all --browser
```

各セッションは、インフラを管理することなくスケールする、分離された使い捨てまたは永続的なサンドボックス内で実行されます。

## クイックスタート

セッションを作成し、コードを実行して終了します。

```js Node theme={null}
// npm install firecrawl
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

// 1. Launch a session
const session = await firecrawl.browser();
console.log(session.cdpUrl); // wss://cdp-proxy.firecrawl.dev/cdp/...

// 2. Execute code
const result = await firecrawl.browserExecute(session.id, {
  code: `
    await page.goto("https://news.ycombinator.com");
    const title = await page.title();
    console.log(title);
  `,
  language: "node",
});
console.log(result.result); // "Hacker News"

// 3. Close
await firecrawl.deleteBrowser(session.id);
```

```python Python theme={null}
# pip install firecrawl
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

# 1. セッションを起動
session = app.browser()
print(session.cdp_url)  # wss://cdp-proxy.firecrawl.dev/cdp/...

# 2. Execute code
result = app.browser_execute(
    session.id,
    code='await page.goto("https://news.ycombinator.com")\ntitle = await page.title()\nprint(title)',
    language="python",
)
print(result.result)  # "Hacker News"

# 3. Close
app.delete_browser(session.id)
```

```bash CLI theme={null}
# Install the Firecrawl CLI
npm install -g firecrawl-cli

# 省略形 - セッションを自動起動、"execute"不要
firecrawl browser "open https://news.ycombinator.com"
firecrawl browser "snapshot"
firecrawl browser "scrape"

# Close when done
firecrawl browser close
```

```bash cURL theme={null}
# 1. セッションを起動
curl -X POST "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json"

# 2. Execute code
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "await page.goto(\"https://news.ycombinator.com\")\ntitle = await page.title()\nprint(title)"
  }'

# 3. Close
curl -X DELETE "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY"
```

* **ドライバーのインストール不要** - Chromium バイナリ不要、`playwright install` 不要、ドライバー互換性の問題なし
* **Python、JavaScript、Bash 対応** - API、CLI、または SDK 経由でコードを送信して結果を取得。3 つの言語すべてがサンドボックス環境上でリモート実行されます
* **agent-browser** - 60 以上のコマンドがプリインストール済みの CLI。AI エージェントは Playwright コードではなくシンプルな bash コマンドを書くことで操作できます
* **Playwright ロード済み** - サンドボックス環境には Playwright がプリインストール済み。必要であればエージェントは Playwright コードを記述することもできます
* **CDP へのアクセス** - 完全な制御が必要なときは、独自の Playwright インスタンスを WebSocket 経由で接続可能
* **ライブビュー** - 埋め込み可能なストリーム URL を使って、セッションをリアルタイムで監視可能
* **インタラクティブ ライブビュー** - 埋め込み可能なインタラクティブなストリームを通じて、ユーザーがブラウザを直接操作できるようにします

## セッションを開始する

セッションID、CDP URL、ライブビューのURLを返します。

```js Node theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

const session = await firecrawl.browser({
  ttl: 120,
  activityTtl: 60,
});

console.log(session.id);
console.log(session.cdpUrl);      // wss://cdp-proxy.firecrawl.dev/cdp/...
console.log(session.liveViewUrl); // https://liveview.firecrawl.dev/...
```

```python Python theme={null}
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

session = app.browser(
    ttl=120,
    activity_ttl=60,
)

print(session.id)
print(session.cdp_url)        # wss://cdp-proxy.firecrawl.dev/cdp/...
print(session.live_view_url)  # https://liveview.firecrawl.dev/...
```

```bash CLI theme={null}
# ライブビューとカスタムTTLで起動
firecrawl browser launch-session --stream --ttl 120 --ttl-inactivity 60

# 起動してセッション情報をファイルに保存
firecrawl browser launch-session -o session.json --json
```

```bash cURL theme={null}
curl -X POST "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ttl": 120,
    "activityTtl": 60
  }'
```

```json Response theme={null}
{
  "success": true,
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "cdpUrl": "wss://browser.firecrawl.dev/cdp/550e8400...?token=abc123...",
  "liveViewUrl": "https://liveview.firecrawl.dev/...",
  "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/...",
  "expiresAt": "2025-01-15T10:40:00Z"
}
```

## コードの実行

セッション内で Python、JavaScript、または bash のコードを実行します。Output は `stdout` 経由で返されます。Node.js では、最後の式の値も `result` として利用できます。

```js Node theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

const result = await firecrawl.browserExecute("YOUR_SESSION_ID", {
  code: 'await page.goto("https://example.com"); const title = await page.title(); console.log(title);',
  language: "node",
});

console.log(result);
```

```python Python theme={null}
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

result = app.browser_execute(
    "YOUR_SESSION_ID",
    code='await page.goto("https://example.com")\ntitle = await page.title()\nprint(title)',
    language="python",
)

print(result)
```

```bash CLI theme={null}
# agent-browserコマンド (デフォルト - "agent-browser"が自動的にプレフィックスとして付与されます)
firecrawl browser execute "open https://example.com"
firecrawl browser execute "snapshot"
firecrawl browser execute "scrape"

# Execute Playwright Python code
firecrawl browser execute --python 'await page.goto("https://example.com")
print(await page.title())'

# Execute Playwright JavaScript code
firecrawl browser execute --node 'await page.goto("https://example.com"); document.title'

# Execute arbitrary bash in the sandbox
firecrawl browser execute --bash 'ls /tmp'

# Target a specific session
firecrawl browser execute --session <id> "snapshot"
```

```bash cURL theme={null}
# Execute Playwright Python code
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "await page.goto(\"https://example.com\")\ntitle = await page.title()\nprint(title)",
    "language": "python"
  }'

# Playwright JavaScriptコードを実行
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "await page.goto(\"https://example.com\"); const title = await page.title(); console.log(title);",
    "language": "node"
  }'
```

```bash cURL (Bash / agent-browser) theme={null}
# Navigate to a page
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "agent-browser open https://example.com", "language": "bash" }'

# @ref IDを含むアクセシビリティスナップショットを取得
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "agent-browser snapshot", "language": "bash" }'

# Interact using @ref IDs from the snapshot
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "agent-browser click @e5", "language": "bash" }'

# Extract page content as markdown
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "agent-browser scrape", "language": "bash" }'
```

```json Response theme={null}
{
  "success": true,
  "stdout": "",
  "result": "Example Domain",
  "stderr": "",
  "exitCode": 0,
  "killed": false
}
```

### ファイルダウンロードの処理

セッション内でダウンロードされたファイルはキャプチャして、base64 として返すことができます。execute エンドポイントから Playwright の download API を使用します。

```python Python theme={null}
import base64

async with page.expect_download() as download_info:
    await page.click('a#download-link')  # ダウンロードをトリガーする要素をクリック

download = download_info.value
path = await download.path()

# 必要に応じて既知のパスに保存
# await download.save_as('/tmp/myfile.pdf')

# ファイル内容を読み取り、base64 として出力
with open(path, "rb") as f:
    content = base64.b64encode(f.read()).decode()
    print(content)
```

```javascript Node theme={null}
// リンク要素からダウンロード URL を取得
const href = await page.getAttribute('a#download-link', 'href');

// ブラウザーコンテキストでファイルを取得し、base64 に変換
const b64 = await page.evaluate(async (url) => {
  const resp = await fetch(url);
  const blob = await resp.blob();
  return new Promise((resolve) => {
    const reader = new FileReader();
    reader.onloadend = () => resolve(reader.result.split(',')[1]);
    reader.readAsDataURL(blob);
  });
}, href);

process.stdout.write(b64);
```

> [!NOTE]
>
> サンドボックスのファイルシステムは一時的なものです。ダウンロードしたファイルはセッションの終了時に失われます。ファイルを永続化するには、セッション内で内容を読み取り、独自のストレージに保存してください。永続プロファイルではブラウザーの状態 (cookie、localStorage) は保持されますが、ディスク上のファイルは保持されません。

## agent-browser (Bash モード)

[agent-browser](https://github.com/vercel-labs/agent-browser) は、すべてのサンドボックスにプリインストールされているヘッドレスブラウザ CLI です。Playwright のコードを書く代わりに、エージェントはシンプルな bash コマンドを送信します。CLI は自動的に `--cdp` フラグを付与し、agent-browser がアクティブなセッションに自動で接続できるようにします。

> [!NOTE]
>
> 以下の `firecrawl browser` CLI の例は、レガシーなブラウザサンドボックス セッション向けです。CLI/MCP のエージェント ワークフローでは、`firecrawl interact` または MCP の `firecrawl_interact` ツールを優先して使用してください。

### 省略記法

`browser` コマンドを使う最速の方法です。省略記法も `execute` も、どちらも自動的に agent-browser にコマンドを送信します。省略記法は単に `execute` を省略し、必要に応じてセッションを自動的に開始します。

```bash theme={null}
firecrawl browser "open https://example.com"
firecrawl browser "snapshot"
firecrawl browser "click @e5"
```

### CLI

明示的な形では `execute` を使用します。コマンドは自動的に agent-browser に送信されるので、`agent-browser` と入力したり、`--bash` を付けたりする必要はありません。

```bash ナビゲーション & スナップショット theme={null}
firecrawl browser execute "open https://example.com"
firecrawl browser execute "snapshot"
```

```bash 操作 theme={null}
firecrawl browser execute "click @e5"
firecrawl browser execute "fill @e3 'search query'"
firecrawl browser execute "scrape"
```

### API と SDK

API または SDK を使って agent-browser コマンドを実行するには、`language: "bash"` を指定します：

```bash cURL theme={null}
curl -X POST "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID/execute" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "agent-browser snapshot",
    "language": "bash"
  }'
```

```javascript Node theme={null}
const result = await app.browserExecute(sessionId, {
  code: "agent-browser snapshot",
  language: "bash",
});
```

```python Python theme={null}
result = app.browser_execute(
    session_id,
    code="agent-browser snapshot",
    language="bash",
)
```

## セッション管理

### 永続セッション

デフォルトでは、各ブラウザセッションは常にまっさらな状態から始まります。`profile` を使うと、セッション間でブラウザの状態を保存し再利用できます。ログイン状態の維持や設定の保持に役立ちます。

プロファイルを保存または選択するには、セッション作成時に `profile` パラメータを使用します。

```js Node theme={null}
const session = await firecrawl.browser({
  ttl: 600,
  profile: {
    name: "my-profile",
    saveChanges: true,
  },
});
```

```python Python theme={null}
session = app.browser(
    ttl=600,
    profile={
        "name": "my-profile",
        "save_changes": True,
    },
)
```

```bash cURL theme={null}
curl -X POST "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ttl": 600,
    "profile": {
      "name": "my-profile",
      "saveChanges": true
    }
  }'
```

```bash CLI theme={null}
# プロファイルで起動する（デフォルトで変更を保存）
firecrawl browser launch-session --profile my-profile

# 読み取り専用モードでプロファイルを使って起動する
firecrawl browser launch-session --profile my-profile --no-save-changes

# 短縮形：プロファイルで起動して一度に実行する
firecrawl browser --profile my-profile "open https://example.com"
```

| パラメータ | デフォルト | 説明 |
| - | - | - |
| `name` | — | 永続プロファイルの名前です。同じ名前のセッションはストレージを共有します。 |
| `saveChanges` | `true` | `true` の場合、ブラウザの状態は終了時にプロファイルへ保存されます。`false` に設定すると、既存データを読み込むだけで書き込みは行いません — 複数の同時読み取りが必要な場合に便利です。 |

> [!NOTE]
>
> 一度に 1 つのセッションだけがプロファイルへ保存できます。ほかのセッションがすでに保存中の場合、`409` エラーが返されます。同じプロファイルを `saveChanges: false` で開くことはできますが、そうでなければ時間をおいて再試行してください。

ブラウザセッションの状態は、セッションがクローズされたときにのみ保存されます。そのため、再利用できるよう、使い終わったらブラウザセッションをクローズすることを推奨します。セッションがクローズされると、そのセッション ID は無効になり、再利用できなくなります。代わりに、同じプロファイル名で新しいセッションを作成し、レスポンスで返される新しいセッション ID を使用してください。保存してクローズするには:

```js Node theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

await firecrawl.deleteBrowser("YOUR_SESSION_ID");
```

```python Python theme={null}
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

app.delete_browser("YOUR_SESSION_ID")
```

```bash CLI theme={null}
# アクティブなセッションを閉じる
firecrawl browser close

# 特定のセッションを閉じる
firecrawl browser close --session <id>
```

```bash cURL theme={null}
curl -X DELETE "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY"
```

### セッション一覧を取得する

```js Node theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

const { sessions } = await firecrawl.listBrowsers();
console.log(sessions);

// ステータスでフィルター
const { sessions: active } = await firecrawl.listBrowsers({ status: "active" });
console.log(active);
```

```python Python theme={null}
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

response = app.list_browsers()
print(response.sessions)
```

```bash CLI theme={null}
firecrawl browser list
firecrawl browser list active
```

```bash cURL theme={null}
curl -X GET "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY"

# ステータスでフィルター
curl -X GET "https://api.firecrawl.dev/v2/interact?status=active" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY"
```

```json Response theme={null}
{
  "success": true,
  "sessions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "status": "active",
      "cdpUrl": "wss://browser.firecrawl.dev/cdp/550e8400...?token=abc123...",
      "liveViewUrl": "https://liveview.firecrawl.dev/...",
      "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/...",
      "createdAt": "2025-01-15T10:30:00Z",
      "lastActivity": "2025-01-15T10:35:00Z"
    }
  ]
}
```

### TTL 設定

セッションには 2 種類の TTL 設定があります:

| Parameter | Default | Description |
| - | - | - |
| `ttl` | 600s (10 min) | セッションの最大存続時間 (30-3600s) |
| `activityTtl` | 300s (5 min) | 非アクティブ時の自動クローズまでの時間 (10-3600s) |

### 広告ブロック

セッションでは、スクレイピングの `blockAds` と同様に、広告、トラッカー、Cookie ポップアップがデフォルトでブロックされます。フィルタリングせずにページを読み込むには、セッション作成時に `"blockAds": false` を指定してください。Interact を使用したスクレイピングから開始されたセッションには、そのスクレイピングの `blockAds` 設定が適用されます。

### ロケーション

セッションは、デフォルトでは米国からブラウジングします。別の国からブラウジングするには、セッションの作成時に、ISO 3166-1 alpha-2 の国コードを `location` に指定します (スクレイピングの `location` と同じ形式です) 。

```bash theme={null}
curl -X POST "https://api.firecrawl.dev/v2/interact" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "location": { "country": "GB" } }'
```

セッションで指定できるのは国コードのみです。`languages` や、スクレイピングで使用できる `us-generic` などの特殊値を指定すると `400` が返されます。Interact を有効にしたスクレイピングから開始したセッションでは、そのスクレイピングの `location.country` が使用されます。

### データ保持ゼロ

セッション作成時に `"zeroDataRetention": true` を渡すと、データ保持ゼロ (ZDR) でセッションを実行できます。Firecrawl はセッションの終了後にページのコンテンツや実行の出力を永続化せず、以降そのセッションに対するすべての呼び出しも ZDR モードで処理されます。ZDR を利用するには Team で有効化されている必要があり、有効化されていない場合はリクエストが `403` を返します。ZDR モードではセッションの録画と永続プロファイルを利用できず (`400`) 、既存の非 ZDR セッションを ZDR に切り替えることもできません (`409`) 。詳細は [Interact ZDR](https://docs.firecrawl.dev/ja/features/interact.md#zero-data-retention-zdr) を参照してください。

### セッションを終了する

```js Node theme={null}
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });

await firecrawl.deleteBrowser("YOUR_SESSION_ID");
```

```python Python theme={null}
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

app.delete_browser("YOUR_SESSION_ID")
```

```bash CLI theme={null}
# アクティブなセッションを閉じる
firecrawl browser close

# 特定のセッションを閉じる
firecrawl browser close --session <id>
```

```bash cURL theme={null}
curl -X DELETE "https://api.firecrawl.dev/v2/interact/YOUR_SESSION_ID" \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY"
```

## ライブビュー

各セッションのレスポンスには `liveViewUrl` が含まれており、これを埋め込むことでブラウザーの状態をリアルタイムで確認できます。デバッグ、デモ、ブラウザー駆動型 UI の構築などに便利です。

```json Response theme={null}
{
  "success": true,
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "cdpUrl": "wss://browser.firecrawl.dev/cdp/550e8400...?token=abc123...",
  "liveViewUrl": "https://liveview.firecrawl.dev/...",
  "interactiveLiveViewUrl": "https://liveview.firecrawl.dev/...",
  "expiresAt": "2025-01-15T10:40:00Z"
}
```

```html theme={null}
<iframe src="LIVE_VIEW_URL" width="100%" height="600" />
```

### インタラクティブ Live View

レスポンスには `interactiveLiveViewUrl` も含まれます。閲覧専用の標準的な Live View と異なり、インタラクティブ Live View では、埋め込みストリームを通じてユーザーがブラウザセッションを直接操作できます (クリックや文字入力など) 。これは、ユーザー向けのブラウザ UI の構築、共同でのデバッグ、あるいは閲覧者がブラウザを操作する必要があるあらゆるシナリオに有用です。

```html theme={null}
<iframe src="INTERACTIVE_LIVE_VIEW_URL" width="100%" height="600" />
```

## CDP 経由での接続

すべてのセッションは CDP WebSocket URL を提供します。`execute` API と `--bash` フラグでほとんどのユースケースはカバーできますが、完全にローカルで制御したい場合は、直接接続することもできます。

```typescript TypeScript theme={null}
import { Firecrawl } from 'firecrawl';
import { chromium } from "playwright-core";

const firecrawl = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });
const session = await firecrawl.browser();

const browser = await chromium.connectOverCDP(session.cdpUrl);
const context = browser.contexts()[0];
const page = context.pages()[0] || (await context.newPage());

await page.goto("https://example.com");
console.log(await page.title());

await browser.close();
await firecrawl.deleteBrowser(session.id);
```

```python Python theme={null}
from firecrawl import Firecrawl
from playwright.sync_api import sync_playwright

app = Firecrawl(api_key="fc-YOUR-API-KEY")
session = app.browser()

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(session.cdp_url)
    context = browser.contexts[0]
    page = context.pages[0] if context.pages else context.new_page()

    page.goto("https://example.com")
    print(page.title())

    browser.close()

app.delete_browser(session.id)
```

```bash agent-browser theme={null}
# セッションのレスポンスで返される cdpUrl を使用
CDP_URL=YOUR_SESSION_CDP_URL

agent-browser open https://example.com --cdp "$CDP_URL"
agent-browser snapshot --cdp "$CDP_URL"
```

## Browser を使うべきタイミング

| ユースケース | 適切なツール |
| - | - |
| 既知の URL からコンテンツを抽出する | [Scrape](https://docs.firecrawl.dev/ja/features/scrape.md) |
| Web を検索して結果を取得する | [Search](https://docs.firecrawl.dev/ja/features/search.md) |
| ページネーションの操作、フォーム入力、クリックを伴うフローの操作 | **Browser** |
| インタラクションを伴うマルチステップのワークフロー | **Browser** |
| 複数のサイトを並列にブラウジングする | **Browser** (各セッションは分離されている) |

## ユースケース

* **競合分析** - 競合サイトを閲覧し、検索フォームやフィルターを操作して、価格や機能を構造化データとして抽出する
* **ナレッジベースの取り込み** - クリック操作、ページネーション、認証が必要なヘルプセンター、ドキュメント、サポートポータルを辿る
* **市場調査** - 複数のブラウザーセッションを並列で起動し、求人サイト、不動産リスティング、法的データベースなどからデータセットを構築する

## 料金

料金はセッションの操作方法によって異なります。セッションで `prompt` を使用する場合はブラウザー 1 分あたり 7 クレジット、使用しない場合 (Playwright の `code` のみ) はブラウザー 1 分あたり 2 クレジット です。課金はブラウザー利用時間 1 分単位で、最低利用時間は 1 分です。

データ保持ゼロのセッションでは、ブラウザー 1 分あたり 2 クレジットが加算されます。セッションで `prompt` を使用する場合はブラウザー 1 分あたり 9 クレジット、使用しない場合は 4 クレジットで、最低利用時間は同じく 1 分です。

## レート制限

初期リリースでは、すべてのプランで最大 20 個のブラウザーセッションを同時に稼働させることができます。

## API リファレンス

* [ブラウザセッションを作成](https://docs.firecrawl.dev/ja/api-reference/endpoint/browser-create.md)
* [ブラウザコードを実行](https://docs.firecrawl.dev/ja/api-reference/endpoint/browser-execute.md)
* [ブラウザセッションの一覧を取得](https://docs.firecrawl.dev/ja/api-reference/endpoint/browser-list.md)
* [ブラウザセッションを削除](https://docs.firecrawl.dev/ja/api-reference/endpoint/browser-delete.md)

***

ご意見やご不明な点がありましたら、[help@firecrawl.com](mailto:help@firecrawl.com) までメールいただくか、[Discord](https://discord.gg/firecrawl) でご連絡ください。

> Firecrawl API key が必要な AI agent の方は、[firecrawl.dev/agent-onboarding/SKILL.md](https://www.firecrawl.dev/agent-onboarding/SKILL.md) の自動オンボーディング手順をご覧ください。


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