Last active
December 13, 2017 00:20
-
-
Save saifazmi/14da024b891cf9f477d39036e1d05d4d to your computer and use it in GitHub Desktop.
A simple Bitcoin price checker using coindesks api
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
#!/usr/bin/python | |
import json | |
import requests | |
URL = "https://api.coindesk.com/v1/bpi/currentprice.json" | |
response = requests.get(URL) | |
jsonResponse = json.loads(response.text) | |
updated = jsonResponse.get("time").get("updateduk") | |
valBTC = jsonResponse.get("bpi") | |
rateUSD = valBTC.get("USD").get("rate") | |
rateGBP = valBTC.get("GBP").get("rate") | |
rateEUR = valBTC.get("EUR").get("rate") | |
disclaimer = jsonResponse.get("disclaimer") | |
print(""" | |
// Bitcoin price value | |
// Updated: {updated} | |
> USD: {rateUSD} | |
> GBP: {rateGBP} | |
> EUR: {rateEUR} | |
// Disclaimer: {disclaimer} | |
""".format(updated=updated, | |
rateUSD=rateUSD, | |
rateGBP=rateGBP, | |
rateEUR=rateEUR, | |
disclaimer=disclaimer)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment