Coinbase API
Prices, exchange rates and (authenticated) account and trading APIs.
What it does
Coinbase’s public API endpoints give you spot, buy and sell prices for hundreds of crypto–fiat pairs, historical spot prices, exchange rates and supported currencies — no account required for this read-only market data. Trading and account endpoints (a separate, authenticated API) are not covered here.
Base URL
Authentication
None for the public market-data endpoints below. Account, wallet and trading endpoints use the Coinbase Advanced Trade API with API-key + secret HMAC signing — a different base URL and flow.
Code examples
curl -s "https://api.coinbase.com/v2/prices/BTC-USD/spot"
import requests
def spot(pair="BTC-USD"):
r = requests.get(f"https://api.coinbase.com/v2/prices/{pair}/spot", timeout=10)
r.raise_for_status()
return r.json()["data"]["amount"]
print("BTC", spot("BTC-USD"))
print("ETH", spot("ETH-USD"))
# all exchange rates relative to one currency
rates = requests.get(
"https://api.coinbase.com/v2/exchange-rates", params={"currency": "USD"}
).json()["data"]["rates"]const res = await fetch(
"https://api.coinbase.com/v2/prices/BTC-USD/spot"
);
const { data } = await res.json();
console.log(data.base, data.currency, data.amount);Rate limits & quotas
The public market-data endpoints are rate-limited by IP — roughly 10 requests/second is safe; sustained bursts return 429. Prices are indicative spot values, not an order book. For tick-level or historical candle data use the Exchange (formerly Coinbase Pro) market-data API.
Key response fields
| data.amount | Price as a decimal string — parse carefully, don’t use float for money |
| data.base / data.currency | e.g. BTC and USD |
| prices/{pair}/buy and /sell | Include Coinbase’s spread — differ from spot |
| exchange-rates.data.rates | Map of currency code → rate relative to the base currency |
Common errors
| 400 / 404 | Unknown or malformed pair — format is BASE-QUOTE, e.g. SOL-EUR. |
| 429 | Rate limited. Back off; cache prices for a few seconds. |
| 5xx | Coinbase incident — retry with exponential backoff and a fallback source. |
When to use it (and alternatives)
These endpoints are perfect for a price ticker, a portfolio value display or a simple converter. For deep market data (order books, trades, OHLC candles) use the Coinbase Exchange API or CoinGecko; CoinGecko is also the easier choice if you need many coins, market caps and metadata in one call.
FAQ
Do I need a Coinbase account to get prices?
No. /v2/prices/… and /v2/exchange-rates are public. You only need keys for account, wallet and trading operations.
What’s the difference between spot, buy and sell price?
spot is the mid-market indicative price. buy and sell include Coinbase’s spread, so they’re what a retail trade would actually cost.
New to APIs?
Short guides for working with this API — and any other.