browserbase-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Browserbase CLI

Browserbase CLI

Use the official
bb
CLI for Browserbase platform operations, Functions workflows, and Fetch API calls.
使用官方
bb
CLI来执行Browserbase平台操作、Functions工作流以及Fetch API调用。

Setup check

安装检查

Before using the CLI, verify it is installed:
bash
which bb || npm install -g @browserbasehq/cli
bb --help
For authenticated commands, set the API key:
bash
export BROWSERBASE_API_KEY="your_api_key"
If using
bb functions dev
or
bb functions publish
, also set:
bash
export BROWSERBASE_PROJECT_ID="your_project_id"
使用CLI前,请确认已安装:
bash
which bb || npm install -g @browserbasehq/cli
bb --help
对于需要认证的命令,请设置API密钥:
bash
export BROWSERBASE_API_KEY="your_api_key"
如果使用
bb functions dev
bb functions publish
,还需设置:
bash
export BROWSERBASE_PROJECT_ID="your_project_id"

When to use this skill

适用场景

Use this skill when the user wants to:
  • run Browserbase commands through
    bb
  • scaffold, develop, publish, or invoke Browserbase Functions
  • inspect or manage Browserbase sessions, projects, contexts, or extensions
  • fetch a page through Browserbase without opening a browser session
  • search the web through Browserbase without opening a browser session
  • open the Browserbase dashboard from the terminal
当用户需要以下操作时,使用本技能:
  • 通过
    bb
    运行Browserbase命令
  • 搭建、开发、发布或调用Browserbase Functions
  • 查看或管理Browserbase会话、项目、上下文或扩展
  • 无需打开浏览器会话即可通过Browserbase获取页面
  • 无需打开浏览器会话即可通过Browserbase搜索网页
  • 从终端打开Browserbase控制台

When not to use this skill

不适用场景

  • For interactive browsing, page inspection, screenshots, clicking, typing, or login flows, prefer the
    browser
    skill.
  • For simple HTTP content retrieval where the user does not care about using the CLI specifically, the dedicated
    fetch
    skill is often a better fit.
  • Use
    bb browse ...
    only when the user explicitly wants the CLI wrapper or is already working in a
    bb
    -centric workflow.
  • 对于交互式浏览、页面检查、截图、点击、输入或登录流程,优先使用
    browser
    技能。
  • 对于不关心是否使用CLI的简单HTTP内容获取,专用的
    fetch
    技能通常更合适。
  • 仅当用户明确需要CLI包装器或已在以
    bb
    为中心的工作流中操作时,才使用
    bb browse ...

Command selection

