import hashlibimport pytzimport hmacfrom time import timeimport urllibimport requestsimport datetimeclass BiteBtc: def __init__(self): self.api_key = b'LvC6D-OMpm2tc-KNpGR-KOxQFukC318D' self.secret_key = b'r40u3jrWUDMfhHyMNNpxbPwsDPnkAoeVMJTzUhlm3cHHUXjRHLKdeiAtiqCEudlz' def get_balance(self): url = 'https://bitebtc.com/api/v1/trading/balances' payload = { 'currencies': 'btc' } paybytes = urllib.parse.urlencode(payload).encode('utf8') ### sgt = pytz.timezone("Asia/Singapore") now = datetime.datetime.now() ts = now.astimezone(sgt).timestamp() ts = round(float(ts), 3) # mili-sec nonce = str(ts).replace(".", "") ### headers = { 'x-api-tonce': nonce, #str(int(time() * 1000)), 'x-api-key': self.api_key, 'x-api-signature': hmac.new(self.secret_key, paybytes, hashlib.sha512).hexdigest() } r = requests.post(url, headers=headers, data=paybytes) return r.json()bite=BiteBtc()print(bite.get_balance())
1 回答
慕田峪7331174
TA贡献1828条经验 获得超13个赞
您应该确保 API 在https://bitebtc.com/profile/keys 上“启用” 。默认情况下它是禁用的,我遇到了同样的问题,但修复了它。
添加回答
举报
0/150
提交
取消