Is it possible to know which pairs I interact with and then use these pairs in the /api/v3/myTrades endpoint or do I always need to ask for all the pairs that Binance supports?
How did you handle this? It look so “expensive” iterate all pairs
Hey,
Could you clarify what you mean by ‘interact with’? Are you referring to interactions on the Binance platform? Additionally, when you asked ‘How did you handle this?’, could you provide more context?
According to the documentation, the GET /api/v3/myTrades endpoint returns ‘the trades for a specific account and symbol.’ The symbol parameter is mandatory, but there’s no option or separate endpoint to retrieve a list of the symbols you’ve traded.
However, with GET /api/v3/myTrades, you can request any eligible symbol on Binance. You don’t need to make a requests for each symbol if you know the ones you’ve traded.
If you don’t remember all the symbols you’ve traded, you can find the balances of the symbols you own using the following endpoint: Binance API Documentation.
Hiii, that’s a good approach but for example if I do a withdrawal the symbol will not be present on my balance and I will not retrieve the trades. So I think the only solution is get the trades for all pairs available on Binance that will take a lot of time (because the time between startTime and endTime can’t be longer than 24 hours).
In general: yes, you will have to try all trading pairs if you’re not keeping track of the ones being traded. It is a good idea to remember them on your side.
Also note than if a trading pair gets delisted, you will not be able to access the trades via /api/v3/myTrades, so it’s a good idea to keep your own records instead of completely relying on the API.
Historical trades are still available via transaction history, but it’s much less convenient to use.
startTime & endTime are not intended for pagination over long periods of time.
If you want to cover more than 24 hours, use startTime and endTime to fetch the first and last trade in the time interval, you need to learn the first and last trade ID. After that, use fromId to paginate through trades by trade ID until you fetch all the trades you need.