Remote Browser Service
Browser control for AI agents via HTTP API. Workflow: navigate, snapshot, act.
Setup
Ensure you have an active session:
- 1. Create session —
POST /api/sessions (HTTP, no WebSocket), or open WebSocket to /ws/{session_id} (DevTools CDP), or run from UI - Or restore — Use stored session from INLINECODE2
- Auth — Pass
Authorization: Bearer <token> or X-API-Key, or INLINECODE5
Base URL: https://rb.all-completed.com (or RBS_BASE_URL). Replace {session_id} in examples. User ID is derived from the token.
Core Workflow
- 1. Navigate to a URL
- Snapshot the accessibility tree (get refs) — INLINECODE9
- Act on refs or selectors (click, type, fill, press)
- Snapshot again to see results
Refs (e0, e1, …) from /json can be used with /action via selector (use ref as selector for e5 → "e5" maps to role/name; for now use CSS selector).
API Reference
Create session (HTTP)
CODEBLOCK0
Sessions idle for 5 min are closed. Use POST .../ping to keep alive.
List sessions
CODEBLOCK1
List stored sessions
CODEBLOCK2
Returns {sessions: [...], count}. Connect via WebSocket to /ws/{session_id} to resume.
Navigate
CODEBLOCK3
Snapshot (accessibility tree)
CODEBLOCK4
Returns {nodes: [{ref, role, name, depth, value?, disabled?, focused?, nodeId?}], count}.
Extract text
CODEBLOCK5
Returns {url, title, text}. Cheapest option (~800 tokens for most pages).
Screenshot
CODEBLOCK6
Act on elements
CODEBLOCK7
Action kinds: click, type, fill, press, focus, hover, select, scroll. Use selector (CSS) or ref (from snapshot). For press use key (e.g. Enter, Tab).
HTML snapshot
CODEBLOCK8
Token Cost Guide
| Method | Typical tokens | When to use |
|---|
| INLINECODE38 | ~800 | Reading page content |
| INLINECODE39 |
~3,600 | Finding buttons/links to click |
|
/json | ~10,500 | Full page structure |
|
/screenshot | ~2K (vision) | Visual verification |
Strategy: Use /text when you only need content. Use /json?filter=interactive for action-oriented tasks. Use full /json for complete page understanding. Use /screenshot for visual checks.
Environment Variables
| Var | Description |
|---|
| INLINECODE46 | Base URL (e.g. https://rb.all-completed.com) |
| INLINECODE47 |
Bearer token or API key (user_id derived from token) |
Tips
- - Session required — Ensure a session exists before calling navigate/json/text/action. Create via
POST /api/sessions (HTTP), WebSocket, or restore from stored sessions. - Refs from snapshot — Use
selector with the ref string (e.g. "e5") when the action API supports ref→DOM resolution; otherwise prefer CSS selectors. - Readability vs raw —
/text (default) strips nav/footer/ads; ?mode=raw returns full innerText. - Interactive filter —
?filter=interactive on /json reduces nodes by ~75% for action tasks. - Stored sessions — Sessions persist to S3 when WebSocket closes; list with
GET /api/stored-sessions, then connect via WebSocket to resume.
远程浏览器服务
通过HTTP API为AI代理提供浏览器控制。工作流程:导航、快照、操作。
环境配置
确保你有一个活跃的会话:
- 1. 创建会话 — POST /api/sessions(HTTP,无需WebSocket),或通过WebSocket连接到 /ws/{sessionid}(DevTools CDP),或从UI运行
- 或恢复会话 — 使用 GET /api/stored-sessions 中存储的会话
- 认证 — 传递 Authorization: Bearer 或 X-API-Key,或 ?accesstoken=
基础URL:https://rb.all-completed.com(或 RBSBASEURL)。在示例中替换 {session_id}。用户ID从令牌派生。
核心工作流程
- 1. 导航 到URL
- 快照 无障碍树(获取引用) — GET .../json
- 操作 引用或选择器(点击、输入、填充、按键)
- 再次快照 查看结果
来自 /json 的引用(e0、e1等)可通过 selector 与 /action 一起使用(使用 ref 作为选择器,例如 e5 → e5 映射到角色/名称;目前使用CSS selector)。
API参考
创建会话(HTTP)
bash
curl -X POST https://rb.all-completed.com/api/sessions \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {}
可选请求体:{session_id: my-session}
空闲5分钟的会话将被关闭。使用 POST .../ping 保持活跃。
列出会话
bash
curl https://rb.all-completed.com/api/sessions \
-H Authorization: Bearer
列出存储的会话
bash
curl https://rb.all-completed.com/api/stored-sessions \
-H Authorization: Bearer
返回 {sessions: [...], count}。通过WebSocket连接到 /ws/{session_id} 恢复会话。
导航
bash
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/navigate \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {url: https://example.com}
带超时(秒)
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/navigate \
-H Authorization: Bearer
\
-H Content-Type: application/json \
-d {url: https://example.com, timeout: 60}
快照(无障碍树)
bash
完整树
curl https://rb.all-completed.com/api/sessions/{session_id}/json \
-H Authorization: Bearer
仅交互元素(按钮、链接、输入)— 小得多
curl https://rb.all-completed.com/api/sessions/{session_id}/json?filter=interactive \
-H Authorization: Bearer
限制深度
curl https://rb.all-completed.com/api/sessions/{session_id}/json?depth=5 \
-H Authorization: Bearer
返回 {nodes: [{ref, role, name, depth, value?, disabled?, focused?, nodeId?}], count}。
提取文本
bash
可读性模式(默认)— 去除导航/页脚/广告
curl https://rb.all-completed.com/api/sessions/{session_id}/text \
-H Authorization: Bearer
原始innerText
curl https://rb.all-completed.com/api/sessions/{session_id}/text?mode=raw \
-H Authorization: Bearer
返回 {url, title, text}。最经济的选择(大多数页面约800个令牌)。
截图
bash
带base64的JSON
curl https://rb.all-completed.com/api/sessions/{session_id}/screenshot \
-H Authorization: Bearer
原始JPEG字节
curl https://rb.all-completed.com/api/sessions/{session_id}/screenshot?raw=true \
-H Authorization: Bearer \
-o screenshot.jpg
带质量(1-100)
curl https://rb.all-completed.com/api/sessions/{session_id}/screenshot?quality=50&raw=true \
-H Authorization: Bearer \
-o screenshot.jpg
操作元素
bash
通过选择器点击
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: click, selector: button.submit}
输入到元素(聚焦 + 插入文本)
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: type, selector: #email, text: user@example.com}
填充(直接设置值)
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: fill, selector: #email, text: user@example.com}
按键
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: press, key: Enter}
聚焦、悬停、选择、滚动
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: focus, selector: input[name=search]}
curl -X POST https://rb.all-completed.com/api/sessions/{session_id}/action \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {kind: scroll, scrollY: 800}
操作类型: click、type、fill、press、focus、hover、select、scroll。使用 selector(CSS)或 ref(来自快照)。对于 press 使用 key(例如 Enter、Tab)。
HTML快照
bash
完整DOM(内联CSS,在浏览器中打开)
curl https://rb.all-completed.com/api/sessions/{session_id}/html \
-H Authorization: Bearer
令牌成本指南
| 方法 | 典型令牌数 | 使用场景 |
|---|
| /text | ~800 | 阅读页面内容 |
| /json?filter=interactive |
~3,600 | 查找可点击的按钮/链接 |
| /json | ~10,500 | 完整页面结构 |
| /screenshot | ~2K(视觉) | 视觉验证 |
策略: 仅需内容时使用 /text。面向操作的任务使用 /json?filter=interactive。需要完整页面理解时使用完整 /json。视觉检查使用 /screenshot。
环境变量
| 变量 | 描述 |
|---|
| RBSBASEURL | 基础URL(例如 https://rb.all-completed.com) |
| ACAPIKEY |
Bearer令牌或API密钥(用户ID从令牌派生) |
提示
- - 需要会话 — 在调用navigate/json/text/action之前确保会话存在。通过 POST /api/sessions(HTTP)、WebSocket创建,或从存储的会话恢复。
- 快照中的引用 — 当操作API支持ref→DOM解析时,使用 selector 配合 ref 字符串(例如 e5);否则优先使用CSS选择器。
- 可读性 vs 原始 — /text(默认)去除导航/页脚/广告;?mode=raw 返回完整 innerText。
- 交互过滤器 — /