HansSheller
New Member
- Joined
- Jun 11, 2018
- Messages
- 2
Hi,
I am building a program in Excel/VBA to execute operations in the trading platform CEX.io. I am using their API and it is working perfectly for any public call. However, when I need to use Private calls, I cannot manage to correctly send the parameters requested for the authorization. Every time I get the following response : "API key is missing.". Could anyone advise what I am doing wrong?
I thought it would be something about the JSON format in the body, but after trying many combinations I really have no idea what to do. I have succesfully created and activated the API key. The signature is hashed correctly, but it seems that I am not being able to even send any information in the body along with the call.
Thank you very much for the support.
Hans
Here Cex's API calls: https://cex.io/rest-api
Below my code:
---------------------------------------------------------
I am building a program in Excel/VBA to execute operations in the trading platform CEX.io. I am using their API and it is working perfectly for any public call. However, when I need to use Private calls, I cannot manage to correctly send the parameters requested for the authorization. Every time I get the following response : "API key is missing.". Could anyone advise what I am doing wrong?
I thought it would be something about the JSON format in the body, but after trying many combinations I really have no idea what to do. I have succesfully created and activated the API key. The signature is hashed correctly, but it seems that I am not being able to even send any information in the body along with the call.
Thank you very much for the support.
Hans
Here Cex's API calls: https://cex.io/rest-api
Below my code:
---------------------------------------------------------
Code:
Sub get_balance()
Dim cexresponse As Object
Dim scriptControl As Object
Dim api_key, api_signature, api_secret, api_body As String
Dim api_nonce As Double
api_key = "myprivatkey" 'replace for real key
api_secret = "mysecret" 'replace for real secret
api_nonce = DateDiff("s", "01/01/1970 00:00:00", Now())
api_signature = HMAC_encode(api_nonce & api_key, api_secret)
api_body = "{""key"": " & api_key & ",""signature"":" & api_signature & ",""nonce"":" & api_nonce & "}"
Set scriptControl = CreateObject("MSScriptControl.ScriptControl")
scriptControl.Language = "JScript"
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", "https://cex.io/api/balance/", False
.Send (api_body)
Set cexresponse = scriptControl.Eval("(" + .ResponseText + ")")
.abort
End With
End Sub
Last edited by a moderator: