Skip to content

Instantly share code, notes, and snippets.

@KolevDarko
Created February 13, 2019 09:33
Show Gist options
  • Save KolevDarko/4c891642b7be4d6485f54fe845f19653 to your computer and use it in GitHub Desktop.
Save KolevDarko/4c891642b7be4d6485f54fe845f19653 to your computer and use it in GitHub Desktop.
BitcoinAverage authentication
import hashlib
import hmac
import requests
import time
secret_key = 'enter your secret key'
public_key = 'enter your public key'
timestamp = int(time.time())
payload = '{}.{}'.format(timestamp, public_key)
hex_hash = hmac.new(secret_key.encode(), msg=payload.encode(), digestmod=hashlib.sha256).hexdigest()
signature = '{}.{}'.format(payload, hex_hash)
url = 'https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD'
headers = {'X-Signature': signature}
result = requests.get(url=url, headers=headers)
print(result.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment