kucoin-api-docs
kucoin-api-docs copied to clipboard
REST DELETE authorization
I am fairly new to python and am having issues with REST DELETE request. I get a 401 error for "Unauthorized -- Invalid API Key." I use the same auth function for the GET requests without issue. The code is below. Thank you very much.
def AUTH2(request):
api_key = kclient.API_KEY
api_secret = kclient.API_SECRET
api_passphrase = kclient.API_PASSPHRASE
url = kclient.API_URL+destination
now = int(time.time() * 1000)
str_to_sign = str(now) + request + destination
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
}
return headers
orderid=item['orderId'] destination='/api/v1/margin/lend/' print(requests.request('delete',kclient.API_URL+destination+orderid, headers=AUTH2('DELETE')))
Hi, there
Are you using the new api key which is shown as V2 version?