HARPA Grid — Browser Automation API
HARPA Grid lets you orchestrate real web browsers remotely. You can scrape pages, search the web, run built-in or custom AI commands, and send AI prompts with full page context — all through a single REST endpoint.
Prerequisites
The user must have:
- 1. HARPA AI Chrome Extension installed from https://harpa.ai
- At least one active Node — a browser with HARPA running (configured in the extension's AUTOMATE tab)
- A HARPA API key — obtained from the HARPA extension AUTOMATE tab. The key is provided as the
HARPA_API_KEY environment variable.
If the user hasn't set up HARPA yet, direct them to: https://harpa.ai/grid/browser-automation-node-setup
API Reference
Endpoint: POST https://api.harpa.ai/api/v1/grid
Auth: Authorization: Bearer $HARPA_API_KEY
Content-Type: INLINECODE3
Full reference: https://harpa.ai/grid/grid-rest-api-reference
Actions
1. Scrape a Web Page
Extract full page content (as markdown) or specific elements via CSS/XPath/text selectors.
Full page scrape:
CODEBLOCK0
Targeted element scrape (grab):
CODEBLOCK1
Grab fields:
| Field | Required | Default | Values |
|---|
| selector | yes | — | CSS (.class, #id), XPath (//h2), or text content |
| selectorType |
no | auto |
auto,
css,
xpath,
text |
| at | no | first |
all,
first,
last, or a number |
| take | no | innerText |
innerText,
textContent,
innerHTML,
outerHTML,
href,
value,
id,
className,
attributes,
styles,
[attrName],
(styleName) |
| label | no | data | Custom label for extracted data |
2. Search the Web (SERP)
Perform a web search. Supports operators like site:, intitle:.
CODEBLOCK2
3. Run an AI Command
Execute one of 100+ built-in HARPA commands or a custom automation on a target page.
CODEBLOCK3
- -
name — command name (e.g. "Summary", "Extract data", or any custom command) - INLINECODE31 — pre-filled user inputs for multi-step commands
- INLINECODE32 — HARPA parameter to return as result (default:
"message") - INLINECODE34 — AI model to use (e.g.
"HARPA AI", "gpt-4o", "claude-3.5-sonnet")
4. Run an AI Prompt
Send a custom AI prompt with page context. Use {{page}} to inject the page content.
CODEBLOCK4
Common Parameters
| Parameter | Required | Default | Description |
|---|
| action | yes | — | INLINECODE39 , serp, command, or INLINECODE42 |
| url |
no | — | Target page URL (ignored by
serp) |
| node | no | — | Node ID (
"r2d2"), multiple (
"r2d2 c3po"), first N (
"5"), or all (
"*") |
| timeout | no | 300000 | Max wait time in ms (max 5 minutes) |
| resultsWebhook | no | — | URL to POST results to asynchronously (retained 30 days) |
| connection | no | — | AI model for
command/
prompt actions |
Node Targeting
- - Omit
node to use the default node - INLINECODE51 — target a specific node by ID
- INLINECODE52 — target multiple nodes
- INLINECODE53 — use first 3 available nodes
- INLINECODE54 — broadcast to all nodes
Async Results via Webhook
Set resultsWebhook to receive results asynchronously. The action stays alive for up to 30 days, useful when target nodes are temporarily offline.
CODEBLOCK5
Tips
- - Scraping behind-login pages works because HARPA runs inside a real browser session with the user's cookies and auth state.
- Use the
grab array with multiple selectors to extract structured data in a single request. - For long-running AI commands, increase
timeout (max 300000ms / 5 min) or use resultsWebhook. - The
{{page}} variable in prompts injects the full page content — use it to give AI context about the current page.
HARPA Grid — 浏览器自动化 API
HARPA Grid 让您能够远程编排真实的网络浏览器。您可以抓取页面、搜索网络、运行内置或自定义的AI命令,以及发送带有完整页面上下文的AI提示——所有这些都通过一个REST端点完成。
前提条件
用户必须具备:
- 1. 从 https://harpa.ai 安装 HARPA AI Chrome 扩展程序
- 至少一个活跃节点 — 运行HARPA的浏览器(在扩展程序的AUTOMATE标签页中配置)
- 一个HARPA API密钥 — 从HARPA扩展程序的AUTOMATE标签页获取。该密钥作为 HARPAAPIKEY 环境变量提供。
如果用户尚未设置HARPA,请引导他们访问:https://harpa.ai/grid/browser-automation-node-setup
API 参考
端点: POST https://api.harpa.ai/api/v1/grid
认证: Authorization: Bearer $HARPAAPIKEY
内容类型: application/json
完整参考:https://harpa.ai/grid/grid-rest-api-reference
操作
1. 抓取网页
提取完整页面内容(以markdown格式)或通过CSS/XPath/文本选择器提取特定元素。
完整页面抓取:
bash
curl -s -X POST https://api.harpa.ai/api/v1/grid \
-H Authorization: Bearer $HARPAAPIKEY \
-H Content-Type: application/json \
-d {
action: scrape,
url: https://example.com,
timeout: 15000
}
定向元素抓取(grab):
bash
curl -s -X POST https://api.harpa.ai/api/v1/grid \
-H Authorization: Bearer $HARPAAPIKEY \
-H Content-Type: application/json \
-d {
action: scrape,
url: https://example.com/products,
grab: [
{
selector: .product-title,
selectorType: css,
at: all,
take: innerText,
label: titles
},
{
selector: .product-price,
selectorType: css,
at: all,
take: innerText,
label: prices
}
],
timeout: 15000
}
抓取字段:
| 字段 | 必填 | 默认值 | 可选值 |
|---|
| selector | 是 | — | CSS(.class、#id)、XPath(//h2)或文本内容 |
| selectorType |
否 | auto | auto、css、xpath、text |
| at | 否 | first | all、first、last 或数字 |
| take | 否 | innerText | innerText、textContent、innerHTML、outerHTML、href、value、id、className、attributes、styles、[attrName]、(styleName) |
| label | 否 | data | 提取数据的自定义标签 |
2. 搜索网络(SERP)
执行网络搜索。支持 site:、intitle: 等运算符。
bash
curl -s -X POST https://api.harpa.ai/api/v1/grid \
-H Authorization: Bearer $HARPAAPIKEY \
-H Content-Type: application/json \
-d {
action: serp,
query: OpenClaw AI agent framework,
timeout: 15000
}
3. 运行AI命令
在目标页面上执行100多个内置HARPA命令之一或自定义自动化。
bash
curl -s -X POST https://api.harpa.ai/api/v1/grid \
-H Authorization: Bearer $HARPAAPIKEY \
-H Content-Type: application/json \
-d {
action: command,
url: https://example.com/article,
name: Extract data,
inputs: 列出所有标题及其字数,
connection: HARPA AI,
resultParam: message,
timeout: 30000
}
- - name — 命令名称(例如 Summary、Extract data 或任何自定义命令)
- inputs — 为多步骤命令预填的用户输入
- resultParam — 作为结果返回的HARPA参数(默认:message)
- connection — 使用的AI模型(例如 HARPA AI、gpt-4o、claude-3.5-sonnet)
4. 运行AI提示
发送带有页面上下文的自定义AI提示。使用 {{page}} 注入页面内容。
bash
curl -s -X POST https://api.harpa.ai/api/v1/grid \
-H Authorization: Bearer $HARPAAPIKEY \
-H Content-Type: application/json \
-d {
action: prompt,
url: https://example.com,
prompt: 分析当前页面并提取所有联系信息。网页:{{page}},
connection: CHAT AUTO,
timeout: 30000
}
公共参数
| 参数 | 必填 | 默认值 | 描述 |
|---|
| action | 是 | — | scrape、serp、command 或 prompt |
| url |
否 | — | 目标页面URL(serp忽略此参数) |
| node | 否 | — | 节点ID(r2d2)、多个(r2d2 c3po)、前N个(5)或全部(*) |
| timeout | 否 | 300000 | 最大等待时间(毫秒,最长5分钟) |
| resultsWebhook | 否 | — | 异步POST结果的URL(保留30天) |
| connection | 否 | — | command/prompt操作的AI模型 |
节点定位
- - 省略 node 使用默认节点
- node: mynode — 按ID定位特定节点
- node: node1 node2 — 定位多个节点
- node: 3 — 使用前3个可用节点
- node: * — 广播到所有节点
通过Webhook异步获取结果
设置 resultsWebhook 以异步接收结果。该操作最多保持活跃30天,当目标节点暂时离线时非常有用。
json
{
action: scrape,
url: https://example.com,
resultsWebhook: https://your-server.com/webhook,
timeout: 15000
}
提示
- - 抓取需要登录的页面也能正常工作,因为HARPA在真实浏览器会话中运行,带有用户的cookies和认证状态。
- 使用包含多个选择器的 grab 数组,在单个请求中提取结构化数据。
- 对于长时间运行的AI命令,增加 timeout(最大300000毫秒/5分钟)或使用 resultsWebhook。
- 提示中的 {{page}} 变量会注入完整的页面内容——用它来为AI提供当前页面的上下文。