import requests
import calendar
import time


def coindeskticker(currency='USD'):
    """ get current bitcoin exchange rate from Coindesk """
    data = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json').json()
    dataprice = data['bpi'][currency]['rate']
    datatime = calendar.timegm(time.strptime(data['time']['updated'], "%b %d, %Y %H:%M:%S %Z"))
    return dataprice, datatime