Coinbase Pro Public API Documentation

Coinbase Pro is a cryptocurrency exchange platform where users can buy, sell, and trade digital assets like Bitcoin, Ethereum, and Litecoin. The Coinbase Pro Public API provides access to real-time market data, trading history, and order book information. In this article, we will explore the various endpoints available with the Coinbase Pro Public API.

To start using the Coinbase Pro Public API, you need to create an API key in your Coinbase Pro account. Once you have created the API key, you can use it to authenticate your requests to the API.

To connect to the API in JavaScript, you can use the fetch method to make HTTP requests to the API endpoints. Here are some examples of how to use the Coinbase Pro Public API with JavaScript:

Retrieve Product Order Book

fetch('https://api.pro.coinbase.com/products/BTC-USD/book')
  .then(response => response.json())
  .then(data => console.log(data));

This code retrieves the order book for the BTC-USD product on Coinbase Pro. The response will include bids, asks, and trades for the product.

Retrieve Product Ticker

fetch('https://api.pro.coinbase.com/products/BTC-USD/ticker')
  .then(response => response.json())
  .then(data => console.log(data));

This code retrieves the ticker for the BTC-USD product on Coinbase Pro. The response will include the current bid, ask, and last traded price for the product.

Retrieve Historical Rates

fetch('https://api.pro.coinbase.com/products/BTC-USD/candles?granularity=3600')
  .then(response => response.json())
  .then(data => console.log(data));

This code retrieves the historical rates for the BTC-USD product on Coinbase Pro. The response will include the open, high, low, and close rates for each hour in the time period specified.

Retrieve Trades

fetch('https://api.pro.coinbase.com/products/BTC-USD/trades')
  .then(response => response.json())
  .then(data => console.log(data));

This code retrieves the trades for the BTC-USD product on Coinbase Pro. The response will include the trade id, price, size, and time for each trade.

Retrieve 24-Hour Stats

fetch('https://api.pro.coinbase.com/products/BTC-USD/stats')
  .then(response => response.json())
  .then(data => console.log(data));

This code retrieves the 24-hour stats for the BTC-USD product on Coinbase Pro. The response will include the open, high, low, and volume for the past 24 hours.

These are just a few examples of the endpoints available with the Coinbase Pro Public API. The API provides a lot of additional functionality to retrieve account information, create orders, and manage orders.

In conclusion, the Coinbase Pro Public API is a powerful tool for accessing real-time market data and managing orders on Coinbase Pro. With a little JavaScript knowledge, you can easily integrate the Coinbase Pro Public API into your web application.

Related APIs in Cryptocurrency