Skip to content

Instantly share code, notes, and snippets.

@mkaz mkaz/btc.py
Created Feb 25, 2019

Embed
What would you like to do?
Script to fetch current bitcoin price
#!/usr/bin/env python3
""" Current Bitcoin price """
import requests
import json
import sys
apiurl = 'https://api.coindesk.com/v1/bpi/currentprice.json'
response = requests.get(apiurl)
data = response.json()
price = data["bpi"]["USD"]["rate"]
price = price.replace(",", "")
price = float(price)
print("{:,.0f}".format(price))
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.