How to get complete Trade/Income History? (API)

I cant find a clear information about how to get the full history of everything that affected an account’s balance through the API.

What I mean is: I want a full list which, when all rows are added together, returns the current balance for spot, futures etc (in each coin of course).

Any help on this would be greatly appreciated.

PS: I realise this might not the possible through just one endpoint. I just tried to explain my question in the most simple way possible. Feel free to post a full list of required endpoints.

Impossible. Binance do not share some important information related to coin balance history.

I am currently trying to compile said list through a variety of API endpoints for a little Python project myself, and right now it seems pretty much impossible because of mainly two points:

  • You currently can’t get FIAT deposit or withdraw history through the corresponding endpoint (see this forum post), so from the start you don’t know the initial balance your trades are made with
  • It’s extremely hard/expensive to get all trades a user ever made. Fetching order history is only possible for each individual symbol (trading pair), not multiple at the same time. This leaves you with having to loop through every single symbol the user might have ever made a transaction with, which of course returns more zeroes than anything else and has a weight of 10 for every symbol, meaning it takes forever (see this forum post).

Additionally to these points, I am not quite sure how the API shows transfers from your Spot wallet to your Savings wallet or vice versa, especially when it comes to Locked Staking since this balance is impossible to request even directly (see this forum post).

Two endpoints you would definitely need (besides those listed above) would be the Dust Log for dust conversions and the Interest History for Binance Savings products and the Asset Dividend Record for… something else. Honestly, I can’t quite tell what the difference between the two is.

So all in all, I am pretty certain that with the current state the API is in, what we’re trying to achieve is as impossible as @tmm mentioned.
It would be nice if Binance took the criticism in the linked threads to heart and considerably improved their API when it comes to fetching historical data - this is extremely important for analytics and taxes and I am honestly disappointed by the API considering how good the other apps and services offered by Binance are.
I hope the API will be improved in the future to make such supposedly simple tasks possible, since other, smaller exchanges seem to be able to offer such endpoints without issues.

10 Likes

I’m also in need of that complete history, as I’m working on a script to get my full financial statement from Binance, with the (basic ?) goal of injecting that information into my accounting software.

And indeed, I also find the experience extremely frustrating : the data is spread throughout several API endpoints (which is acceptable), but some just cannot be obtained through the API currently. @Lutrix01 already mentionned several aspects, and you can add Large OTC Trades to the list (API for Large OTC trades).

But I’m starting to realize that the situation might be even worse than you think, let me explain.

I tried another strategy : exporting the full statement csv (the one you can only generate 4 times a month), along with the “Buy History” and the “Deposit History”, and trying to process that.
Again, this was a painful process because it doesn’t contain as much information as the API, for instance:

  • the fees appear as separate records, so if you want to associate it with the corresponding trade, you have to correlate several records…
  • … but the problem is, the file doesn’t have any kind of “id”
  • you could use the timestamp to correlate the records instead, but it’s not terribly reliable
  • the trade prices are not included, you have to compute them yourself… but again, you need to correlate the records first.

After some time I finally got to a point where I could start to work with a combination of the statement file and the API.
[Quick side note: I now use the statement to get my list of traded pairs, which narrows down the number of API calls I have to make]

But I’m still not to the point where I can obtain the same balances as what the web interface (or the balance in the /api/v3/account API) gives me.
When I compare the data I get from the statement and from the API, I can explain some differences (eg. data not available through the API), but I’m still trying to explain quite a few others.

All in all this is, again, a very frustrating exercise.

More than frustrating actually : a better word would be “concerning”, as I’m really not confortable with the idea of putting my money in a centralized institution, without any reliable means of getting at my financial data.

4 Likes

Many moving to FTX because of that. Cant do all this accounting by hand.

it sounded like a fair move

I’m looking for this thing as well.

It’s still like this?
Funy with the ftx move, but sheesh.

Just looped through all coins and realized dang it’s the same data being imported from every coin.

so this endpoint
/sapi/v1/capital/deposit/hisrec
using
coin STRING YES
seems pointless. Maybe I need to iterate through them and merge the data try and see what’s different if anything at each coin.

The other thing i kind of question:
startTime LONG NO Default: 90 days from current timestamp

So if you don’t imply a startTime, i guess it will only pull up to 90 days of data. Is there a way to pull all data. Guess I’m going to have to pull every so often and just merge it to a database. Like there’s work around, but why is it such a work around!?