pythonpython-3.xpoloniex

Poloniex API Request Gives 404 Error


I am writing a custom Python class to encapsulate the Poloniex trading API. However, I am running in to a problem with the request returning a "404 Error". I have been over and over the documentation and am quite sure that I am utilizing the right endpoint... What else could I be doing wrong here:

...

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

Solution

  • The A in the url must be capitalized:

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

    While Poloniex's documentation does not make note of this (in fact the url used was copied directly from their page), remember to capitalize it!