API Directory › ₿ Cryptocurrency › Coinbase
No authHTTPSCORS

Coinbase API

Prices, exchange rates and (authenticated) account and trading APIs.

Auth
No auth needed
HTTPS
Yes
CORS
Yes
Open Coinbase docs ↗

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

https://api.coinbase.com/v2

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
curl -s "https://api.coinbase.com/v2/prices/BTC-USD/spot"
Python
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"]
JavaScript
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.amountPrice as a decimal string — parse carefully, don’t use float for money
data.base / data.currencye.g. BTC and USD
prices/{pair}/buy and /sellInclude Coinbase’s spread — differ from spot
exchange-rates.data.ratesMap of currency code → rate relative to the base currency

Common errors

400 / 404Unknown or malformed pair — format is BASE-QUOTE, e.g. SOL-EUR.
429Rate limited. Back off; cache prices for a few seconds.
5xxCoinbase 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.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

Crypto PriceCryptoLarz app

Related Cryptocurrency APIs

← Back

More Cryptocurrency APIs · All 196 APIs