Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too Many Requests #8

Open
zerofelx opened this issue Nov 28, 2020 · 12 comments
Open

Too Many Requests #8

zerofelx opened this issue Nov 28, 2020 · 12 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@zerofelx
Copy link

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."}]}',

@TheGrinch00
Copy link

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?

@SaekiTominaga
Copy link

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.

@jorgerosal
Copy link
Owner

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

@jorgerosal jorgerosal self-assigned this Mar 6, 2021
@jorgerosal
Copy link
Owner

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 jorgerosal added the documentation Improvements or additions to documentation label Mar 8, 2021
@mattiaz9
Copy link

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

@polilluminato
Copy link

polilluminato commented Jul 21, 2021

@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

@ericrosenberg1
Copy link

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

@devagarwal007
Copy link

I am also getting the same error

@jorgerosal
Copy link
Owner

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

@feroz39
Copy link

feroz39 commented Dec 31, 2022

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

@jorgerosal
Copy link
Owner

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.

@SantoshNayak
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

10 participants