命令选择

  • bb functions
    for local dev, packaging, publishing, and invocation
  • bb sessions
    ,
    bb projects
    ,
    bb contexts
    ,
    bb extensions
    for Browserbase platform resources
  • bb fetch <url>
    for Fetch API requests
  • bb search "<query>"
    for Search API requests
  • bb dashboard
    to open Browserbase Overview locally
  • bb browse ...
    to forward to the standalone
    browse
    binary (requires
    @browserbasehq/browse-cli
    )
  • bb skills install
    to install Browserbase agent skills for Claude Code
  • bb functions
    :用于本地开发、打包、发布和调用
  • bb sessions
    bb projects
    bb contexts
    bb extensions
    :用于管理Browserbase平台资源
  • bb fetch <url>
    :用于发送Fetch API请求
  • bb search "<query>"
    :用于发送Search API请求
  • bb dashboard
    :在本地打开Browserbase概览页面
  • bb browse ...
    :转发至独立的
    browse
    二进制文件(需安装
    @browserbasehq/browse-cli
  • bb skills install
    :为Claude Code安装Browserbase agent技能

Common workflows

常见工作流

Functions

Functions

bash
bb functions init my-function
cd my-function
bb functions dev index.ts
bb functions publish index.ts
bb functions invoke <function_id> --params '{"url":"https://example.com"}'
Use
bb functions invoke --check-status <invocation_id>
to poll an existing invocation instead of creating a new one.
bash
bb functions init my-function
cd my-function
bb functions dev index.ts
bb functions publish index.ts
bb functions invoke <function_id> --params '{"url":"https://example.com"}'
使用
bb functions invoke --check-status <invocation_id>
来轮询现有调用,而非创建新调用。

Platform APIs

平台API

bash
bb projects list --json
bb sessions get <session_id> --json
bb sessions downloads get <session_id> --output session-artifacts.zip
bb contexts create --body '{"region":"us-west-2"}' --json
bb extensions upload ./my-extension.zip --json
bash
bb projects list --json
bb sessions get <session_id> --json
bb sessions downloads get <session_id> --output session-artifacts.zip
bb contexts create --body '{"region":"us-west-2"}' --json
bb extensions upload ./my-extension.zip --json

Fetch API

Fetch API

bash
bb fetch https://example.com --json
bb fetch https://example.com --allow-redirects --output page.html
bash
bb fetch https://example.com --json
bb fetch https://example.com --allow-redirects --output page.html

Search API

Search API

bash
bb search "browser automation" --json
bb search "web scraping" --num-results 5 --json
bb search "AI agents" --output results.json
bash
bb search "browser automation" --json
bb search "web scraping" --num-results 5 --json
bb search "AI agents" --output results.json

Dashboard

控制台

bash
bb dashboard
bash
bb dashboard

Best practices

最佳实践

  1. Prefer
    bb --help
    and subgroup
    --help
    before guessing flags.
  2. Use dash-case flags exactly as shown in CLI help.
  3. Prefer
    --json
    when the result may need follow-up parsing.
  4. Use environment variables for auth unless the user explicitly wants one-off overrides.
  5. Pass structured request bodies with JSON strings in
    --body
    or
    --params
    .
  6. Remember that
    bb functions ...
    uses
    --api-url
    , while platform API commands use
    --base-url
    .
  7. If
    bb browse
    fails because
    browse
    is missing, either install
    @browserbasehq/browse-cli
    or switch to the
    browser
    skill.
  1. 在猜测参数前,优先使用
    bb --help
    及子命令的
    --help
  2. 严格按照CLI帮助中所示使用短横线命名(dash-case)的参数。
  3. 当结果可能需要后续解析时,优先使用
    --json
    参数。
  4. 除非用户明确要求一次性覆盖,否则使用环境变量进行认证。
  5. --body
    --params
    中通过JSON字符串传递结构化请求体。
  6. 注意
    bb functions ...
    使用
    --api-url
    ,而平台API命令使用
    --base-url
  7. 如果
    bb browse
    因缺少
    browse
    而失败,可安装
    @browserbasehq/browse-cli
    或切换至
    browser
    技能。

Troubleshooting

故障排除

  • Missing API key: set
    BROWSERBASE_API_KEY
    or pass
    --api-key
  • Missing project ID on
    bb functions dev
    or
    bb functions publish
    : set
    BROWSERBASE_PROJECT_ID
    or pass
    --project-id
  • Unknown flag: rerun the relevant command with
    --help
    and use the exact dash-case form
  • bb browse
    install error: run
    npm install -g @browserbasehq/browse-cli
For command-by-command reference and more examples, see REFERENCE.md.
  • 缺少API密钥:设置
    BROWSERBASE_API_KEY
    或传递
    --api-key
    参数
  • 使用
    bb functions dev
    bb functions publish
    时缺少项目ID:设置
    BROWSERBASE_PROJECT_ID
    或传递
    --project-id
    参数
  • 未知参数:重新运行相关命令并添加
    --help
    ,使用正确的短横线命名形式
  • bb browse
    安装错误:运行
    npm install -g @browserbasehq/browse-cli
如需逐命令参考及更多示例,请查看REFERENCE.md