@coinbase/coinbase-cli

中文文档
0.0.11发布于 2026/10/31MITES Module零依赖近 30 天下载 3545

Coinbase for agents — CLI and MCP server for trading, wallets, payments, and onchain across the Coinbase platform

原始使用文档
文档目录13 节
  1. Install
  2. Quick start
  3. Commands
  4. coinbase env — Manage API keys
  5. coinbase <resource> <action> — API operations
  6. Streaming ( --watch / --until )
  7. coinbase history — Request history
  8. coinbase skills — Workflow skills
  9. Claude Code / MCP
  10. Configuration
  11. Contributing
  12. Security
  13. License

@coinbase/coinbase-cli

Coinbase for agents — CLI and MCP server for the Coinbase platform. Authenticate once, access every API from your terminal or AI agent.

Zero runtime dependencies — just Node.js 22+.

Install

npm install -g @coinbase/coinbase-cli

Quick start

# 1. Set up your API key (get one at coinbase.com/settings/api)
coinbase env live --key-id <id> --key-secret <secret>

# 2. Make a request
coinbase products list

# 3. Explore available commands
coinbase --help

Commands

coinbase env — Manage API keys

Configure API keys once; all subsequent commands authenticate automatically.

coinbase env                                           # list environments
coinbase env live --key-id <id> --key-secret <secret>  # configure inline
coinbase env live --remove                             # remove an environment

Multiple API keys — prefix live to inherit its URL with a different key:

coinbase env live-team-a --key-id <id> --key-secret <secret>  # inherits live URL
coinbase env live                                              # switch back to live
coinbase products list -e live-team-a                          # one-off override

Custom environment names that don't start with live require --url:

coinbase env custom --key-id <id> --key-secret <secret> --url https://api.coinbase.com

coinbase <resource> <action> — API operations

Commands are generated from the API spec. Run coinbase --help to see available resources and actions.

coinbase products list
coinbase products get product_id=BTC-USD
coinbase orders list
coinbase orders create product_id=BTC-USD side=BUY ...
coinbase balance
coinbase products ticker BTC-USDC \
  --until "price BTC-USDC >= 65000"   # block on a live stream until true, then exit 0

Use --template to see the expected request shape before writing, and --dry-run to preview without sending:

coinbase orders create --template    # print request body template
coinbase orders create --dry-run     # preview the assembled request

Field syntax:

SyntaxMeaning
key=valueString body field
key:=valueRaw JSON body field
key==valueQuery parameter
a.b.c=valueNested body field
@file.jsonBody from file
-Body from stdin
Header:valueCustom HTTP header

Resource flags:

FlagBehavior
--templatePrint request body template as JSON
--dry-runPrint request without sending
--editOpen request body in $EDITOR
--jq <expr>Filter JSON response (requires jq)
--paginateAuto-follow pagination for full results
--watchRender a live terminal surface fed by a WebSocket stream
--until <predicate>Block on a live stream until the predicate is true, then exit
--until-timeout <seconds>Cap how long --until waits before giving up
-e <env>Use a specific environment

Streaming (--watch / --until)

Read commands like products ticker, products book, and orders list can subscribe to a live WebSocket feed instead of making a one-shot request.

--watch renders a live terminal surface. --until blocks until a predicate becomes true, prints the matching event as JSON, and exits — composable with &&:

# Live ticker surface
coinbase products ticker BTC-USDC ETH-USDC --watch

# Block until BTC crosses 65k, then place an order
coinbase products ticker BTC-USDC --until "price BTC-USDC >= 65000" --until-timeout 3600 \
  && coinbase orders create product_id=BTC-USDC side=SELL ...

# Wait for an order to fill
coinbase orders list --until "status == FILLED"

Exit codes: 0 predicate matched, 124 timed out, 2 permanent stream failure.

coinbase history — Request history

View and manage a log of recent API requests made through the CLI.

coinbase history        # show recent requests
coinbase history clear  # clear request history

coinbase skills — Workflow skills

Manage reusable workflow skills (prompt templates) that extend the MCP server.

coinbase skills list                # list available skills
coinbase skills add                 # install/update all bundled skills
coinbase skills add --dir <path>    # install to a specific directory
coinbase skills remove              # remove all installed skills

Claude Code / MCP

coinbase mcp starts an MCP server that gives AI agents typed tool access to every Coinbase API endpoint. Tools are generated from the spec — new endpoints appear automatically when the CLI updates.

In addition to API tools, the MCP server exposes meta-tools for environment and workflow management:

ToolPurpose
coinbase_set_envSwitch the active API environment
coinbase_envShow current environment and key info
coinbase_helpGet usage help for CLI commands

If you installed the CLI globally:

claude mcp add --scope user --transport stdio coinbase -- coinbase mcp

MCP only (no global install needed — runs via npx):

claude mcp add --scope user --transport stdio coinbase -- npx -y @coinbase/coinbase-cli mcp

If you use both the CLI and MCP, install globally so they share the same version and spec.

Or add to your project's .mcp.json:

{
  "mcpServers": {
    "coinbase": { "transport": "stdio", "command": "coinbase", "args": ["mcp"] }
  }
}

Auto-approve read operations in .claude/settings.json:

{
  "permissions": {
    "allow": [
      "mcp__coinbase__coinbase_env",
      "mcp__coinbase__coinbase_help",
      "mcp__coinbase__coinbase_*_list",
      "mcp__coinbase__coinbase_*_get"
    ]
  }
}

Configuration

Environment variables override config file values:

VariablePurpose
COINBASE_ENVActive environment name
COINBASE_KEY_IDAPI key ID
COINBASE_KEY_SECRETAPI key secret
COINBASE_URLBase URL override
COINBASE_NO_HISTORYSet to 1 to disable request history
COINBASE_CONFIG_DIRConfig directory (default: ~/.config/coinbase, %APPDATA%\coinbase on Windows)

Keys and state are stored in config.json within the config directory.

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

License

MIT

版本与发布记录

@coinbase/coinbase-cli 共发布 12 个版本,首次发布于 2026/05/19;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.0.11latest2026/10/3110 天前
0.0.102026/10/011 个月前
0.0.92026/09/231 个月前
0.0.82026/09/221 个月前
0.0.72026/09/012 个月前
0.0.62026/08/192 个月前

其他发布通道:placeholder → 0.0.0。

关于 @coinbase/coinbase-cli 的常见问题

@coinbase/coinbase-cli 是什么?

Coinbase for agents — CLI and MCP server for trading, wallets, payments, and onchain across the Coinbase platform

如何安装 @coinbase/coinbase-cli?

在项目目录运行 npm install @coinbase/coinbase-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 coinbase,可以用 npx coinbase 直接运行。

@coinbase/coinbase-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/coinbase__coinbase-cli 是否存在。

@coinbase/coinbase-cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@coinbase/coinbase-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@coinbase/coinbase-cli 可以商用吗?

@coinbase/coinbase-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@coinbase/coinbase-cli 的下载量有多少?

根据 npm 官方下载统计,@coinbase/coinbase-cli 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,545 次,日均约 118 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@coinbase/coinbase-cli 还在维护吗?

最新版本 0.0.11 发布于 2026/10/31(10 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/05/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。