bankr-dev---api-workflow by bankrbot/claude-plugins
npx skills add https://github.com/bankrbot/claude-plugins --skill 'Bankr Dev - API Workflow'Bankr Agent API 使用的异步任务模式的完整参考。
1. 提交 -> POST /agent/prompt -> 获取 jobId + threadId
2. 轮询 -> GET /agent/job/{id} -> 每 2 秒检查状态
3. 完成 -> 最终状态 -> 处理 response + richData
const response = await fetch(`${API_URL}/agent/prompt`, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
prompt: "What is my ETH balance?",
threadId: "thr_XYZ789", // optional: continue conversation
}),
});
// → { success: true, jobId: "job_abc123", threadId: "thr_XYZ789", status: "pending" }
请求字段:
prompt (string, required): 自然语言提示(最多 10,000 个字符)threadId (string, optional): 继续现有对话。对于新对话请省略。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
const status = await fetch(`${API_URL}/agent/job/${jobId}`, {
headers: { "x-api-key": API_KEY },
});
const cancel = await fetch(`${API_URL}/agent/job/${jobId}/cancel`, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
});
| 状态 | 描述 | 操作 |
|---|---|---|
pending | 任务已排队,尚未开始 | 继续轮询 |
processing | 任务正在运行 | 继续轮询,显示 statusUpdates |
completed | 成功完成 | 读取 response 和 richData |
failed | 遇到错误 | 检查 error 字段 |
cancelled | 已被取消 | 无需进一步操作 |
success, jobId, threadId, status, prompt, createdAtresponse — 自然语言文本richData — 结构化数据数组(图表、社交卡片等)transactions — 已执行交易的数组completedAt, processingTimestatusUpdates — { message, timestamp } 数组startedAt, cancellableerror — 错误信息completedAtcancelledAtasync function waitForCompletion(
jobId: string,
onProgress?: (message: string) => void
): Promise<JobStatusResponse> {
const POLL_INTERVAL = 2000; // 2 seconds
const MAX_POLLS = 150; // 5 minutes max
let lastUpdateCount = 0;
for (let i = 0; i < MAX_POLLS; i++) {
const status = await getJobStatus(jobId);
// Report new status updates
if (onProgress && status.statusUpdates) {
for (let j = lastUpdateCount; j < status.statusUpdates.length; j++) {
onProgress(status.statusUpdates[j].message);
}
lastUpdateCount = status.statusUpdates.length;
}
// Terminal states
if (["completed", "failed", "cancelled"].includes(status.status)) {
return status;
}
await new Promise((r) => setTimeout(r, POLL_INTERVAL));
}
throw new Error("Job timed out");
}
// Start a conversation
const first = await submitPrompt("What is the price of ETH?");
const threadId = first.threadId;
// Continue the conversation (agent remembers context)
const second = await submitPrompt("And what about BTC?", threadId);
// Each response includes the same threadId
已完成的任务可能包含 richData:
type RichData = {
type?: string; // "social-card", "chart", etc.
[key: string]: unknown;
};
无论 richData 内容如何,response 字段始终包含文本摘要。
| 状态 | 错误 | 解决方案 |
|---|---|---|
| 400 | 无效请求 / 提示过长 | 检查输入(最多 10,000 个字符) |
| 401 | 需要身份验证 | 检查 API 密钥 |
| 403 | Agent API 未启用 | 在 bankr.bot/api 启用 |
| 404 | 未找到任务 | 检查 jobId 是否正确 |
| 429 | 超出速率限制 | 等待 resetAt 时间戳 |
// Handle rate limits
if (response.status === 429) {
const error = await response.json();
const waitMs = error.resetAt - Date.now();
console.log(`Rate limited. Resets in ${Math.ceil(waitMs / 60000)} minutes`);
}
import { submitPrompt, waitForCompletion } from "./bankr-client";
async function main() {
// Submit
const { jobId } = await submitPrompt("Swap 0.1 ETH for USDC on Base");
console.log(`Job: ${jobId}`);
// Poll with progress
const result = await waitForCompletion(jobId, (msg) => {
console.log(`Progress: ${msg}`);
});
// Handle result
if (result.status === "completed") {
console.log(result.response);
for (const tx of result.transactions || []) {
console.log(`Transaction: ${tx.type}`);
}
} else if (result.status === "failed") {
console.error(`Failed: ${result.error}`);
}
}
bankr-api-basics - 端点文档和 TypeScript 接口bankr-client-patterns - 包含 execute() 辅助函数的可重用客户端代码bankr-sign-submit-api - 同步端点(无需轮询)每周安装次数
–
代码仓库
GitHub 星标数
69
首次出现
–
Complete reference for the asynchronous job pattern used by the Bankr Agent API.
1. SUBMIT -> POST /agent/prompt -> Get jobId + threadId
2. POLL -> GET /agent/job/{id} -> Check status every 2s
3. COMPLETE -> Terminal status -> Process response + richData
const response = await fetch(`${API_URL}/agent/prompt`, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
prompt: "What is my ETH balance?",
threadId: "thr_XYZ789", // optional: continue conversation
}),
});
// → { success: true, jobId: "job_abc123", threadId: "thr_XYZ789", status: "pending" }
Request fields:
prompt (string, required): Natural language prompt (max 10,000 chars)threadId (string, optional): Continue existing conversation. Omit for new thread.const status = await fetch(`${API_URL}/agent/job/${jobId}`, {
headers: { "x-api-key": API_KEY },
});
const cancel = await fetch(`${API_URL}/agent/job/${jobId}/cancel`, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
});
| Status | Description | Action |
|---|---|---|
pending | Job queued, not started | Keep polling |
processing | Job running | Keep polling, show statusUpdates |
completed | Finished successfully | Read response and richData |
failed | Encountered error | Check error field |
cancelled | Was cancelled | No further action |
success, jobId, threadId, status, prompt, createdAtresponse — Natural language textrichData — Array of structured data (charts, social cards)transactions — Array of executed transactionscompletedAt, processingTimestatusUpdates — Array of { message, timestamp }startedAt, cancellableerror — Error messagecompletedAtcancelledAtasync function waitForCompletion(
jobId: string,
onProgress?: (message: string) => void
): Promise<JobStatusResponse> {
const POLL_INTERVAL = 2000; // 2 seconds
const MAX_POLLS = 150; // 5 minutes max
let lastUpdateCount = 0;
for (let i = 0; i < MAX_POLLS; i++) {
const status = await getJobStatus(jobId);
// Report new status updates
if (onProgress && status.statusUpdates) {
for (let j = lastUpdateCount; j < status.statusUpdates.length; j++) {
onProgress(status.statusUpdates[j].message);
}
lastUpdateCount = status.statusUpdates.length;
}
// Terminal states
if (["completed", "failed", "cancelled"].includes(status.status)) {
return status;
}
await new Promise((r) => setTimeout(r, POLL_INTERVAL));
}
throw new Error("Job timed out");
}
// Start a conversation
const first = await submitPrompt("What is the price of ETH?");
const threadId = first.threadId;
// Continue the conversation (agent remembers context)
const second = await submitPrompt("And what about BTC?", threadId);
// Each response includes the same threadId
Completed jobs may include richData:
type RichData = {
type?: string; // "social-card", "chart", etc.
[key: string]: unknown;
};
The response field always has a text summary regardless of richData content.
| Status | Error | Resolution |
|---|---|---|
| 400 | Invalid request / Prompt too long | Check input (max 10,000 chars) |
| 401 | Authentication required | Check API key |
| 403 | Agent API not enabled | Enable at bankr.bot/api |
| 404 | Job not found | Check jobId is correct |
| 429 | Rate limit exceeded | Wait for resetAt timestamp |
// Handle rate limits
if (response.status === 429) {
const error = await response.json();
const waitMs = error.resetAt - Date.now();
console.log(`Rate limited. Resets in ${Math.ceil(waitMs / 60000)} minutes`);
}
import { submitPrompt, waitForCompletion } from "./bankr-client";
async function main() {
// Submit
const { jobId } = await submitPrompt("Swap 0.1 ETH for USDC on Base");
console.log(`Job: ${jobId}`);
// Poll with progress
const result = await waitForCompletion(jobId, (msg) => {
console.log(`Progress: ${msg}`);
});
// Handle result
if (result.status === "completed") {
console.log(result.response);
for (const tx of result.transactions || []) {
console.log(`Transaction: ${tx.type}`);
}
} else if (result.status === "failed") {
console.error(`Failed: ${result.error}`);
}
}
bankr-api-basics - Endpoint documentation and TypeScript interfacesbankr-client-patterns - Reusable client code with execute() helperbankr-sign-submit-api - Synchronous endpoints (no polling needed)Weekly Installs
–
Repository
GitHub Stars
69
First Seen
–
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
29,800 周安装