source code will always be your friend.
def get_spot_price(self, **params):
"""https://developers.coinbase.com/api/v2#get-spot-price"""
if 'currency_pair' in params:
currency_pair = params['currency_pair']
else:
currency_pair = 'BTC-USD'
response = self._get('v2', 'prices', currency_pair, 'spot', data=params)
return self._make_api_object(response, APIObject)
def get_historic_prices(self, **params):
"""https://developers.coinbase.com/api/v2#get-historic-prices"""
response = self._get('v2', 'prices', 'historic', data=params)
return self._make_api_object(response, APIObject)
We can see that both functions call the same api endpoint. We see that get_spot_price
supports the currency_pair
argument and passes it as part of the api call. On the other hand get_historic_prices
does not.
I wonder what would happen if it did. Let's try it:
from coinbase.wallet.client import Client
from coinbase.wallet.model import APIObject
client = Client(api_key, api_secret)
client._make_api_object(client._get('v2', 'prices', 'ETH-USD', 'historic'), APIObject)
<APIObject @ 0x10dd04938> {
"currency": "USD",
"prices": [
{
"price": "52.60",
"time": "2017-03-30T17:03:48Z"
},
{
"price": "52.60",
"time": "2017-03-30T17:03:38Z"
},
{
"price": "52.54",
"time": "2017-03-30T17:03:28Z"
},
{
"price": "52.54",
"time": "2017-03-30T17:03:18Z"
},
{
"price": "52.54",
"time": "2017-03-30T17:03:08Z"
},
{
"price": "52.53",
"time": "2017-03-30T17:02:58Z"
},
{
"price": "52.53",
"time": "2017-03-30T17:02:48Z"
},
{
"price": "52.53",
"time": "2017-03-30T17:02:38Z"
},
{
"price": "52.53",
"time": "2017-03-30T17:02:28Z"
},
.....
Success!
I'll sent a PR their way. but for now you can use my code snippet.
PR submitted