我正在尝试使用 R 向 Kucoin 交易所发出 API 请求。我当前的代码如下。我无法为 API 调用获取签名和密码。有什么想法吗?谢谢。
api_key <- "my_api_key"
api_secret <- "my_api_secret"
api_passphrase <- "my_api_passphrase"
url <- 'https://api.kucoin.com/api/v1/accounts'
now <- as.numeric(Sys.time()) * 1000
str_to_sign <- paste0(as.character(now), 'GET', '/api/v1/accounts')
signature <- base64.b64encode(
hmac(api_secret.encode('utf-8'),
str_to_sign.encode('utf-8'),
hashlib.sha256).digest())
passphrase <- base64.b64encode(
hmac.new(api_secret.encode('utf-8'),
api_passphrase.encode('utf-8'),
hashlib.sha256).digest())
headers = {
"KC-API-SIGN": signature,
"KC-API-TIMESTAMP": as.character(now),
"KC-API-KEY": api_key,
"KC-API-PASSPHRASE": passphrase,
"KC-API-KEY-VERSION": "2"
}
response <- request('get', url, headers=headers)