Coinbase Pro API – A Complete Developer's Guide

·

The Coinbase Pro API is a powerful tool for developers, algorithmic traders, and fintech enthusiasts who want to interact programmatically with one of the most trusted cryptocurrency exchanges in the U.S. Whether you're building a trading bot, analyzing market data, or automating investment strategies, this guide walks you through everything you need to know—step by step.

From setup and authentication to executing trades and streaming real-time data, we cover all essential aspects of the Coinbase Pro API with practical code examples in Python. Let’s dive in.

What Is the Coinbase Pro API?

The Coinbase Pro API enables developers to access trading functionality, market data, and account information on the Coinbase Pro exchange via HTTP requests or WebSocket connections. Unlike the consumer-facing Coinbase app, Coinbase Pro is designed for active traders and supports advanced order types, high-frequency trading, and deeper liquidity.

Using this API, you can:

👉 Get started building your own trading automation tools today.

Is the Coinbase Pro API Free?

Yes, access to the Coinbase Pro API is free. There are no charges for creating an account or making API calls. However, standard trading fees apply when you execute buy or sell orders.

Coinbase Pro uses a maker-taker fee model, where:

Fees are tiered based on your 30-day trading volume in USD. For example:

Partial fills are split: filled portions incur taker fees; unfilled parts become maker orders once placed on the book.

Why Use the Coinbase Pro API?

Here’s why developers and traders choose Coinbase Pro:

👉 Explore how to integrate real-time data into your next project.

Potential Drawbacks

While robust, the platform has limitations:

Coinbase vs. Coinbase Pro: What’s the Difference?

Though both platforms are owned by Coinbase Global Inc, they serve different audiences:

You can link both accounts seamlessly—funds transfer easily between them.

Is Coinbase Pro API Better Than Coinbase API?

Yes. The Coinbase Pro API offers more advanced features than the standard Coinbase API, including:

For serious trading automation, Coinbase Pro is the superior choice.

Is the Coinbase Pro API Available in My Country?

The API is accessible in over 100 countries, including the U.S., Canada, most of Europe, Singapore, and Australia. Availability depends on local regulations—always verify compliance in your jurisdiction before use.

Alternatives to the Coinbase Pro API

If you're exploring other options, consider these popular exchanges:

Each offers strong API support but may vary in regulation, fee structure, and regional availability.

Supported Client Libraries

Officially maintained SDKs make integration easier:

These libraries abstract complex HTTP logic and simplify authentication and request handling.

How to Get Started With the Coinbase Pro API

Step 1: Create or Link Your Account

  1. Visit pro.coinbase.com
  2. Sign up directly or log in using your existing Coinbase account

Step 2: Generate an API Key

  1. Click your profile icon → API
  2. Select + New API Key
  3. Choose permissions (avoid “Transfer” unless needed)
  4. Set a nickname and passphrase
  5. Enter two-factor authentication code
  6. Save your API key, secret, and passphrase securely
🔐 Never expose your credentials in code or public repositories.

Install the Python client:

pip install cbpro

How to Fetch Trading Pairs Information

Use the get_products() endpoint to list all tradable assets:

import cbpro
import pandas as pd

client = cbpro.PublicClient()
products = pd.DataFrame(client.get_products())
print(products[['id', 'base_currency', 'quote_currency']].head())

This returns pairs like BTC-USD, ETH-EUR, ADA-USD, etc.

Retrieve Real-Time Price Data

Get current ticker data using get_product_ticker():

ticker = client.get_product_ticker(product_id='BTC-USD')
print(f"Current BTC Price: ${ticker['price']}")

Alternatively, use direct REST calls:

import requests
data = requests.get('https://api.pro.coinbase.com/products/BTC-USD/ticker').json()

Access Historical Candlestick Data

Fetch OHLCV (Open, High, Low, Close, Volume) data:

historical = pd.DataFrame(
    client.get_product_historic_rates('ETH-USD', granularity=3600)
)
historical.columns = ["Date", "Open", "High", "Low", "Close", "Volume"]
historical['Date'] = pd.to_datetime(historical['Date'], unit='s')
historical.set_index('Date', inplace=True)

