-1

I hope someone could help me in this.

Following this official doc from FTX: https://docs.ftx.com/#request-historical-balances-and-positions-snapshot I'm continue to get this error: {'success': False, 'error': 'Missing parameter accounts', 'errorCode': 'parameter_missing'}

The code was ok and getting all the response from the other API call until I tested the the one above and I had to add the parameters, those are not working :-(

Here is my code:

import requests
from requests import Request, Session
import time
import hmac
import json

s = requests.Session() 
url = "https://ftx.com/api/historical_balances/requests"
ts = int(time.time() * 1000) 
tsN = int(time.time())
          
params = {
    "accounts": ["main","subaccounts"],
    "endTime": tsN,
}

request = requests.Request("POST", url, params=params)
prepared = request.prepare()
signature_payload = f'{ts}{prepared.method}{prepared.path_url}'.encode()

if prepared.body:
    signature_payload += prepared.body
  
signature = hmac.new('MYSECRET'.encode(), signature_payload, 'sha256').hexdigest()

request.headers = {
        'FTX-KEY': 'MYKEY',
        'FTX-SIGN': signature,
        'FTX-TS': str(ts),
    }

r = s.send(request.prepare()) 
r.json()
print('Output Json :',r.json())

Do you have any suggestion please? I'm getting crazy with this... Thanks!!

Ray Smith
  • 3
  • 2
  • the problem should be here `"accounts": ["main","subaccounts"]` it says paramenter accounts is missing (=wasn't sent) – Dmitriy Neledva Oct 24 '22 at 16:15
  • 1
    Duplicate [Difference between "data" and "params" in Python requests?](https://stackoverflow.com/questions/24535920/difference-between-data-and-params-in-python-requests) – esqew Oct 24 '22 at 16:45

1 Answers1

-1

Try switching request = requests.Request("POST", url, params=params) to request = requests.Request("POST", url, data=params) or request = requests.Request("POST", url, json=params), because I believe they want you to send them accounts and endTime as body of request, not as url parameters.

Igor Hwang
  • 72
  • 7