简体   繁体   中英

How do I get Litecoin prices with Coinbase Python API?

client.get_spot_price(currency='EUR')

该行将给我当前的比特币价格,但是如何找到莱特币和以太坊价格?

You need to pass the correct currency_pair as seen in the docs

client.get_spot_price(currency_pair='LTC-EUR')

EDIT

This seems to be a bug noted on github . For a quick fix, you can modify the client.py file by chaning this function

def get_spot_price(self, **params):
    """https://developers.coinbase.com/api/v2#get-spot-price"""
    response = self._get('v2', 'prices','spot', data=params)
    return self._make_api_object(response, APIObject)

to this

def get_spot_price(self, **params):
    """https://developers.coinbase.com/api/v2#get-spot-price"""
    currency_pair = params['currency_pair']
    response = self._get('v2', 'prices', currency_pair,'spot', data=params)
    return self._make_api_object(response, APIObject)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM