Search code examples
amazon-advertising-apibottlenose

Error when use bottlenose


I have problems when I use bottlenose. According to its instructions, I need to add a error_handler as per instructions. in the instructions I placed the function:

def error_handler(err):
    ex = err['exception']
    if isinstance(ex, HTTPError) and ex.code == 404:
        time.sleep(random.expovariate(0.1))
        return True

The examples in the instruction says to use this line:

amazon = bottlenose.Amazon(ErrorHandler=error_handler)

I have this:

amazon = bottlenose.Amazon(AWSAccessKeyId=ACCESS_KEY_ID, AWSSecretAccessKey = SECRET_KEY,AssociateTag = ASSOC_TAG)

But I'm getting no correct response. Why?


Solution

  • Are you submitting requests too quickly? You need to slow down. One request per second is a good speed.

    The Amazon Product Advertising API returns errors in three categories so that you can easily determine how best to handle the problem:

    • 2XX errors are caused by mistakes in the request. For example, your request might be missing a required parameter. The error message in the response gives a clear indication what is wrong.
    • 4XX errors are non-transient errors. Upon receiving this error, resubmit the request.
    • 5XX errors are transient errors reflecting an error internal to Amazon. A 503 error means that you are submitting requests too quickly and your requests are being throttled. If this is the case, you need to slow your request rate to one request per second.