Created
February 13, 2019 09:33
-
-
Save KolevDarko/4c891642b7be4d6485f54fe845f19653 to your computer and use it in GitHub Desktop.
BitcoinAverage authentication
This file contains hidden or 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 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