Search code examples
coinbase-api

Coinbase API call to get crypto spot prices


Just started exploring CoinBase APIs.
I found that

I need to programmatically fetch current spot price for certain cryptocurrencies, I found an endpoint for this in the old API: https://api.coinbase.com/v2/prices/
Is this the correct API call to get the prices? Is there an equivalent endpoint in one of the new Coinbase Cloud APIs?


Solution

  • you can use the spot price api

    https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-prices#get-spot-price

    example: https://api.coinbase.com/v2/prices/BTC-USD/spot

    or you can use the ticker api (I think this is the better option)

    https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker

    example: https://api.pro.coinbase.com/products/BTC-USD/ticker