man-c / pycoingecko

Python wrapper for the CoinGecko API
MIT License
1.04k stars 268 forks source link

Is there a way to use symbol to get data about a coin? #68

Open PetruIulian opened 2 years ago

PetruIulian commented 2 years ago

Hi, I'm trying to use a symbol in order to get data about a coin, for e.g. BTC using cg.get_price(ids='bitcoin') will work, but is there a way to do something like cg.get_price(ids = 'BTC')?

0xMimir commented 2 years ago

Yes there is, I will try to integrate it, we only need dict with every coins symbol as key and id as value then just return result of get_price, for example

{
    'BTC': 'bitcoin', 
    'ETH': 'ethereum',
    'XRP': 'ripple'
}

This is one way of doing, but it would need to updated every time new coin is added. Other is querying https://api.coingecko.com/api/v3/coins/list before and then finding item which matches symbol and take id from there and then get use that