I have played around a lot and tried to have then found some on the internet which partly also works well, but i've got a problem.
It's about the Api Bitfinex.com, and although I would like to retrieve via the Api the "last trade" or by trading.
Link: bitfinex.com/pages/api
In the method: GET, with api_path = "/ v1/symbols", it works.
But if I used something else it stops working.
Error: The remote server returned an error: (400) Bad Request.
sry for the english
anybody can help me / us ?
VB.NET-Quellcode
Public Shared api_url As String = "https://api.bitfinex.com/"
Public Shared api_key As String = "CodeCodeCode"
Public Shared api_secret As String ="CodeCodeCode"
Public Shared api_path As String = "/v1/symbols"
'Public Shared api_path As String = "/v1/account_infos"
Public Function check_balance()
Dim payLoadobject As New PayLoad()
Dim MySerializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim payloadJson As String = MySerializer.Serialize(payLoadobject)
Dim payload As String = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(payloadJson))
Dim encoding As New System.Text.ASCIIEncoding()
Dim getmessageBytes As Byte() = encoding.GetBytes(payload)
Dim secretByte As Byte() = encoding.GetBytes(api_secret)
Dim gethmacsha384 As New HMACSHA384(secretByte)
Dim hashmessage As Byte() = gethmacsha384.ComputeHash(getmessageBytes)
Dim finalString As New StringBuilder()
For i As Integer = 0 To hashmessage.Length - 1
finalString.Append(hashmessage(i).ToString("X2"))
Next
Dim SIGNATURE As String = finalString.ToString()
Dim request As HttpWebRequest
Dim nurl As String = api_url + api_path
Dim address As Uri = New Uri(nurl)
request = DirectCast(WebRequest.Create(address), HttpWebRequest)
request.Accept = True
request.Method = "GET" 'POST or GET
request.Headers("X-BFX-APIKEY") = api_key
request.Headers("X-BFX-PAYLOAD") = payload
request.Headers("X-BFX-SIGNATURE") = SIGNATURE
request.AllowAutoRedirect = True
request.AllowWriteStreamBuffering = True
request.KeepAlive = True
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader = Nothing
Dim result As String = Nothing
Try
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
result = reader.ReadToEnd()
Catch ex As Exception
Return ex.Message.ToString()
Finally
If Not response Is Nothing Then response.Close()
End Try
Return result
End Function
Public Class coptions
Public hostname As String = "https://api.bitfinex.com/"
Public port As String = "443"
Public path As String
Public method As String = "GET" 'POST OR GET
End Class
Public Class PayLoad
Public request As String = api_path
Public nonce As String = Convert.ToInt64((DateTime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds)
Public options As New coptions
End Class