Created
December 20, 2020 20:08
-
-
Save counterbeing/bb5ff401b0b0bbd8558f572f7a9788ee to your computer and use it in GitHub Desktop.
This file contains 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 os | |
import time | |
import base64 | |
import hmac | |
import hashlib | |
import requests | |
kucoin_key = os.environ.get('KUCOIN_KEY') | |
kucoin_secret = os.environ.get('KUCOIN_SECRET') | |
kucoin_passphrase = os.environ.get('KUCOIN_PASSPHRASE') | |
url = 'https://openapi-sandbox.kucoin.com/api/v1/accounts' | |
now = int(time.time() * 1000) | |
str_to_sign = str(now) + 'GET' + '/api/v1/accounts' | |
signature = base64.b64encode( | |
hmac.new(kucoin_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256).digest()) | |
passphrase = base64.b64encode(hmac.new(kucoin_secret.encode('utf-8'), kucoin_passphrase.encode('utf-8'), hashlib.sha256).digest()) | |
headers = { | |
"KC-API-SIGN": signature, | |
"KC-API-TIMESTAMP": str(now), | |
"KC-API-KEY": kucoin_key, | |
"KC-API-PASSPHRASE": passphrase, | |
"KC-API-KEY-VERSION": "2" | |
} | |
response = requests.request('get', url, headers=headers) | |
print(response.status_code) | |
print(response.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment