python-kucoin icon indicating copy to clipboard operation
python-kucoin copied to clipboard

account balance [401 Response]

Open jumabora opened this issue 5 years ago • 0 comments

hi, I am trying to create a code in python to get the balance of my account, I use the Example for get balance of accounts in python on the api kucoin page, however when I run my code I get the following error: {'code': '400004', 'msg': 'Invalid KC-API-PASSPHRASE'}, but I'm sure my API-PASSPHRASE is fine. My code is:

import hmac import json import requests import time import base64 import hashlib kucoin_key= 'xxxxxxxxxxxxxxxxxxxxx' kucoin_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' kucoin_passphrase = 'xxxxxxxxxxxxxxx'

url = 'https://openapi-v2.kucoin.com/api/v1/accounts' kucoin_nonce = str(int(time.time() * 1000)) kucoin_signature = kucoin_nonce + 'GET' + '/api/v1/accounts' signature = base64.b64encode(hmac.new(kucoin_secret.encode('utf-8'), kucoin_signature.encode('utf-8'), hashlib.sha256).digest()) headers = {"KC-API-SIGN":signature, "KC-API-TIMESTAMP": kucoin_nonce, "KC-API-KEY": kucoin_key, "KC-API-PASSPHRASE": kucoin_passphrase} response = requests.request('get', url, headers=headers) print(response.status_code) print(response.json())

what is the problem?

tks!

jumabora avatar Feb 04 '20 22:02 jumabora