· 4 years ago · Aug 05, 2021, 03:32 PM
1import requests
2import os
3
4url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'
5params = {
6 'start':'1',
7 'limit':'100',
8 'convert':'USD'
9}
10headers = {
11 'Accepts': 'application/json',
12 'X-CMC_PRO_API_KEY': 'Insert CoinMarketCap API key here'
13}
14json = requests.get(url, params=params, headers=headers).json()
15
16print(json)
17os.system('clear')
18
19coins = json['data']
20
21for x in coins:
22 print('\033[1m' + x['symbol'] + '\033[0m','Price:', x['quote']['USD']['price'],',', '24hr Volume:', x['quote']['USD']['volume_24h'],',', 'Marketcap:', x['quote']['USD']['market_cap'],',','Max Supply:', x['max_supply'],',', 'Circ. Supply:', x['circulating_supply'])