Created
December 21, 2020 14:54
-
-
Save counterbeing/33615298c71a10e4c843e40877edcd52 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() | |
) | |
headers = { | |
"KC-API-SIGN": signature, | |
"KC-API-TIMESTAMP": str(now), | |
"KC-API-KEY": kucoin_key, | |
"KC-API-PASSPHRASE": kucoin_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