我正在编写一个自定义Python类来封装Poloniex交易API。但是,我遇到的问题是返回“404错误”。我一遍又一遍地在文档中,我很确定我正在使用正确的端点......我还有什么可能做错的:
...
self.trading_api = 'https://poloniex.com/tradingapi'
self.api_key = 'My API key'
self.secret_key = bytes('My Secret Key', 'latin-1')
...
req['nonce'] = int(time.time()*1000)
data = urllib.parse.urlencode(req).encode()
sign = hmac.new(self.secret_key, data, sha512)
signature=sign.hexdigest()
headers = dict(Key=self.api_key, Sign=signature)
conn = urllib.request.Request(self.trading_api, headers=headers)
self.rate_limit()
try:
requested = urllib.request.urlopen(conn, data=data)
return requested
网址中的A必须大写:
self.trading_api = 'https://poloniex.com/tradingApi'
虽然Poloniex的文档没有记录这一点(实际上使用的URL是直接从他们的页面复制的),但请记住将其大写!