Using the python coinbase API-- The functions-- get_buy_price
, get_sell_price
, get_spot_price
, get_historical_data
, etc... all seem to return bitcoin prices only. Is there a way of querying Ethereum prices?
It would seem that currency_pair = 'BTC-USD'
could be changed to something akin to currency_pair = 'ETH-USD'
although this has no effect.
I would expect that the API simply doesn't support this, except that the official documentation explicitly states:
Get the total price to buy one bitcoin or ether
I can work around this somewhat by using the quote='true'
flag in the buy/sell request. This however only works moving forward, I would like historical data.
source code will always be your friend.
We can see that both functions call the same api endpoint. We see that
get_spot_price
supports thecurrency_pair
argument and passes it as part of the api call. On the other handget_historic_prices
does not.I wonder what would happen if it did. Let's try it:
Success!
I'll sent a PR their way. but for now you can use my code snippet.
PR submitted
I tried this and had the problem that using a 'currency_pair' parameter together with the 'historic' parameter will produce a history with 1 second granularity for the past few days only.
I solved this by using the GDAX client API instead, together with the GDAX Python client:
Install GDAX Python client:
Then you can use the public API part even without having a GDAX account:
To get a list of available products (cryptocurrency / FIAT currency pairs), use
and scan for the id entries.
Something worked for me with a similar problem calling exchange rates. Try changing the params in
from
to