I managed to create hitbtc api caller
Protected Overrides Function getJsonPrivate(method As String, otherParameters() As Tuple(Of String, String)) As String
Dim content = "/api/1/trading/" + method + "?nonce=" + ExchangesClass.getNonce().ToString + "&apikey=" + _apiKey1
Dim postar = otherParameters.ToList.ConvertAll(Function(x) x.Item1 + "=" + x.Item2)
Dim post = String.Join("&", postar) ' "id=4987469178"
Dim sighash = computeSig(content) '"https://api.hitbtc.com/api/1/trading/cancel_order?nonce=36411402&apikey=13a2492a3f0631d657ecd510ceacc509"
Dim url = "https://api.hitbtc.com" + content
Dim response = CookieAwareWebClient.downloadString1(url, post, {Tuple.Create("X-Signature", sighash)})
'Dim response1 = CookieAwareWebClient.downloadString1("https://api.hitbtc.com" + content + "&" + post, "", {Tuple.Create("X-Signature", sighash)})
Return response
End Function
It works for their get requests. I can get balances. I can get active orders. But to cancel orders, for example, I would need post requests.
For example, doing _jsonResult = getJsonPrivate("balance", {})
would work just fine and I would get:
"{""balance"":[{""currency_code"":""1ST"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""8BT"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""ADX"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AE"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AEON"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AIR"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AMB"",""cash"":""0"",""reserved"":""0""},{""currency_code"":""AMP"",""cash"":""0"",""reserved"":""0""},
response simply result in zero.
I tried to see PhP code sample here
https://github.com/hitbtc-com/hitbtc-api/blob/master/APIv1.md#examples
And the PHP sample here
https://gist.github.com/hitbtc-com/10885873
It's still strange.
Am I supposed to computeSig based on the post requests too added to URI? With no underlying &
Has anyone C# or vb.net sample? I think it'll require only one small change to the code so I can do cancel_order method instead of just get
The content of downloadstring1 is the following. So it basically do post or get based on whether post argument is empty string or not. I think that's pretty obvious.
Public Shared Function downloadString1(url As String, post As String, otherHeaders As Tuple(Of String, String)()) As String
Dim wc = New CookieAwareWebClient()
For Each oh In otherHeaders
wc.Headers.Add(oh.Item1, oh.Item2)
Next
Dim response = String.Empty
Try
If post = "" Then
response = wc.DownloadString(url)
Else
response = wc.UploadString(url, post)
End If
Catch ex As Exception
Dim a = 1
End Try
Return response
End Function