Post
Topic
Board Development & Technical Discussion
Merits 2 from 1 user
Re: How to import account balance to an excel sheet
by
HCP
on 18/04/2018, 05:00:32 UTC
⭐ Merited by ETFbitcoin (2)
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.