Skip to content

Instantly share code, notes, and snippets.

@LuRsT
Last active December 16, 2015 04:58
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 LuRsT/5380592 to your computer and use it in GitHub Desktop.
Save LuRsT/5380592 to your computer and use it in GitHub Desktop.
Getting bitcoin prices info in the command line
import sys
import requests
def main(coin='USD'):
url = 'http://data.mtgox.com/api/2/BTCUSD/money/ticker'
if coin == 'EUR':
url = 'https://data.mtgox.com/api/2/BTCEUR/money/ticker'
r = requests.get(url)
data = r.json()['data']
print "%10s: %s" % ( 'Average', data['avg']['display_short'])
print "%10s: %s" % ( 'High', data['high']['display_short'])
print "%10s: %s" % ( 'Low', data['low']['display_short'])
if __name__ == "__main__":
if len(sys.argv) > 1:
main(sys.argv[1])
else:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment