I try to request to yobit API wthin R. To get access to some of the methods you need to complete authentication:
Each Trade API request should pass authentication. Authentication is fulfilled by sending the following HTTP-titles:
Key - API-key, example: FAF816D16FFDFBD1D46EEF5D5B10D8A2
Sign - digital signature, POST-parameters (?param0=val0 & ...& nonce=1) signed by secret key through HMAC-SHA512
Parameter nonce (1 minimum to 2147483646 maximum) in succeeding request should exceed that in the previous one. To null nonce it is necessary to generate new key.
My code :
nonce=1
API_KEY = "0B02AD5AF57854184D68D3D1D4D980F9"
API_SECRET = "89b20f882220b5dc6feeb33253c25ba3"
Body=paste('method=getInfo&nonce=',nonce, sep="")
sign = hmac(API_SECRET, Body, algo="sha512")
title=add_headers('Content-type'='application/x-www-form-urlencoded', Key = API_KEY, Sign = sign)
rep=POST('https://yobit.net/tapi', body=Body, headers=title, encode='form')
nonce=nonce+1
Response from server:
"{\"success\":0,\"error\":\"invalid key, sign, method or nonce\"}"
Thanks for help!