Post
Topic
Board Development & Technical Discussion
Re: How to import account balance to an excel sheet
by
BTC Turkiye
on 18/04/2018, 05:10:44 UTC
I have that already but couldnt figure out how and where to enter the details there. Because the API I get from my account is not a link. It`s a 50 digit code and there is a secret also.
If you know how to do it, could you please explain me?
What you have is not the "API"... what you have is the "API Key"... you call the API via a HTTP POST call using a URL.

For instance, here is the API documentation for Poloniex... they have both Public and Private APIs...

Public example: https://poloniex.com/public?command=returnTicker

Their Private API is quite different:
All calls to the trading API are sent via HTTP POST to https://poloniex.com/tradingApi and must contain the following headers:

Key - Your API key.
Sign - The query's POST data signed by your key's "secret" according to the HMAC-SHA512 method.
Additionally, all queries must include a "nonce" POST parameter. The nonce parameter is an integer which must always be greater than the previous nonce used.

All responses from the trading API are in JSON format. In the event of an error, the response will always be of the following format:

{"error":""}

There are several methods accepted by the trading API, each of which is specified by the "command" POST parameter:

So you need to setup a data source in Excel that creates the HTTP POST call, feeding in a "Key" parameter (ie. your 50 digit code), the "command" parameter (which are specified in the list on that page) the "nonce" value and then the "Sign" parameter which involves creating an HMAC-SHA512 of all the "POST" parameter data you've just created. Obviously, all the different exchanges use slightly different APIs but in general work on a similar process.

This guy was doing something similar with limited success: https://www.reddit.com/r/excel/comments/2ex0vh/http_post_api_request_using_power_query/
Possibly the same guy: https://www.mrexcel.com/forum/general-excel-discussion-other-questions/745134-web-api-access-sha-512-authentication.html
This link shows some of the API specific stuff: https://www.howtoexcel.org/power-query/how-to-access-a-json-api-with-power-query/

I think the issue will be generating the HMAC-512 that a lot of the exchanges require... Excel doesn't handle that stuff natively... and will require some VBA coding etc.

It might actually be easier to execute a python script to extract the data from the Exchange API and dump it out to a JSON file and then just read the JSON file into the Excel sheet, seeing as there are numerous python scripts that already exist for most of the popular exchanges.

Thank you very much for the detailed answer. Awesome help!

I`m looking for the binance account info so I checked out their api doc information on their github page. There`s really good info there but it doesnt say anything about how to import it to excel. I shouldn`t need to write a code to import the data. Because when I need to import something from a public api, I just enter the link and it gets the data.

I`m already using power query and that`s how i connected to public apis but I just dont know how to do it for private apis. I`m not good with coding so I was trying so hard to avoid it and just import the info somewhere then see the data on the sheet.

I`m sure you already understand what I`m looking to accomplish but Just to give you an example of what I need, Check out this guys excel sheet.

https://www.youtube.com/watch?v=kPLCsKAG57g