Files
py-ticker/cmc.py
T
2017-04-25 20:20:24 -07:00

19 lines
479 B
Python

import requests
cmcurl = 'https://api.coinmarketcap.com/v1/ticker?limit=10'
def getcmc():
ticker_string = ''
try:
r = requests.get('https://api.coinmarketcap.com/v1/ticker?limit=10')
j = r.json()
with open('cachedCMC.txt', 'w') as f:
f.write(r.text)
except:
print("Failed to get CMC via API")
with open('cachedCMC.txt', 'r') as f:
j = f.read().json()
# for i in j:
# print(i)
return j