我想通过Python连接到v2 Bitfinex REST API,但我一直收到错误:
error 10100 apikey: invalid
然而,当我对v1使用相同的键时,一切正常。这是我的Python代码:
class MyTradeClient:
def __init__(self):
self.URL = "{0:s}://{1:s}/{2:s}".format(PROTOCOL, HOST, VERSION)
self.KEY = public
self.SECRET = secret
@property
def _nonce(self):
return str(int(time.time() * 100000))
def _sign_payload(self, payload):
j = json.dumps(payload)
data = base64.standard_b64encode(j.encode('utf8'))
h = hmac.new(self.SECRET.encode('utf8'), data, hashlib.sha384)
signature = h.hexdigest()
return {
"X-BFX-APIKEY": self.KEY,
"X-BFX-SIGNATURE": signature,
"X-BFX-PAYLOAD": data
}
def wallets(self):
payload = {
"request": "/v2/auth/r/wallets",
#"options": {"autoOpen": False}, # READ IT SOMEWHERE ON THE INTERNET, NOT SURE OF THE MEANING
"nonce": self._nonce}
signed_payload = self._sign_payload(payload)
r = requests.post(self.URL + "/auth/r/wallets", headers=signed_payload, verify=True)
if r.status_code == 200:
return r.json()
else:
print('error, status_code = ', r.status_code)
print(r.text)
return ''
有人知道如何解决这个问题吗?
答案 0 :(得分:-1)
你的标题错了:
“bfx-nonce”:nonce,“bfx-apikey”:self.api,“bfx-signature”:签名