Closed cgunnels closed 5 years ago
I believe this might also be due to the fact that a GET request with parameters returns the same error. I'm using their example:
api_secret = "api_secret"
api_passphrase = "api_passphrase"
url = 'https://openapi-sandbox.kucoin.com/api/v1/deposits'
now = int(time.time() * 1000)
str_to_sign = str(now) + 'GET' + '/api/v1/deposits?status=SUCCESS'
signature = base64.b64encode(
hmac.new(api_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": api_key,
"KC-API-PASSPHRASE": api_passphrase
}
response = requests.request('get', url, headers=headers)
print(response.status_code)
print(response.json())
If I remove the parameters I get a 200 ok response with some content.
Thanks @cgunnels this was related to get request signature generation.
In the _request
function only the request specific headers are generated. If you look at the _init_session
function it sets general headers for your session there.
Can you check if it is resolved in v2.0.2
Thanks! I'm away from my computer, but I will give it a test when I get a moment.
@cgunnels Did you manage to get this to work? i am still struggling on GET requests with params. same happens for fills etc.
@bsliran I believe it's fixed in v2.02+. It was an issue with the libraries signature generation.
I printed out the kwargs right before the request is sent to the exchange. It is missing required keys/values. This is what the kwargs are as of line 156 in client.py: KWARGS: {'timeout': 10, 'headers': {'KC-API-TIMESTAMP': '11111111111111', 'KC-API-SIGN': b'xxxxxxxxxxxxxxxxxxxxx'}, 'params': {'status': 'SUCCESS', 'startAt': '0', 'limit': 100}}
According to https://docs.kucoin.com/#creating-a-request all these values are required: KC-API-KEY KC-API-SIGN KC-API-TIMESTAMP KC-API-PASSPHRASE
It looks like the session headers aren't being utilized after Client instantiation.