functions
作者: browserbase
使用 Browserbase
npx skills add https://github.com/browserbase/skills --skill functionsBrowserbase Functions
Deploy serverless browser automation using the official browse CLI.
Prerequisites
Get an API key from: https://browserbase.com/settings
export BROWSERBASE_API_KEY="your_api_key"
Creating a Function Project
1. Initialize
browse functions init my-function
cd my-function
This creates:
my-function/
├── package.json
├── index.ts # Your function code
└── .env # Add credentials here
2. Add Credentials to .env
echo "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .env
3. Install Dependencies
pnpm install
Function Structure
import { defineFn } from "@browserbasehq/sdk-functions";
import { chromium } from "playwright-core";
defineFn("my-function", async (context) => {
const { session, params } = context;
// Connect to browser
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
// Your automation
await page.goto(params.url || "https://example.com");
const title = await page.title();
// Return JSON-serializable result
return { success: true, title };
});
Key objects:
context.session.connectUrl- CDP endpoint to connect Playwrightcontext.params- Input parameters from invocation
Development Workflow
1. Start Dev Server
browse functions dev index.ts
Server runs at http://127.0.0.1:14113
2. Test Locally
curl -X POST http://127.0.0.1:14113/v1/functions/my-function/invoke \
-H "Content-Type: application/json" \
-d '{"params": {"url": "https://news.ycombinator.com"}}'
3. Iterate
The dev server auto-reloads on file changes. Use console.log() for debugging - output appears in the terminal.
Deploying
browse functions publish index.ts
Output:
Function published successfully
Build ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Function ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Save the Function ID - you need it to invoke.
Quick Reference
| Command | Description |
|---|---|
browse functions init <name> | Create new project |
browse functions dev <file> | Start local dev server |
browse functions publish <file> | Deploy to Browserbase |
For invocation examples, common patterns, and troubleshooting, see REFERENCE.md.
來自 browserbase 的更多技能
browser-automation
browserbase
使用 MCP 工具自動化網頁瀏覽器操作。當使用者要求瀏覽網站、導航網頁、從網站提取資料、截取螢幕畫面時使用…
official
functions
browserbase
使用官方 Browserbase Functions CLI 引導無伺服器瀏覽器自動化的部署。當使用者想要部署自動化以在…上執行時使用。
official
autobrowse
browserbase
透過自動研究循環實現自我改進的瀏覽器自動化。反覆執行瀏覽任務、讀取追蹤記錄,並持續提升導航技能…
official
browser
browserbase
使用本地Chrome或遠端Browserbase進行瀏覽器自動化,適用於受保護網站、機器人偵測及CAPTCHA驗證。兩種模式:本地Chrome(預設,無需設定)或遠端Browserbase(反機器人隱蔽、自動CAPTCHA解鎖、住宅代理、會話持久化)。核心指令涵蓋導航、頁面檢查、互動(點擊、輸入、填寫、選擇、拖曳)及透過CLI進行會話管理。使用瀏覽快照讀取無障礙樹並取得元素參考以實現可靠互動;保留...
official
browser-trace
browserbase
擷取任何瀏覽器自動化的完整 DevTools 協定追蹤 — CDP 資料流、螢幕截圖和 DOM 轉儲 — 然後將串流二分為每個可搜尋的頁面…
official
browserbase-cli
browserbase
Use the Browserbase CLI (`bb`) for Browserbase Functions and platform API workflows. Use when the user asks to run `bb`, deploy or invoke functions, manage…
official
company-research
browserbase
探索並深入研究潛在銷售對象的公司。使用 Browserbase Search API 進行發現,並採用「規劃→研究→綜合」模式進行深度豐富——輸出評分研究報告與 CSV 檔案。
official
cookie-sync
browserbase
將本機 Chrome 的 Cookie 同步至 Browserbase 持久化上下文,使 browse CLI 能存取已驗證的網站。當使用者希望以…身分瀏覽時使用。
official