快速开始:五分钟从 Key 到成交
创建 Key、读取账户、下单、开发票,再决定是否上线实盘。
1. 创建 Key
打开 设置 → API Keys,命名 Key,勾选 read 与 trade,设置你能接受的上限。新 Key 默认只读、单笔 $50、每日 $200;弹窗里可以调高。
密钥只显示一次,复制后导出到环境变量:
export PB_KEY=pb_…2. 读取账户
curl -s https://protocolbanks.com/api/v1/agent/state \
-H "Authorization: Bearer $PB_KEY"新钱包会得到一个纸面账户(模拟 $500)与真实 Hyperliquid 行情。返回包含模式、净值、持仓、活动,以及策略与 spentTodayUsd。
3. 下单
curl -s https://protocolbanks.com/api/v1/agent/orders \
-H "Authorization: Bearer $PB_KEY" -H "Content-Type: application/json" \
-d '{"coin":"BTC","side":"long","sizeUsd":20}'成功时返回成交、费用与 remainingTodayUsd。超过 Key 单笔上限时,服务端在触达 Agent 之前就返回 403:
{"ok":false,"error":"order of $5000.00 exceeds this key's per-call cap of $100"}4. 创建发票
curl -s https://protocolbanks.com/api/v1/agent/invoice \
-H "Authorization: Bearer $PB_KEY" -H "Content-Type: application/json" \
-d '{"to":"0xabc…","amount":25,"description":"agent work"}'发票以 pending 创建,并返回 paymentLink(/pay?invoice=…&sig=…)。把链接交给付款方;用 GET /api/invoice?id=…&sig=… 回读结算状态。
5. 用 SDK 或一条命令
import { ProtocolBanks } from "@everestan/protocolbanks-sdk"
const pb = new ProtocolBanks({ apiKey: process.env.PB_KEY! })
const state = await pb.agent.state()
const order = await pb.agent.order({ coin: "BTC", side: "long", sizeUsd: 20 })
if (!order.ok) console.log(order.status, order.error) // 403 / 409 are returned如果你有仓库访问权限,PB_KEY=pb_… pnpm example:agent(加 --invoice)可以一条命令走完流程。框架工具清单在 @everestan/protocolbanks-agent-tools。
6. 转为实盘
在驾驶舱的 Go Live 卡片中授权 agent 钱包。同样的端点切换为实盘(mode: "live"),钱包只有交易权限。请从小额、可承受全损的预算开始。
Note · 实盘前请阅读风险披露。自动交易可能损失交易钱包的全部资金。