Granularity options: 60, 300, 900, 3600, 21600, or 86400 seconds.

Calculate Technical Indicators Like 20-SMA

The API doesn’t provide built-in indicators—but you can compute them easily:

historical['20_SMA'] = historical['Close'].rolling(20).mean()

# Visualize with Plotly
import plotly.graph_objects as go
fig = go.Figure(data=[
    go.Candlestick(x=historical.index, open=historical['Open'], high=historical['High'],
                   low=historical['Low'], close=historical['Close']),
    go.Scatter(x=historical.index, y=historical['20_SMA'], line=dict(color='purple'), name='20-SMA')
])
fig.show()

Pull Order Book Data

Access real-time bid/ask levels:

book = client.get_product_order_book('BTC-USD', level=2)  # Level 2 = aggregated book

bids = pd.DataFrame(book['bids'], columns=['Price', 'Size', 'Orders'])
asks = pd.DataFrame(book['asks'], columns=['Price', 'Size', 'Orders'])

print("Top Bids:\n", bids.head())
print("Top Asks:\n", asks.head())

Stream Live Trades Data

Fetch recent transactions:

trades = pd.DataFrame(
    requests.get('https://api.pro.coinbase.com/products/ETH-USD/trades').json()
)
print(trades[['time', 'price', 'size']].head())

Use WebSockets for Real-Time Updates

Subscribe to live feeds using WebSocketClient:

import cbpro

class TickerFeed(cbpro.WebsocketClient):
    def on_message(self, msg):
        if msg.get('type') == 'ticker':
            print(f"{msg['product_id']}: ${msg['price']} @ {msg['time']}")

ws = TickerFeed(url="wss://ws-feed.pro.coinbase.com",
                products="BTC-USD",
                channels=["ticker"])
ws.start()

Stop with ws.close().

Automate Conditional Trades: Example Strategies

Example 1: Buy ETH When BTC Hits $38,500

from time import sleep

while True:
    try:
        btc_price = float(client.get_product_ticker('BTC-USD')['price'])
        if btc_price >= 38500.0:
            eth_price = float(client.get_product_ticker('ETH-USD')['price'])
            order = auth_client.place_limit_order(
                product_id='ETH-USD',
                side='buy',
                price=eth_price + 2,
                size='0.01'
            )
            sleep(2)
            status = auth_client.get_order(order['id'])
            if status['status'] == 'done':
                print("Trade executed successfully.")
            break
    except Exception as e:
        print(f"Error: {e}")
    sleep(10)

Example 2: Trade ETH If BTC Moves 5% in 5 Minutes

old_tick = client.get_product_ticker('BTC-USD')
sleep(300)  # Wait 5 minutes
new_tick = client.get_product_ticker('BTC-USD')

change = ((float(new_tick['price']) - float(old_tick['price'])) / float(old_tick['price'])) * 100

if abs(change) >= 5:
    # Execute trade logic here
    print(f"BTC moved {change:.2f}% — triggering trade.")

Cancel Open Orders

Cancel specific or all open orders:

auth_client.cancel_order(order_id="abc123")
# Or cancel all
auth_client.cancel_all(product_id='ETH-USD')

Frequently Asked Questions (FAQ)

Q: Do I need a verified Coinbase account to use the API?
A: Yes. You must complete identity verification to generate an API key with trading permissions.

Q: Can I use the API for high-frequency trading (HFT)?
A: While possible, rate limits apply. For HFT, optimize request frequency and prefer WebSockets over REST polling.

Q: Are there rate limits on the Coinbase Pro API?
A: Yes. Public endpoints allow ~3 requests per second; private endpoints are limited to ~5 per second per IP.

Q: How secure is the API?
A: Very secure—uses HMAC-SHA256 authentication, HTTPS/WSS encryption, and allows granular permission settings.

Q: Can I backtest strategies using this API?
A: Yes. Retrieve historical data at various intervals to simulate and test trading algorithms.

Q: Does Coinbase Pro support margin or futures trading via API?
A: No. The platform currently only supports spot trading through its public API.


Ready to take control of your crypto trading workflow? The Coinbase Pro API gives you full access to build intelligent systems that react in real time.

👉 Start building smarter trading solutions now.