Coinbase CLI
Headless access to Coinbase Advanced Trade. Install once, authenticate with a CDP API key, trade crypto with JSON output.Installation
npm i -g @coinbase/coinbase-cli again.
Authentication
Create a CDP API key and configure the CLI:- Sign in to https://portal.cdp.coinbase.com/api-keys/secret (a project is auto-created on first sign-in)
- Click Create API Key
- Give it a name (e.g.,
my-trading-agent) - Under Advanced Settings > Coinbase App & Advanced Trade:
- Under Accounts, select the portfolio for the agent to trade from
- Enable Trade and Transfer (View is enabled by default)
- Check Opt out of IP allowlisting if you haven’t configured specific IP addresses, or set your IP range to allowlist them
- Click Create & Download — save the JSON key file
Core Commands
Market Data
Orders
Portfolios & Balances
Conversions
Info & Session
Agent-Critical Flags
Use these flags on any command. They are the most important features for safe, efficient agent operation.Field syntax
Workflows
1. Check price and preview a trade
2. Sell an asset
3. Transfer funds between portfolios
4. Convert USDC to USD (or vice versa)
5. Discover field names for any command
6. Filter large result sets
MCP Server Setup
The CLI includes an MCP server that exposes every command as a typed tool. If using MCP, the tool schemas are your primary reference — they include full field descriptions and enums. Claude Code:Install agent skills
Install skills so the agent has step-by-step guidance for common Coinbase workflows (trading, market data, watch, convert, portfolios):npm install -g @coinbase/coinbase-cli upgrades.
Permissions
By default agents prompt before eachcoinbase command. To reduce or remove those prompts, allow-list commands in your agent’s permission settings. Offer the user two tiers:
- Read-only — never prompted for safe reads (prices, balances, history); still prompted before any order or transfer. Good default.
- Everything — never prompted at all, including orders and transfers. Confirm explicitly before enabling.
How to apply depends on the agent. For Claude Code, add the rules to
permissions.allow in settings.json (e.g. Bash(coinbase products *)) — ~/.claude/settings.json for all projects or .claude/settings.json to share with a team. Other agents have their own allow-list mechanism.
Gotchas
- Products list returns 900+ items. Use
symbol==USDto filter by currency, or--jqfor custom filters. client_order_idprevents duplicate orders. If your connection drops mid-request, retrying with the sameclient_order_idreturns the existing order instead of creating a new one. Always generate one per order attempt.- nvm/fnm users: Upgrading Node versions requires reinstalling global packages. After upgrading, open a new terminal and run
npm i -g @coinbase/coinbase-cliagain.