amazon-paapi icon indicating copy to clipboard operation
amazon-paapi copied to clipboard

Too Many Requests

Open zerofelx opened this issue 4 years ago • 12 comments

When I try to run the example code (Obviously with my own keys) to search for a Harry Potter book it drops that error. I use the "amazon-pa-api50" and I have no problem when searching with the number of requests text: '{"__type":"com.amazon.paapi5#TooManyRequestsException","Errors":[{"Code":"TooManyRequests","Message":"The request was denied due to request throttling. Please verify the number of requests made per second to the Amazon Product Advertising API."}]}',

zerofelx avatar Nov 28 '20 16:11 zerofelx

Hi, note that Amazon Product Advertising API gives you that error even if you search in the wrong marketplace. For example, I use this package with keys provided for italian marketplace and if I do not specify it in the request, the default is amazon.com.

As a result, Amazon answers with a nice TooManyRequests, maybe that's also your problem?

TheGrinch00 avatar Dec 06 '20 07:12 TheGrinch00

Hi, I had the same problem, but I solved it by specifying the Marketplace.

In the official documentation, the Marketplace parameter is described as follows.

We determine the target Amazon Locale from the Host value in the headers, hence it is not a mandatory parameter.

However, if you omit the Marketplace parameter of commonParameters in 'amazon-paapi', www.amazon.com will be set. Therefore, when you specify a value other than US for Host, Marketplace is also effectively required.

In my case, this confusion was caused by the fact that both the official documentation and this feature state that Marketplace is "optional", while the behavior when it is omitted is different in both.

If you are suffering from the same problem, adding the Marketplace corresponding to the specified Host may solve the problem.

SaekiTominaga avatar Feb 01 '21 12:02 SaekiTominaga

Thank you @SaekiTominaga. Well explained. I will make an update to avoid confusion.

jorgerosal avatar Mar 06 '21 11:03 jorgerosal

Hello @SaekiTominaga , after careful consideration, I decided to keep the marketplace parameter to the commonParameters options and use it to predetermine the Host and Region so users won't have to specify Host and Region values. They do it by specifying the Marketplace value.

const amazonPaapi = require('amazon-paapi');

const commonParameters = {
	'AccessKey' : '<YOUR  ACCESS  KEY>',
	'SecretKey' : '<YOUR  SECRET  KEY>',
	'PartnerTag' : '<YOUR  PARTNER  TAG>', // yourtag-20
	'PartnerType': 'Associates', // Optional. Default value is Associates.
	'Marketplace': 'www.amazon.com' //Default value is US. Note: Host and Region are predetermined based on the marketplace value. There's is no need for you to add Host and Region as soon as you specify correct the correct Marketplace value. If your region is not US or .com, please make sure you add the correct Marketplace value.
};

This is to keep it simple and make it so it mimics a scratchpad-like experience. I will update the documentation to avoid confusion. Thank you.

image

jorgerosal avatar Mar 07 '21 10:03 jorgerosal

I get this error even after setting the marketplace (I use www.amazon.it). Am I doing something wrong?

mattiaz9 avatar Apr 22 '21 09:04 mattiaz9

@mattiaz9 I've got the same issue but some days ago it automagically disappeared. This is my package.json dependencies:

"dependencies": {
    "amazon-paapi": "^1.0.5",
    "dotenv": "^10.0.0"
}

this is my working code:

//amazon_utils.js

const AmazonPaapi = require('amazon-paapi');
require('dotenv').config();

const commonParameters = {
    'AccessKey' : process.env.AMAZON_ACCESS_KEY,
    'SecretKey' : process.env.AMAZON_SECRET_KEY,
    'PartnerTag' : process.env.AMAZON_PARTNER_TAG_API, // yourtag-20
    'PartnerType': 'Associates',
    'Marketplace': 'www.amazon.it'
};

let requestParameters = {
    'ItemIdType': 'ASIN', 
    'Condition' : 'New',
    'Resources' : [
        'Images.Primary.Large', 
        'ItemInfo.ContentInfo', 
        'ItemInfo.Title', 
        'Offers.Listings.Price'
    ]
};

exports.getItemsFromAmazonByItemsCode = (productsArray) => {
    return new Promise( async (resolve)=>{
        requestParameters.ItemIds = productsArray;
        let data = await AmazonPaapi.GetItems(commonParameters, requestParameters);
        resolve(data);
    });
}

I call it with:

const AmazonUtils = require('../utils/amazon_utils');

async function(){
    //some code
    let data = await AmazonUtils.getItemsFromAmazonByItemsCode([asinResult.ASIN]);
    //some code
}

Hope you find it useful, Alberto

polilluminato avatar Jul 21 '21 17:07 polilluminato

Hello, I'm trying to use this package to search for a product and generate an affiliate link. I'm also getting the TooManyRequestsException error. This is trying to make a single search request. Would appreciate any guidance, thanks!

My code:

from constants import *
from amazon_paapi import AmazonApi
amazon = AmazonApi(AMZN_KEY, AMZN_SECRET, AMZN_TAG, AMZN_REGION, throttling=2)  # Makes 1 request every 2 seconds

#Create search for Amazon API
amzn_search = (quote_book + " " + quote_author)

#Search for Product
search_result = amazon.search_items(keywords=amzn_search)
for item in search_result.items:
    print(item.item_info.title.display_value) # Item title
    print(item.detail_page_url) # Affiliate url

ericrosenberg1 avatar May 10 '22 18:05 ericrosenberg1

I am also getting the same error

devagarwal007 avatar Nov 21 '22 17:11 devagarwal007

Please try to test and make a request via amazon scratchpad and see if you get the same message.

jorgerosal avatar Nov 23 '22 13:11 jorgerosal

I also get this error while working with code. After that, I test it in scratchpad and getting same Capture

feroz39 avatar Dec 31 '22 10:12 feroz39

Try an affiliate key with at least 3 sales for the past 180 days. That is one of the requirements amazon apparently imposes. If your key is new and made no sales yet, then this is probably the cause.

jorgerosal avatar Jan 04 '23 07:01 jorgerosal

Try an affiliate key with at least 3 sales for the past 180 days. That is one of the requirements amazon apparently imposes. If your key is new and made no sales yet, then this is probably the cause.

I have more than 3 sales in last 30 days still getting this issue

SantoshNayak avatar Sep 18 '23 05:09 SantoshNayak