SPOT API | myTrades endpoints

Hello,

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

https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data
https://binance-docs.github.io/apidocs/spot/en/#query-enabled-isolated-margin-account-limit-user_data

Thanks,

João de Deus

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?

Hello, sure

I meaning if I need to get all pairs available on binance (Binance API Documentation) and then for each pair call the trade endpoint (Binance API Documentation)

Let’s imagine that binance supports 1k of pairs I will do a 1k of requests (or I’m thinking completely wrong).

The main goal is to get the trades from a binance account (API call) and my main question is:

  • can I get only the pairs that my account interact (eg: BTCEUR, ETHEUR) or I need to execute the request to all pairs (BTCEUR, BTCETH, BTCUSDT, …)

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 :frowning: that will take a lot of time (because the time between startTime and endTime can’t be longer than 24 hours).

Do you have other approach?

Thanks

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.