Skip to content

Instantly share code, notes, and snippets.

@meany
Last active August 3, 2018 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meany/158c898745273e16074be7690b9b6455 to your computer and use it in GitHub Desktop.
Save meany/158c898745273e16074be7690b9b6455 to your computer and use it in GitHub Desktop.
CMC Banano lookup (temporary until listing)
# https://github.com/sterlingbeason/coinmarketcap-professional
from coinmarketcap_pro.client import Client
client = Client("<GUID>")
# query weight 10
# so like, only one call an hour maybe on the free version
response = client.request_api_endpoint("cryptocurrency/listings/latest", {'limit': 1000})
if response["status"]["error_code"] is 0:
# cache response
f = open('cmc.txt', 'w')
f.write(str(response))
f.close()
# inside !price logic
f = open('cmc.txt', 'r')
r = eval(f.read())
f.close()
# replace with calculated ban cap
cap = 7817437.18
i = 1
for coin in r['data']:
if coin['quote']['USD']['market_cap'] < cap:
# i = CMC rank
print i
break
else:
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment