I am trying to get the historical income data using the requests library. Everything works perfect without the limit parameter, but once I include the limit parameter I get a <Response [400]>
My code is as follows:
def fetch_balance_history(apikey, secret):
base_url = 'https://api.binance.com'
servertime = requests.get(f"{base_url}/api/v1/time")
servertimeobject = json.loads(servertime.text)
servertimeint = servertimeobject['serverTime']
params = urllib.parse.urlencode({
"timestamp" : servertimeint,
})
hashedsig = hmac.new(secret.encode('utf-8'), params.encode('utf-8'), hashlib.sha256).hexdigest()
account_history = requests.get(f'https://fapi.binance.com/fapi/v1/income',
params = {
# "limit" : 500,
"timestamp" : servertimeint,
"signature" : hashedsig,
},
headers = {
"X-MBX-APIKEY" : apikey,
}
)
data = fetch_balance_history(apiKey, secretKey)
print(data)
My problem is without the limit in the params, it works fine (it’s only showing 66 rows of data) but I need historical data from last month as well which it doesn’t show, can someone enlighten me on what’s the mistake I am making here. Thanks