Poloniex API请求给出404错误

问题描述 投票:0回答:1

我正在编写一个自定义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
python python-3.x poloniex
1个回答
0
投票

网址中的A必须大写:

self.trading_api = 'https://poloniex.com/tradingApi'

虽然Poloniex的文档没有记录这一点(实际上使用的URL是直接从他们的页面复制的),但请记住将其大写!

© www.soinside.com 2019 - 2024. All rights reserved.