← 返回
安全合规 中文

Metered API Marketplace

Build and operate a metered public API endpoint ("agent microservice") for OpenClaw skills/agents with API-key auth, per-request usage logging + pricing, pre...
构建并运营带API密钥认证、按请求用量记录与计费的OpenClaw技能/代理计量公共API端点(“代理微服务”)...
arshingleton
安全合规 clawhub v0.1.3 1 版本 99860.1 Key: 无需
★ 0
Stars
📥 714
下载
💾 6
安装
1
版本
#latest

概述

Metered API Marketplace

Provide a production-lean template for: OpenClaw Skill → Public API Endpoint → Usage Metering → Crypto Payment Gateway → BTC/ETH wallets.

This skill ships a runnable reference server (Fastify + SQLite) that:

  • Accepts structured JSON input
  • Performs a high-value transformation (pluggable “transformers”)
  • Returns structured JSON output
  • Enforces signed API key auth
  • Checks prepaid balance, deducts per call, and logs usage
  • Accepts payment webhooks (Coinbase Commerce / BTCPay Server style)
  • Applies a 2.5% platform fee in the ledger (fee addresses configurable)

Workflow (do this in order)

1) Pick the productized capability (the thing people pay for)

Choose ONE transformer that is:

  • high leverage (makes/keeps money)
  • repeatable (called often)
  • defensible (data, heuristics, workflow, or automation — not “generic summarization”)

Good defaults:

  • revenue/offer optimizer
  • ad copy optimizer
  • lead scoring
  • contract risk flags

If unclear, start with the included revenue-amplifier transformer and replace it later.

2) Run the reference server locally

Use the bundled server in scripts/server/.

Typical run:

  • cd scripts/server
  • npm install
  • cp .env.example .env and edit
  • npm run dev

Set flat launch pricing in .env:

  • COST_CENTS_PER_CALL=25 # $0.25/call

3) Create an API key

Use scripts/server/admin/create_key_pg.js (or the admin HTTP endpoint) to create a key and starting balance.

4) Integrate from an OpenClaw skill / agent

Call the public endpoint with:

  • x-api-key
  • x-timestamp (unix ms)
  • x-signature = hex(HMAC_SHA256(api_secret, ${timestamp}.${rawBody}))

5) Add real payments

Wire a payment processor webhook to /v1/payments/webhook/:provider.

Providers are adapter-based:

  • start with “manual” credits (admin script)
  • then add Coinbase Commerce or BTCPay Server

6) Ship

Deploy behind TLS (Cloudflare / Fly.io / Render / AWS / GCP). Put rate limiting at the edge + in-app.

Bundled resources

scripts/server/

Runnable reference implementation:

  • Fastify API server (long-running)
  • Postgres ledger (balances, usage, credits)
  • Signed API key auth
  • Rate limiting + basic anti-abuse
  • Webhook endpoint(s)

scripts/nextjs-starter/

Vercel-ready Next.js API implementation:

  • Serverless API routes (no listen())
  • Postgres ledger (Supabase Transaction Pooler recommended)
  • Same auth + pricing + webhook concepts

references/

Read only when needed:

  • references/api_reference.md – endpoint contracts + auth/signing
  • references/billing_ledger.md – pricing, fee logic, idempotency
  • references/providers.md – provider adapters (Coinbase/BTCPay patterns)

版本历史

共 1 个版本

  • v0.1.3 当前
    2026-03-30 00:15 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,714
security-compliance

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,164
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,439