Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Error: status code 400005 on deposits endpoint but 200000 on balances endpoint. #435

Open
ghost opened this issue Jan 11, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Jan 11, 2023

Hey everyone, I've been trying to access /api/v1/deposits endpoint to retrieve the data for my account deposits, but keep getting Invalid KC-API-SIGN on the response object.

The weird part is that when I access the balances endpoint /api/v1/accounts, inside the same script I ran to fetch the deposits, it returns me the information desired with a 200 code. Are there differences between the endpoints in terms of siging the request?

The code bellow is how I'm signing the request, I believe it's correct, specially since I can retrieve the balances information.

def _nonce(self):
        return int(time.time() * 1000)    

def _headers(self, path, body= ""):
        str_to_sign = str(self._nonce()) + 'GET' + path + body
        sign = base64.b64encode(
                hmac.new(self.api_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256).digest())

        headers = {
                "KC-API-SIGN": sign,
                "KC-API-TIMESTAMP": str(self._nonce()),
                "KC-API-KEY": self.api_key,
                "KC-API-PASSPHRASE": self.passphrase,
                "Content-Type": "application/json"
        }
        logging.info("Headers:")
        logging.info(headers)

        return headers

def _req(self, path, params={}):
        url = self.BASE_URL + path
        response = requests.request('get', url, headers=self._headers(path = path), params=params)
        return response

The request to the deposits endpoint is shown bellow:

def get_successful_deposits(self, currency, timespan):
        params= {
            'currency': currency,
            'startAt': timespan['startAt'],
            'endAt': timespan['endAt'],
            'status': 'SUCCESS'
        }
        response= self._req(path= '/api/v1/deposits', params= params)
        return response.json()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants