Chirag Jain
Chirag Jain

Reputation: 53

Coinbase API: How to get market or spot prices for all currencies

The current Coinbase API for market data: https://developers.coinbase.com/api/v2#get-spot-price only provides the spot price for one currency per API call. Is there a supported API that can provide the SPOT or market price for all supported currencies in a single API call?

Upvotes: 1

Views: 1684

Answers (2)

Like @Andy answer, use .../v2/exchange-rates?currency=CURRENCY (replace CURRENCY by any currency available one Coinbase.

For instance do a query to .../v2/exchange-rates?currency=USD and to get the prices against USD divide 1 by the exchange rate given.

So if you get:

...
    "currency":"USD",
          "rates":{
             "BTC":"2.8266877198368038e-05",
             "ETH":"0.00041082102582010144",
             ...
          }
...

To get ETH price against USD, you can do 1/0.00041082102582010144 = 2434,15 USD.

Upvotes: 5

Andy
Andy

Reputation: 892

Use the "/v2/exchange-rates?currency={0}" with for example "USD" as the currency, and it will return all other currencies' exchange rate for USD.

Upvotes: 2

Related Questions