Extracting historic best bids and asks


Is there a way to extract the historic data of the best bids and asks of, let’s say, BTC-USD?

Using the API or the WebSocket feed, I can only get real-time data. Is there any way to extract previous date data, or maybe reconstruct them?

For example, can I reconstruct the historic values of best bids and asks, by extracting all trades from the endpoint “/trades” and reading the best bids and asks from there? The matching engine should execute trades at the best bids and asks, right?

1 Like

Hello @doogers. Welcome to the forum. Thank you for taking interest in Coinbase Cloud services.

In order to get the historic rates of a product, you may use the /candles endpoint (Get product candles). You may opt to specify the following:

  • granularity - this corresponds to the interval of time allotted to a system, representing one minute, five minutes, fifteen minutes, one hour, six hours, and one day. This must be in one of the following values: {60, 300, 900, 3600, 21600, 86400}
  • start - the timestamp for starting range of aggregations. This must be in Unix Epoch time format.
  • end - the timestamp for ending range of aggregations. This must be in Unix Epoch time format.

You may refer to the attached screenshot on how we got the historic rates of BTC-USD for a specified time.

Also, please do note that it is expected that the historic rate data for products may be incomplete on the /candles endpoint. We also call this out on our documentation that we do not guarantee completeness of historic data for the candles endpoint. Historical rates should not be polled frequently. If you need real-time information, you may use the Get product trades endpoint and Get product book endpoint along with the Websocket feed.

We hope this helps. Thank you!


Hi, thanks for the reply but I was asking about the best bids and asks in the orderbook. The endpoint ‘/candles’ do not provide this information.

Hello @doogers. Thank you for the clarification. We understand that you want to extract the best bids and asks data.

In order to get information about the best bid and ask, you may use the /ticker endpoint (https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker). For example: https://api.exchange.coinbase.com/products/BTC-USD/ticker

However, this endpoint doesn’t provide the historical data of the product id. You can’t customize its time range, unlike in the /candles endpoint.

You may also subscribe to the Ticker Channel if you wish to use the Websocket feed.

We hope this helps!


Please help me how i can get came back my money please help me

Hello @Kosratali! We empathize with you on this matter. For us to be able to assist you faster, we would like to recommend that you log a ticket in our Support Site . Thank you!

1 Like

Can you help me please

Hello @Kosratali! In order for us to help you, we may need sensitive information that should not be shared here in the Developer’s Forum. Hence, we recommend that you log a ticket in our Support Site to further assist you. Thank you!

1 Like