GET /fapi/v1/userTrades does not return trades

When using GET /fapi/v1/userTrades with the following parameters:

  • startTime: 1726476485757 (timestamp of 3 months ago)
  • endTime: null
  • fromId: null

I get 0 results from the api. But if I set the same parameters but set startTime with a timestamp equals to 7 days ago, it suddenly returns me some results. The behavior should be the same than for the SPOT endpoint no? When querying the SPOT endpoint I don’t have any difficulty getting results from years ago just by setting the startTime parameters (so letting endTime and fromId null).

For info I use the testnet as I can’t use Binance Futures because it’s restricted in my country.

Hey,
Here is some information provided in the documentation for this endpoint:

If startTime and endTime are both not sent, then the last 7 days data will be returned.
The time between startTime and endTime cannot be longer than 7 days.
The parameter fromId cannot be sent with startTime or endTime.
Only support querying trade in the past 6 months

Hi,

thanks for your reply but unfortunately the documentation is not useful here.
The thing is I only pass startTime as parameter for my first API call. Once I know the user trade id I use the fromId parameter.
This works correctly for SPOT endpoint but not for the futures one.
Querying 7 days ranges from the first trade to today for each symbol is so slow that it’s not an option.

If startTime is more than 7 days ago it does not return any trade. That’s the issue here.

Futures and Spot are different, so you need to account for the limitations specific to Futures.
As mentioned in my previous post, it’s not possible to send only the startTime. You must also provide an endTime that is within 7 days of the startTime.

So the only way to retrieves all the trades from the past 6 months is to iterate through each symbol and then query from 6 months to now 7 days by 7 days? By doing like this it takes way too long to just query trades. This is something the doc should be mentioning.
Getting user trades with the Binance API is really frustrating.
At least on the SPOT by just passing the startTime parameter I can get the first trade ever of the user and then iterate through all trades with the fromId param. Anyway thank you for your time!

You can also retrieve the first ID from 6 months ago by making a request with a startTime and an endTime that is within 7 days of the startTime. Once you have the ID, you only need to use it as fromId.

Yes that’s what I ended up doing and it works well, but it’s not optimized and takes several minutes to complete, but there’s no other choice so I’ll stick to that, thanks again :slight_smile: