When I use the cg.get_coin_history_by_id('bitcoin', date='30-12-2017')
it seems to list the price compared to everything. I don't know how to make it just print one specific currency.
In coingecko, trying to get historical prices, but get the prices compared to every currencies
791 Views Asked by tirsot At
2
There are 2 best solutions below
0

It's not a .json it's a python dictionary. You can get the prices with the keys. For example if you want the price in US Dollars (USD):
>>> history = cg.get_coin_history_by_id(id='bitcoin', date="30-12-2017")
>>> price = history["market_data"]["current_price"]["usd"]
>>> price
output:
13620.3618741461
cg.get_coin_history_by_id
returns more than just price, it returns market cap, volume, etc... It isn't comparing the price to anything, it's just returning the data in multiple different currencies.If you want to access the price for a specific currency just reference it using the keys you see in the response. For example, to get the price of bitcoin on that day in Australian dollars, you would do it like this:
The structure of the json looks like this:
source: pycoingecko