CoinAPI REST Skill
Use this skill to run CoinAPI REST market data operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, auth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://rest.coinapi.io. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinapi-openapi-skill/references/coinapi-market.openapi.json
Scope
This skill covers a read-first market data surface:
- - current exchange rates
- current quote snapshots
- latest OHLCV candles
- latest trades
- latest order books
This skill does not cover:
- - FIX, WebSocket, or MCP transport surfaces
- write operations
- the broader CoinAPI catalog
Authentication
CoinAPI uses X-CoinAPI-Key header auth.
Configure one API-key credential and bind it to rest.coinapi.io:
CODEBLOCK0
Validate the active mapping when auth looks wrong:
CODEBLOCK1
Core Workflow
- 1. Use the fixed link command by default:
-
command -v coinapi-openapi-cli
- If missing, create it:
uxc link coinapi-openapi-cli https://rest.coinapi.io --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinapi-openapi-skill/references/coinapi-market.openapi.json
- INLINECODE10
- 2. Inspect operation schema first:
-
coinapi-openapi-cli get:/v1/exchangerate/{asset_id_base}/{asset_id_quote} -h
-
coinapi-openapi-cli get:/v1/ohlcv/{symbol_id}/latest -h
- INLINECODE13
- 3. Prefer narrow spot and latest reads before broader crawls:
-
coinapi-openapi-cli get:/v1/exchangerate/{asset_id_base}/{asset_id_quote} asset_id_base=BTC asset_id_quote=USD
- INLINECODE15
- 4. Execute with key/value parameters:
-
coinapi-openapi-cli get:/v1/ohlcv/{symbol_id}/latest symbol_id=BINANCE_SPOT_BTC_USDT period_id=1DAY limit=10
- INLINECODE17
Operations
- - INLINECODE18
- INLINECODE19
- INLINECODE20
- INLINECODE21
- INLINECODE22
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Treat this v1 skill as read-only. Do not imply order entry or market connectivity support.
- Keep
filter_symbol_id, period_id, limit, and limit_levels narrow unless the user explicitly wants larger pulls. - INLINECODE33 is equivalent to
uxc https://rest.coinapi.io --schema-url <coinapi_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE35
- Curated OpenAPI schema: INLINECODE36
- CoinAPI REST docs: https://docs.coinapi.io/market-data/rest-api
技能名称: coinapi-openapi-skill
详细描述:
CoinAPI REST 技能
使用此技能通过 uxc + OpenAPI 运行 CoinAPI REST 市场数据操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 网络可访问 https://rest.coinapi.io。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinapi-openapi-skill/references/coinapi-market.openapi.json
范围
此技能涵盖只读优先的市场数据面:
- - 当前汇率
- 当前报价快照
- 最新 OHLCV 蜡烛图
- 最新交易
- 最新订单簿
此技能不涵盖:
- - FIX、WebSocket 或 MCP 传输面
- 写入操作
- 更广泛的 CoinAPI 目录
认证
CoinAPI 使用 X-CoinAPI-Key 头部认证。
配置一个 API 密钥凭证并将其绑定到 rest.coinapi.io:
bash
uxc auth credential set coinapi \
--auth-type api_key \
--api-key-header X-CoinAPI-Key \
--secret-env COINAPI_KEY
uxc auth binding add \
--id coinapi \
--host rest.coinapi.io \
--scheme https \
--credential coinapi \
--priority 100
当认证出现问题时,验证活动映射:
bash
uxc auth binding match https://rest.coinapi.io
核心工作流程
- 1. 默认使用固定链接命令:
- command -v coinapi-openapi-cli
- 如果缺失,创建它:
uxc link coinapi-openapi-cli https://rest.coinapi.io --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinapi-openapi-skill/references/coinapi-market.openapi.json
- coinapi-openapi-cli -h
- 2. 首先检查操作模式:
- coinapi-openapi-cli get:/v1/exchangerate/{asset
idbase}/{asset
idquote} -h
- coinapi-openapi-cli get:/v1/ohlcv/{symbol_id}/latest -h
- coinapi-openapi-cli get:/v1/trades/{symbol_id}/latest -h
- 3. 在更广泛的爬取之前,优先进行窄范围的现货和最新读取:
- coinapi-openapi-cli get:/v1/exchangerate/{asset
idbase}/{asset
idquote} asset
idbase=BTC asset
idquote=USD
- coinapi-openapi-cli get:/v1/quotes/current filter
symbolid=BINANCE
SPOTBTC_USDT
- 4. 使用键/值参数执行:
- coinapi-openapi-cli get:/v1/ohlcv/{symbol
id}/latest symbolid=BINANCE
SPOTBTC
USDT periodid=1DAY limit=10
- coinapi-openapi-cli get:/v1/orderbooks/{symbol
id}/latest symbolid=BINANCE
SPOTBTC
USDT limitlevels=20
操作
- - get:/v1/exchangerate/{assetidbase}/{assetidquote}
- get:/v1/quotes/current
- get:/v1/ohlcv/{symbolid}/latest
- get:/v1/trades/{symbolid}/latest
- get:/v1/orderbooks/{symbol_id}/latest
防护措施
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 将此 v1 技能视为只读。不要暗示支持订单录入或市场连接。
- 保持 filtersymbolid、periodid、limit 和 limitlevels 为窄范围,除非用户明确要求更大的拉取。
- coinapi-openapi-cli ... 等同于 uxc https://rest.coinapi.io --schema-url openapischema> ...。
参考
- - 使用模式:references/usage-patterns.md
- 精选的 OpenAPI 模式:references/coinapi-market.openapi.json
- CoinAPI REST 文档:https://docs.coinapi.io/market-data/rest-api