Skip to content

Instantly share code, notes, and snippets.

@iannase
Last active December 9, 2019 21:42
Show Gist options
  • Save iannase/7fa72a46e4c219d99651cbde4a059f25 to your computer and use it in GitHub Desktop.
Save iannase/7fa72a46e4c219d99651cbde4a059f25 to your computer and use it in GitHub Desktop.
Not limited to 100
import requests
import json
while True:
# base URLs
globalURL = "https://api.coinmarketcap.com/v1/global/"
tickerURL = "https://api.coinmarketcap.com/v1/ticker/"
unlimited = "?limit=0"
# get data from globalURL
request = requests.get(globalURL)
data = request.json()
globalMarketCap = data['total_market_cap_usd']
# menu
print()
print("Welcome to the CoinMarketCap Explorer!")
print("Global cap of all cryptocurrencies: $" + str(globalMarketCap))
print("Enter 'all' or 'name of crypto' (i.e. bitcoin) to see the name of the top 100 currencies or a specific currency")
print()
choice = input("Your choice: ")
if choice == "all":
request = requests.get(tickerURL + unlimited)
data = request.json()
for x in data:
ticker = x['symbol']
price = x['price_usd']
if ticker is not None and price is not None:
print(ticker + ":\t\t$" + price)
print()
else:
choice = choice.replace(' ', '-')
tickerURL += choice + '/'
request = requests.get(tickerURL)
data = request.json()
ticker = data[0]['symbol']
price = data[0]['price_usd']
print(ticker + ":\t\t$" + price)
print()
choice2 = input("Again? (y/n): ")
if choice2 == "y":
continue
if choice2 == "n":
break
@tiboine
Copy link

tiboine commented Apr 30, 2018

Cool :)

@ProgMmgGhoneim
Copy link

i need to get sell price and buy price

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment