In this chapter, we will continue to develop the cryptocurrency application by retrieving a number of top coins by their total volume across all markets in the last 24 hours.
We will perform these steps:
- Create a button which will call the search coin function to retrieve the above mentioned data.
- Create the search coin function to retrieve and to display the market data.
# get top 100 coins by their total volume across all markets in the last 24 hours action_coin_volume = tk.Button(selectorFrame, text="Trade Volume", command=search_coin, state=DISABLED) # button used to get the top currency/cryptocurrency pair data action_coin_volume.pack(side=LEFT)
def search_coin(): # display all market data of the currency/cryptocurrency pair sell_buy = '' try: currency_symbol = based.get() # get the currency symbol url = "https://min-api.cryptocompare.com/data/top/totalvolfull" data = {'tsym': currency_symbol, 'limit': 100} r = requests.get(url, params=data) exchange_rate_s = json.loads(json.dumps(r.json())) except: print("An exception occurred") count = 0 # used to control new line for each symbol for value in exchange_rate_s['Data']: # populate exchange rate string and the currency tuple for key, value1 in value.items(): for key2, value2 in value1.items(): if (type(value2) == dict): for key3, value3 in value2.items(): if (key3 == "IMAGEURL"): continue sell_buy += str(key3) + " : " + str(value3) + "\n" count += 1 if count == 2: sell_buy += "\n" count = 0 text_widget.delete('1.0', END) # clear all those previous text first s.set(sell_buy) text_widget.insert(INSERT, s.get()) # populate the text widget with new exchange rate data
The above function will retrieve the market data of the top 100

Below are the steps to display those data:
- Click on the Load data button to load the top currencies data to the currency’s combo box.
- Select the currency which you wish to compare from the combo box, in this example we select EURO.
- Click on the trade volume button to display the
If you have missed out the previous chapter don’t forget to read them because the code in this chapter is interrelated with the previous one.
Please follow and like us: