Home > Software design >  Issue with FTX US API
Issue with FTX US API

Time:10-06

I have looked through the FTX API documentation found here: https://docs.ftx.us/#overview

And I've looked at the example code found in this repo: https://github.com/ftexchange/ftx/tree/master/rest

I can't get or post anything that requires Authentication. I am using the API key on my account that has 'full trade permissions', and when I look at print(request.headers) the headers look like they are in the right format.

Let me know if you need any more information, my code returns

Error Code: 400 Invalid API Key

            import time
            import hmac
            from requests import Request

            ts = int(time.time() * 1000)
            request = Request('GET', 'https://ftx/api/wallet/balances')
            prepared = request.prepare()
            signature_payload = f'{ts}{prepared.method}{prepared.path_url}'.encode()
            signature = hmac.new('API SECRET'.encode(), signature_payload, 'sha256').hexdigest()

            request.headers[f'FTXUS-KEY'] = API KEY'
            request.headers[f'FTXUS-SIGN'] = signature
            request.headers[f'FTXUS-TS'] = str(ts)

            res = requests.get('https://ftx/api/wallet/balances', headers=prepared.headers)
            r = res.json()

CodePudding user response:

I also got this error and It was a silly mistake.

I think you have FTX.US API Key and you are hitting on 'https://ftx/api/wallet/balances'. U should hit on 'https://ftx.us/api/wallet/balances' to get this working

  • Related