Alchemy Prices API Skill
Use this skill to run Alchemy Prices API 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://api.g.alchemy.com. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/alchemy-openapi-skill/references/alchemy-prices.openapi.json
Scope
This v1 skill intentionally covers the narrow Prices API surface:
- - token price lookup by symbol
- token price lookup by contract address
- historical token prices
This skill does not cover:
- - node JSON-RPC
- NFT or portfolio APIs
- write operations
- the broader Alchemy API surface
- multi-symbol batch lookup in one
uxc call
Authentication
Alchemy Prices API places the API key in the request path: /prices/v1/{apiKey}/....
Configure one API-key credential with a request path prefix template:
CODEBLOCK0
Validate the active mapping when auth looks wrong:
CODEBLOCK1
Core Workflow
- 1. Use the fixed link command by default:
-
command -v alchemy-openapi-cli
- If missing, create it:
uxc link alchemy-openapi-cli https://api.g.alchemy.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/alchemy-openapi-skill/references/alchemy-prices.openapi.json
- INLINECODE10
- 2. Inspect operation schema first:
-
alchemy-openapi-cli get:/tokens/by-symbol -h
-
alchemy-openapi-cli post:/tokens/by-address -h
- INLINECODE13
- 3. Start with narrow single-asset reads before batch historical requests:
-
alchemy-openapi-cli get:/tokens/by-symbol symbols=ETH currency=USD
- INLINECODE15
4. Use positional JSON only for the POST endpoints:
- INLINECODE16
Operations
- - INLINECODE17
- INLINECODE18
- INLINECODE19
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 and prices-only. Do not imply RPC, trade execution, or wallet mutation support.
- API keys are sensitive because they appear in the request path. Use
--secret-env or --secret-op, not shell history literals, when possible. - INLINECODE28 is query-based in the live API.
- The live API supports repeated
symbols= parameters, but this v1 skill intentionally narrows that endpoint to a single symbols=<TOKEN> query because current uxc query argument handling does not reliably execute array-shaped query parameters. - Historical requests can expand quickly. Keep time windows tight unless the user explicitly wants a larger backfill.
- INLINECODE32 is equivalent to
uxc https://api.g.alchemy.com --schema-url <alchemy_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE34
- Curated OpenAPI schema: INLINECODE35
- Alchemy Prices API docs: https://www.alchemy.com/docs/reference/prices-api
- Prices API endpoints: https://www.alchemy.com/docs/reference/prices-api-endpoints
Alchemy Prices API 技能
使用此技能通过 uxc + OpenAPI 运行 Alchemy Prices API 操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://api.g.alchemy.com 的网络连接。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/alchemy-openapi-skill/references/alchemy-prices.openapi.json
范围
此 v1 技能特意仅涵盖有限的 Prices API 功能:
- - 按符号查询代币价格
- 按合约地址查询代币价格
- 历史代币价格
此技能不涵盖:
- - 节点 JSON-RPC
- NFT 或投资组合 API
- 写入操作
- 更广泛的 Alchemy API 功能
- 单次 uxc 调用中的多符号批量查询
认证
Alchemy Prices API 将 API 密钥放在请求路径中:/prices/v1/{apiKey}/...。
使用请求路径前缀模板配置一个 API 密钥凭证:
bash
uxc auth credential set alchemy-prices \
--auth-type api_key \
--secret-env ALCHEMYAPIKEY \
--path-prefix-template /prices/v1/{{secret}}
uxc auth binding add \
--id alchemy-prices \
--host api.g.alchemy.com \
--scheme https \
--credential alchemy-prices \
--priority 100
当认证出现问题时,验证活动映射:
bash
uxc auth binding match https://api.g.alchemy.com
核心工作流程
- 1. 默认使用固定链接命令:
- command -v alchemy-openapi-cli
- 如果缺失,创建它:
uxc link alchemy-openapi-cli https://api.g.alchemy.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/alchemy-openapi-skill/references/alchemy-prices.openapi.json
- alchemy-openapi-cli -h
- 2. 首先检查操作模式:
- alchemy-openapi-cli get:/tokens/by-symbol -h
- alchemy-openapi-cli post:/tokens/by-address -h
- alchemy-openapi-cli post:/tokens/historical -h
- 3. 在批量历史请求之前,从窄范围的单资产读取开始:
- alchemy-openapi-cli get:/tokens/by-symbol symbols=ETH currency=USD
- alchemy-openapi-cli post:/tokens/by-address {addresses:[{network:eth-mainnet,address:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48}],currency:USD}
- 4. 仅对 POST 端点使用位置 JSON:
- alchemy-openapi-cli post:/tokens/historical {symbol:ETH,startTime:2025-01-01T00:00:00Z,endTime:2025-01-07T00:00:00Z,interval:1d,currency:USD}
操作
- - get:/tokens/by-symbol
- post:/tokens/by-address
- post:/tokens/historical
防护措施
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 将此 v1 技能视为只读且仅限价格。不要暗示支持 RPC、交易执行或钱包变更。
- API 密钥敏感,因为它们出现在请求路径中。尽可能使用 --secret-env 或 --secret-op,而不是 shell 历史记录字面量。
- /tokens/by-symbol 在实时 API 中是基于查询的。
- 实时 API 支持重复的 symbols= 参数,但此 v1 技能特意将该端点限制为单个 symbols= 查询,因为当前 uxc 查询参数处理无法可靠地执行数组形式的查询参数。
- 历史请求可能快速扩展。除非用户明确需要更大的回填,否则保持时间窗口紧凑。
- alchemy-openapi-cli ... 等同于 uxc https://api.g.alchemy.com --schema-url openapischema> ...。
参考资料
- - 使用模式:references/usage-patterns.md
- 精选的 OpenAPI 模式:references/alchemy-prices.openapi.json
- Alchemy Prices API 文档:https://www.alchemy.com/docs/reference/prices-api
- Prices API 端点:https://www.alchemy.com/docs/reference/prices-api-endpoints