CLI 参考
pikeway inspect
查看端点需要的输入和价格,并附上可直接执行的 pikeway run 命令。免费,无需 key。
用法
bash
pikeway inspect -p <provider> -e <endpoint> [-m <method>] [--json]
说明
调用 POST /v1/inspect,依次输出 API 名称、方法、路径、价格和说明,然后是路径参数和查询参数(必填项以 * 标出,附类型、可选值和说明),有 JSON body 时再输出其 schema,最后是 API 提供方的备注。
最后一行是一条完整的 pikeway run 命令,已填入端点的示例输入,复制后改改参数值即可运行。只有非 GET 方法才会在这行加上 -m。
参数
--provider, -pstring必填API slug,即
discover 显示的名称(如 birdeye)。--endpoint, -estring必填端点路径。可以是模板(
/tvl/{protocol}),也可以是具体路径(/tvl/aave)。--method, -mstringHTTP 方法。仅当同一路径有多个方法时需要,否则网关会自动选择存在的那个。
示例
bash
# the usual next step after discover
pikeway inspect -p birdeye -e /defi/price
# pick the POST variant of a path that also has GET
pikeway inspect -p someapi -e /reports -m POST
# a concrete path is matched against its template
pikeway inspect -p defillama -e /tvl/aave
# get just the input schema and example
pikeway inspect -p birdeye -e /defi/price --json | jq '{input, exampleInput}'输出
text
Birdeye (birdeye) GET /defi/price $0.001/call
Current price of a token by mint address
query parameters:
* address string Token mint address
next: pikeway run -p birdeye -e '/defi/price' -i '{"queryParams":{"address":"So11111111111111111111111111111111111111112"}}'带 JSON body 和提供方备注的端点:
text
Some API (someapi) POST /reports $0.01/call
Generate a usage report
JSON body schema:
{
"type": "object",
"properties": {
"range": { "type": "string", "enum": ["7d", "30d", "90d"] }
},
"required": ["range"]
}
note: reports over 90 days can take a few minutes; use --wait
next: pikeway run -p someapi -e '/reports' -m POST -i '{"body":{"range":"30d"}}'--json
完整的 /v1/inspect 响应:input(pathParams、queryParams、body 的 JSON Schema)、exampleInput、price、notes、hints,以及已发布时的 responses。
json
{
"provider": "birdeye",
"providerName": "Birdeye",
"endpoint": "/defi/price",
"method": "GET",
"description": "Current price of a token by mint address",
"input": {
"queryParams": {
"type": "object",
"properties": { "address": { "type": "string", "description": "Token mint address" } },
"required": ["address"]
}
},
"exampleInput": { "queryParams": { "address": "So11111111111111111111111111111111111111112" } },
"price": { "type": "PER_CALL", "amount": { "value": 0.001, "currency": "USD" } },
"notes": [],
"hints": { "inspect": "…", "run": "…", "docs": "…" }
}错误与退出码
| 退出码 | 错误信息 | 触发条件 |
|---|---|---|
| 2 | missing --provider | 没有传 -p(或没有给值)。 |
| 2 | missing --endpoint | 没有传 -e。 |
| 1 | unknown provider: birdeyee | 不存在该 slug 的 API。 |
| 1 | unknown endpoint /price on birdeye | 不存在该路径。加 --json 时,details.available 会列出实际存在的端点。 |
| 1 | cannot reach <gateway>: ECONNREFUSED | 无法连接网关(DNS、网络,或 PIKEWAY_API_BASE_URL 写错)。冒号后的错误码来自 Node。 |
- 不确定路径?先运行 pikeway discover,或对错误路径加
--json获取有效路径列表。