在VB.NET中实现bittrex API

时间:2018-01-27 11:30:00

标签: vb.net rest api

根据Bittrex API Docs,它表示他们使用标准的HMAC-SHA512签名。将apikey和nonce附加到您的请求并计算HMAC哈希并将其包含在apisign标头下。注意:nonce目前不受尊重,但稍后会强制执行。

$apikey='xxx';
$apisecret='xxx';
$nonce=time();
$uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce;
$sign=hash_hmac('sha512',$uri,$apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);

弃用     请求:     https://bittrex.com/api/v1.1/account/getbalances?apikey=apikey

所以要在vb.net中实现这个,我试过以下:

Dim nonce = DateTime.Now.ToString()
        Dim apiurl = "https://bittrex.com/api/v1.1/account/getbalances?apikey=" + "apikey" + nonce
        sign = HashString(apiurl, "apisecret")
        Dim request As WebRequest
        request = WebRequest.Create(site)
        Dim response As WebResponse
        request.Method = "GET"
        request.Headers.Add("apisign:" + sign)
        response = request.GetResponse()

但得到错误:(

{"成功":假,"消息":" NONCE_NOT_PROVIDED""导致":空}

1 个答案:

答案 0 :(得分:0)

    Dim nonce = DateTime.Now.Ticks.ToString
       Dim apiurl = "https://bittrex.com/api/v1.1/account/getbalances?apikey=" + "ApiKey" + "&nonce=" + nonce
        sign = HashString(apiurl, "apisecret")
        Dim request As WebRequest
        request = WebRequest.Create(site)
        Dim response As WebResponse
        request.Method = "GET"
        request.Headers.Add("apisign:" + sign)
        response = request.GetResponse()