Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import json
import base64
import hashlib
import hmac
def _prepare_headers(payload, api_key, api_secret):
# payload = parameters-dictionary -> JSON encode -> base64
payload_json = json.dumps(payload)
payload_encoded = base64.encodestring(payload_json)
# signature = HMAC-SHA384(payload, api-secret) as hexadecimal
encryptor =, api_secret, hashlib.sha384)
signature = encryptor.hexdigest()
# send (api-key, payload, signature)
headers = {"X-BFX-APIKEY" : api_key,
"X-BFX-PAYLOAD" : payload_encoded,
"X-BFX-SIGNATURE": signature
return headers
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.