Coinbase Advanced Trade Skill
Use this skill to run Coinbase Advanced Trade REST 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.coinbase.com. - Access to the curated OpenAPI schema URL:
- INLINECODE5
Scope
This skill covers a curated Coinbase Advanced Trade surface for:
- - product and best-bid-ask market reads
- account summary reads
- order create, cancel, and lookup workflows
This skill does not cover:
- - Coinbase Exchange APIs
- Coinbase Prime APIs
- Coinbase Derivatives APIs
- wallet or retail app product families outside Advanced Trade
Authentication
Public product endpoints can be read without credentials.
Private account and order endpoints require a Coinbase Advanced Trade bearer JWT. uxc now supports Coinbase's request-scoped JWT flow directly through jwt_bearer_v1, so you can store the API key id and private key in a credential and let uxc mint the short-lived bearer token per request.
Recommended v1 setup:
- 1. Download or copy the Coinbase API key material:
-
key_id:
organizations/{org_id}/apiKeys/{key_id}
-
private_key: Coinbase exports either
-----BEGIN EC PRIVATE KEY----- or
-----BEGIN PRIVATE KEY-----;
uxc accepts both PEM forms for ES256.
- 2. Store those values in a local credential.
- Bind the credential to
api.coinbase.com with a jwt_bearer_v1 signer.
CODEBLOCK0
Validate the active mapping when auth looks wrong:
CODEBLOCK1
Core Workflow
- 1. Use the fixed link command by default:
-
command -v coinbase-openapi-cli
- If missing, create it:
uxc link coinbase-openapi-cli https://api.coinbase.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinbase-openapi-skill/references/coinbase-advanced-trade.openapi.json
- INLINECODE19
- 2. Inspect operation help before execution:
-
coinbase-openapi-cli get:/api/v3/brokerage/products -h
-
coinbase-openapi-cli get:/api/v3/brokerage/accounts -h
- INLINECODE22
- 3. Prefer product reads before private account or order workflows:
-
coinbase-openapi-cli get:/api/v3/brokerage/products product_type=SPOT limit=20
- INLINECODE24
- 4. Treat all order placement and cancellation as high-risk writes.
Operations
- - INLINECODE25
- INLINECODE26
- INLINECODE27
- INLINECODE28
- INLINECODE29
- INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - INLINECODE40 mints a fresh short-lived Coinbase JWT on each private request; do not try to bind a stale pre-generated bearer token when
jwt_bearer_v1 is available. - Coinbase exports ES256 private keys in more than one PEM form; this skill expects the raw downloaded PEM and does not require a manual PKCS#8 conversion step.
- Treat
post:/api/v3/brokerage/orders and post:/api/v3/brokerage/orders/batch_cancel as high-risk writes. - Keep initial product/account pulls narrow with small
limit values. - INLINECODE45 is equivalent to
uxc https://api.coinbase.com --schema-url <coinbase_advanced_trade_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE47
- Curated OpenAPI schema: INLINECODE48
- Coinbase Advanced Trade overview: https://docs.cdp.coinbase.com/coinbase-app/advanced-trade-apis/overview
Coinbase Advanced Trade 技能
使用此技能可通过 uxc + OpenAPI 运行 Coinbase Advanced Trade REST 操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://api.coinbase.com 的网络连接。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinbase-openapi-skill/references/coinbase-advanced-trade.openapi.json
范围
此技能涵盖精选的 Coinbase Advanced Trade 功能,用于:
- - 产品和最佳买卖报价市场读取
- 账户摘要读取
- 订单创建、取消和查询工作流
此技能不涵盖:
- - Coinbase Exchange API
- Coinbase Prime API
- Coinbase Derivatives API
- Advanced Trade 之外的钱包或零售应用产品系列
认证
公共产品端点无需凭证即可读取。
私有账户和订单端点需要 Coinbase Advanced Trade bearer JWT。uxc 现在通过 jwtbearerv1 直接支持 Coinbase 的请求范围 JWT 流程,因此您可以将 API 密钥 ID 和私钥存储在凭证中,让 uxc 为每个请求生成短期 bearer 令牌。
推荐的 v1 设置:
- 1. 下载或复制 Coinbase API 密钥材料:
- key
id:organizations/{orgid}/apiKeys/{key_id}
- private_key:Coinbase 导出 -----BEGIN EC PRIVATE KEY----- 或 -----BEGIN PRIVATE KEY-----;uxc 接受 ES256 的两种 PEM 格式。
- 2. 将这些值存储在本地凭证中。
- 使用 jwtbearerv1 签名器将凭证绑定到 api.coinbase.com。
bash
uxc auth credential set coinbase-advanced-trade \
--auth-type api_key \
--field keyid=env:COINBASEKEY_ID \
--field privatekey=env:COINBASEPRIVATE_KEY
uxc auth binding add \
--id coinbase-advanced-trade \
--host api.coinbase.com \
--path-prefix /api/v3/brokerage \
--scheme https \
--credential coinbase-advanced-trade \
--signer-json {kind:jwtbearerv1,algorithm:es256,privatekeyfield:privatekey,headertyp:JWT,headerkidfield:keyid,expiresinseconds:120,claims:{static:{iss:cdp},fromfields:{sub:keyid},time:{nbf:now,exp:nowplusttl}},requestclaim:{name:uri,format:string,value_template:{{request.method}} {{request.host}}{{request.path}}}} \
--priority 100
当认证出现问题时,验证活动映射:
bash
uxc auth binding match https://api.coinbase.com/api/v3/brokerage/accounts
核心工作流
- 1. 默认使用固定链接命令:
- command -v coinbase-openapi-cli
- 如果缺失,创建它:
uxc link coinbase-openapi-cli https://api.coinbase.com --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/coinbase-openapi-skill/references/coinbase-advanced-trade.openapi.json
- coinbase-openapi-cli -h
- 2. 执行前检查操作帮助:
- coinbase-openapi-cli get:/api/v3/brokerage/products -h
- coinbase-openapi-cli get:/api/v3/brokerage/accounts -h
- coinbase-openapi-cli post:/api/v3/brokerage/orders -h
- 3. 在私有账户或订单工作流之前优先进行产品读取:
- coinbase-openapi-cli get:/api/v3/brokerage/products product_type=SPOT limit=20
- coinbase-openapi-cli get:/api/v3/brokerage/best
bidask product_ids=BTC-USD,ETH-USD
- 4. 将所有订单下达和取消视为高风险写入操作。
操作
- - get:/api/v3/brokerage/products
- get:/api/v3/brokerage/products/{productid}
- get:/api/v3/brokerage/bestbidask
- get:/api/v3/brokerage/accounts
- get:/api/v3/brokerage/accounts/{accountuuid}
- post:/api/v3/brokerage/orders
- post:/api/v3/brokerage/orders/batchcancel
- get:/api/v3/brokerage/orders/historical/{orderid}
- get:/api/v3/brokerage/orders/historical/batch
安全护栏
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- uxc 在每个私有请求上生成新的短期 Coinbase JWT;当 jwtbearerv1 可用时,不要尝试绑定过期的预生成 bearer 令牌。
- Coinbase 以多种 PEM 格式导出 ES256 私钥;此技能期望原始下载的 PEM,不需要手动进行 PKCS#8 转换步骤。
- 将 post:/api/v3/brokerage/orders 和 post:/api/v3/brokerage/orders/batchcancel 视为高风险写入操作。
- 保持初始产品/账户拉取范围较小,使用小的 limit 值。
- coinbase-openapi-cli ... 等同于 uxc https://api.coinbase.com --schema-url advancedtradeopenapi_schema> ...。
参考
- - 使用模式:references/usage-patterns.md
- 精选的 OpenAPI 模式:references/coinbase-advanced-trade.openapi.json
- Coinbase Advanced Trade 概述:https://docs.cdp.coinbase.com/coinbase-app/advanced-trade-apis/overview