Last active
December 16, 2015 04:58
-
-
Save LuRsT/5380592 to your computer and use it in GitHub Desktop.
Getting bitcoin prices info in the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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