Filtering out useless data from Python Api -
i have written bot should print out current price of cryptocurrency, , used coinmarketcaps api this. however, if print out it's giving me of other useless data such volume, supply etc. don't need.
from coinmarketcap import market coinmarketcap = market() print(coinmarketcap.ticker('bitcoin', convert='usd'))
please guide me. causing problem?
edit: output i'm getting
[{'id': 'bitcoin', 'name': 'bitcoin', 'symbol': 'btc', 'rank': '1', 'price_usd': '2771.66', 'price_btc': '1.0', '24h_volume_usd': '1116730000.0', 'market_cap_usd': '45660983723.0', 'available_supply': '16474237.0', 'total_supply': '16474237.0', 'percent_change_1h': '-0.11', 'percent_change_24h': '7.18', 'percent_change_7d': '1.41', 'last_updated': '1501238672'}]
you should print out value need object (in case price
), not object itself, this:
from coinmarketcap import market coinmarketcap = market() price = coinmarketcap.ticker('btc', convert='usd') item in price: print(item['price_usd'])
Comments
Post a Comment