基于 Base 链的 USDC 微支付付费即用 API 网关,无需 API 密钥,支持 15+ 生产环境 API,简易钱包设置。
Apiosk - 使用 USDC Micropay 访问是一项面向实际任务的技能,主要用于代理代理的每页付费 API 访问;没有 API 密钥;
使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
面向智能体的按请求付费 API 接入:无需 API 密钥,无需账户,即付即用。
Apiosk 使智能体能够通过 x402 协议(基于 Base 区块链的 USDC 微支付)直接调用生产环境 API。告别 API 密钥管理,开启按请求付费新范式。
# 通过 ClawHub 安装 clawhub install apiosk # 或手动克隆仓库 git clone https://github.com/apiosk/apiosk-skill
# 生成新钱包(或导入已有钱包) ./setup-wallet.sh # 此操作将在 ~/.apiosk/wallet.json 中创建以下内容: # - 私钥(本地明文存储,权限设为 chmod 600 以保障安全) # - 公钥地址 # - Base 主网 RPC 地址 **重要提示:** 私钥以明文形式保存在 `~/.apiosk/wallet.json` 中(文件权限已严格限制)。请仅向该钱包注入少量资金用于测试。生产环境建议使用硬件钱包或外部密钥管理系统。
重要提示:请为您的钱包充值 Base 主网上的 USDC(建议最低充值 $1–$10)。
充值方式:
# 列出全部 API ./list-apis.sh # 输出示例: # weather $0.001/req 获取当前天气与预报 # prices $0.002/req 加密货币/股票/外汇行情 # news $0.005/req 按主题/国家分类的全球新闻 # company $0.01/req 公司信息、财务数据、相关新闻 # geocode $0.001/req 地址 → 坐标转换 # ...
# 调用 weather API
./call-api.sh weather --params '{"city": "Amsterdam"}'
# 输出示例:
# {
# "temperature": 12,
# "condition": "Cloudy",
# "forecast": [...]
# }
#
# ✅ 已支付:$0.001 USDC
const { callApiosk } = require('./apiosk-client');
// 调用 weather API
const weather = await callApiosk('weather', {
city: 'Amsterdam'
});
console.log(`Temperature: ${weather.temperature}°C`);
// ✅ 自动支付 $0.001 USDC
from apiosk_client import call_apiosk
# 调用 prices API
prices = call_apiosk('prices', {
'symbols': ['BTC', 'ETH']
})
print(f"BTC: ${prices['BTC']}")
# ✅ 自动支付 $0.002 USDC
| API | 单次调用费用 | 描述 | 参数示例 |
|---|---|---|---|
| weather | $0.001 | 天气预报 | {"city": "NYC"} |
| prices | $0.002 | 加密货币/股票行情 | {"symbols": ["BTC"]} |
| news | $0.005 | 全球新闻文章 | {"topic": "AI"} |
| company | $0.01 | 公司数据 | {"domain": "apple.com"} |
| geocode | $0.001 | 地址 → 坐标转换 | {"address": "Amsterdam"} |
| code-runner | $0.05 | 执行代码沙箱 | {"lang": "python", "code": "..."} |
| pdf-generator | $0.02 | HTML → PDF 转换 | {"html": " |
| web-screenshot | $0.03 | URL → 截图 | {"url": "example.com"} |
| file-converter | $0.01 | 文件格式转换 | {"from": "docx", "to": "pdf"} |
完整文档: https://apiosk.com/#docs
list-apis.sh#!/bin/bash # 列出所有可用 API 及其定价信息 curl -s https://gateway.apiosk.com/v1/apis | jq -r '.apis[] | "(.id)t$(.price_usd)/reqt(.description)"'
call-api.sh#!/bin/bash # 调用任意 Apiosk API,并自动完成支付 # 使用方式:./call-api.sh--params '{"key":"value"}' API_ID=$1 PARAMS=$3 # 加载钱包信息 WALLET_ADDRESS=$(jq -r '.address' ~/.apiosk/wallet.json) # 发起请求(x402 支付通过链上验证完成) # 网关执行链上支付验证,客户端无需签名 curl -X POST "https://gateway.apiosk.com/$API_ID" -H "Content-Type: application/json" -H "X-Wallet-Address: $WALLET_ADDRESS" -d "$PARAMS"
check-balance.sh#!/bin/bash
# 查询您 Apiosk 钱包中的 USDC 余额
WALLET_ADDRESS=$(jq -r '.address' ~/.apiosk/wallet.json)
curl -s "https://gateway.apiosk.com/v1/balance?address=$WALLET_ADDRESS" | jq
# 输出示例: {"balance_usdc": 9.87, "spent_today": 0.13}
usage-stats.sh#!/bin/bash
# 查看您的 API 使用统计
WALLET_ADDRESS=$(jq -r '.address' ~/.apiosk/wallet.json)
curl -s "https://gateway.apiosk.com/v1/usage?address=$WALLET_ADDRESS" | jq
# 输出示例:
# {
# "total_requests": 142,
# "total_spent_usdc": 1.89,
# "by_api": {
# "weather": {"requests": 87, "spent": 0.087},
# "prices": {"requests": 55, "spent": 0.11}
# }
# }
const { callApiosk } = require('./apiosk-client');
async function getWeatherReport(city) {
const weather = await callApiosk('weather', { city });
return `🌤️ ${city} 天气简报:
温度:${weather.temperature}°C
天气状况:${weather.condition}
预报摘要:${weather.forecast.map(f => f.summary).join(', ')}
💰 成本:$0.001 USDC`;
}
// 使用示例
console.log(await getWeatherReport('Amsterdam'));
from apiosk_client import call_apiosk
import time
def track_prices(symbols, interval=60):
"""使用 Apiosk 追踪加密货币行情"""
while True:
prices = call_apiosk('prices', {'symbols': symbols})
for symbol, price in prices.items():
print(f"{symbol}: ${price:,.2f}")
print(f"✅ 已支付:$0.002 USDCn")
time.sleep(interval)
# 每分钟追踪 BTC 和 ETH 行情
track_prices(['BTC', 'ETH'])
const { callApiosk } = require('./apiosk-client');
async function getDailyDigest(topics) {
const articles = [];
for (const topic of topics) {
const news = await callApiosk('news', {
topic,
limit: 3
});
articles.push(...news.articles);
}
return `📰 每日新闻摘要(共 ${articles.length} 篇)
${articles.map(a => `- ${a.title} (${a.source})`).join('n')}
💰 总成本:$${(topics.length * 0.005).toFixed(3)} USDC`;
}
// 获取科技与商业类新闻
console.log(await getDailyDigest(['technology', 'business']));
传统 API 接入流程:
1. 注册账户 2. 获取 API 密钥 3. 安全存储密钥 4. 在请求中携带密钥 5. 监控速率限制 6. 按月缴纳订阅费用
Apiosk(x402 协议):
1. 发起请求 2. 网关返回 402 Payment Required 3. 您的钱包签署支付凭证 4. 网关执行链上验证 5. 网关将请求转发至目标 API 6. 返回响应结果
耗时:毫秒级;计费:按实际用量精确结算;准备时间:零配置。
# 编辑 ~/.apiosk/config.json
{
"rpc_url": "https://mainnet.base.org",
"chain_id": 8453,
"usdc_contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}
# 设置日消费上限 ./set-limit.sh --daily 10.00 # 设置单次请求最高费用 ./set-limit.sh --per-request 0.10
# 当余额低于阈值时触发通知 ./configure.sh --alert-balance 1.00 --alert-webhook "https://hooks.slack.com/..."
# 今日消费 ./usage-stats.sh --today # 本月消费 ./usage-stats.sh --month # 各 API 分项统计 ./usage-stats.sh --by-api
# 导出 CSV 格式账单数据(供财务对账) ./export-usage.sh --start 2026-01-01 --end 2026-01-31 --format csv > january_usage.csv
# 查询当前余额 ./check-balance.sh # 若余额过低,请为钱包充值: # 1. 通过 https://bridge.base.org 将 USDC 桥接到 Base 网络 # 2. 发送至:[您的钱包地址]
# 验证钱包签名功能是否正常 ./test-signature.sh # 若验证失败,请重新生成钱包: ./setup-wallet.sh --regenerate
# 刷新 API 列表缓存 ./list-apis.sh --refresh # 检查指定 API 是否已上线 curl https://gateway.apiosk.com/v1/apis | jq '.apis[] | select(.id=="weather")'
希望借助 Apiosk 实现您自有 API 的商业化?
# 1. 注册开发者账号
curl -X POST https://dashboard.apiosk.com/api/register
-d '{"email":"you@example.com","api_name":"My API"}'
# 2. 添加您的 API 接口
curl -X POST https://dashboard.apiosk.com/api/add
-H "Authorization: Bearer $TOKEN"
-d '{
"name": "my-api",
"endpoint": "https://my-api.com",
"price_usd": 0.01,
"description": "My awesome API"
}'
# 3. 开始盈利!
# 智能体通过 Apiosk 网关调用您的 API
# 您将自动获得 90–95% 的收入分成
更多详情: https://docs.apiosk.com/developers
面向智能体用户:
面向开发者:
网络效应: API 数量越多 → 吸引更多智能体 → 收入增长 → 激励更多 API 上线
由 Apiosk 团队为智能体经济构建。
x402 协议: 基于加密货币微支付的无密钥 API 接入协议。
使命: 让每一个 API 都能被每一个智能体即时访问。
“停止管理 API 密钥,开始按请求付费。”
MIT 协议 — 您可在智能体项目中自由使用!
# 安装
clawhub install apiosk
# 初始化配置
cd ~/.openclaw/skills/apiosk && ./setup-wallet.sh
# 调用示例
./call-api.sh weather --params '{"city": "Amsterdam"}'
# 监控使用情况
./usage-stats.sh
祝您开发愉快!🚀
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.3万人学习
共49课时 | 82.7万人学习
最新文章