Yesterday, a site I maintain, earlychildhoodeducator.com, was having issues communicating with Amazon’s Product Advertising API. Here’s what I learned about the problem and how we fixed it (in case you’re likewise having issues with it!)
The website is for an online school, and they have links to the course’s textbooks. The administrators just enter the course’s textbooks’ ASIN numbers (a unique ID in Amazon’s database), and then we use their Product Advertising API to fetch the book’s name, images, and an affiliate link, all of which we display to students.
FYI, in case you’re googling the problem, we were sending GET requests to URIs like the following:
It’s been working fine for years, yet yesterday morning we started getting the following error responses from Amazon’s servers:
<?xml version="1.0"?> <ItemLookupErrorResponse xmlns="http://ecs.amazonaws.com/doc/2005-10-05/"><Error><Code>RequestThrottled</Code><Message>AWS Access Key ID: *******. You are submitting requests too quickly. Please retry your requests at a slower rate.</Message></Error><RequestID>************</RequestID></ItemLookupErrorResponse>
At first glance that seems pretty self-explanatory: we’re sending requests too quickly, and so they were getting denied. But that was strange because we only send these requests once, and then cache the responses for a full week. Amazon’s documentation said we got at least hundreds of API calls per hour -no way our dozen requests a week was over the quota. Nevertheless, I tried temporarily just disabling our API calls, figuring maybe there was some runaway process that hit their servers with a million requests and now we needed to just wait for access to be restored. After a few hours of waiting, no change. It was something else.
I logged into the Amazon to see if there was any record of what was going on. I was greeted with this:
The efficiency guideline had some gems:
Effective 23-Jan-2019… your account will lose access to Product Advertising API if it has not generated referring sales using PA API in the last 30 days.Amazon Efficiency Guidelines
Translation: about 2 months ago they made a change. If you don’t get a sale for a month, they revoke your access to the API. How rude. We were averaging about a sale a month, and since the last sale was just over a month ago, we lost access this week.
But there’s a way to recover, you need to make another sale:
If you lose access to Product Advertising API, please see our other product linking tools, such as Site Stripe. You will regain access to Product Advertising API once your account again begins to drive referring sales.Amazon Efficiency Guidelines
Meaning, if someone were to buy a book on Amazon using our affiliate link, they’d restore our access to the API for another month. The trick is: we lost those affiliate links (we just refreshes them once a week, and now when they tried to get refreshed, they couldn’t be accessed). So we were up the stream without a paddle.
In our case, it seems we just needed to switch to manually getting the book’s name, copying the image from Amazon, and using SiteStripe to get our affiliate link.
We only have a few dozen books, so it didn’t take too long to manually get the affiliate link, image, and name for each book. I don’t know what we would do if we had hundreds of books though… maybe we’d buy a book ourselves, using thea ffiliate links, every month to maintain access. Seems pretty ridiculous, but that seems like the best option Amazon would have left us with.
Got a better fix? Or questions about our fix? Feel free to leave a comment.
About the Cover Image: This is from a somewhat disturbing french book “Ce n’est PAS une bonne idee” by Mo Willems.