krijnsent / crypto_vba

An Excel/VBA project to communicate with various cryptocurrency exchanges APIs
MIT License
157 stars 54 forks source link

HitBTC API v2 #16

Closed theMoe closed 6 years ago

theMoe commented 6 years ago

I saw you added HitBTC API v1. Do you think you could update it to v2?

https://api.hitbtc.com/

krijnsent commented 6 years ago

Hi Moe, I'll give it a try, have the same on my wishlist for Bittrex. I did try it a little, but bumped into some trouble, that's why I preferred a working v1 over a non functional v2. It's now on my to-do. Thanks for all your feedback, what are you building with my code?

theMoe commented 6 years ago

Thanks! I track my coins with it - obviously - in Excel 😉. And take a look on it, if I update APIs for an iOS app.

Do you have an idea just to check the API- keys if they are valid? Or should I just send a balance request or something similar?

krijnsent commented 6 years ago

To check the API keys, I would indeed use any of the Private commands like Balance. There are no specific commands to just check the API keys and only the other party (HitBTC in this example) can tell you whether they are valid or not.

antre77 commented 6 years ago

Dear krijnsent, Could you finish the work on version 2.0 if possible. I would like to use HitBTС as the main exchange.

krijnsent commented 6 years ago

It took quite some fiddling, but finally found a post that helped me solve this. I created new functions for the v2 API. Could you please check them and close this issue if it works?

antre77 commented 6 years ago

Dear krijnsent, thank you very much for your job. All that's needed works great.

I corrected a little code: TradeApiSite = "https://api.hitbtc.com" urlPath = "/api/2/" & Method Url = TradeApiSite & urlPath ' Instantiate a WinHttpRequest object and open it Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") objHTTP.Open HTTPMethod, Url, False objHTTP.setRequestHeader "accept", "application/json" objHTTP.setRequestHeader "authorization", "Basic " & Base64Encode(apikey & ":" & secretkey) objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send MethodOptions objHTTP.WaitForResponse PrivateHitBTC2 = objHTTP.ResponseText Set objHTTP = Nothing

according to the HITBTC swarger's answer: curl -X POST "https://api.hitbtc.com/api/2/order" -H "accept: application/json" -H "authorization: Basic YjRkMjRhN4NjVmZmYyMDI2YmFjYzMWVmZDdlNTQ6NmVmOTJjN4MjE0NzkwNDlkMmExMGY1ODFhMzRjZmU=" -H "Content-Type: application/x-www-form-urlencoded" -d "clientOrderId=324355444&symbol=...BTC&side=sell&type=limit&timeInForce=GTC&quantity=1&price=0.00"

Obviously, you will find the best solution

Best regards Andrey

krijnsent commented 6 years ago

Was trying to see what you changed, but it's the headers. Will change them in my code and update that.