简体   繁体   中英

amazon product advertising api node js sdk request throtteling issue

I am getting this error in response when calling amazon product advertising api from nodejs sdk.

Error calling PA-API 5.0!
Printing Full Error Object:
{
 "status": 429,
 "response": {
  "req": {
   "method": "POST",
   "url": "https://webservices.amazon.com/paapi5/getitems",
   "data": {
    "ItemIds": [
     "B075LRK2QK"
    ],
    "PartnerTag": "raassnabct-21",
    "PartnerType": "Associates",
    "Condition": "New",
    "Resources": [
     "Images.Primary.Medium"
    ]
   },
   "headers": {
    "user-agent": "paapi5-nodejs-sdk/1.0.0",
    "authorization": "AWS4-HMAC-SHA256 Credential=MY_KEY/20191215/us-east-1/ProductAdvertisingAPI/aws4_request, SignedHeaders=content-encoding;content-type;host;x-amz-date;x-amz-target, Signature=030b9f07a2336302a6d8855e216e602589960bf919dc9e700daac6155dcce1a2",
    "content-encoding": "amz-1.0",
    "content-type": "application/json; charset=utf-8",
    "host": "webservices.amazon.com",
    "x-amz-target": "com.amazon.paapi5.v1.ProductAdvertisingAPIv1.GetItems",
    "x-amz-date": "20191215T111055Z",
    "accept": "application/json"
   }
  },
  "header": {
   "server": "Server",
   "date": "Sun, 15 Dec 2019 11:10:54 GMT",
   "content-type": "application/json",
   "content-length": "193",
   "connection": "close",
   "x-amzn-requestid": "0ada8ea0-944f-47a2-bbef-acc0f5d984a9",
   "vary": "Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent",
   "content-encoding": "gzip",
   "x-amz-rid": "JTD0DAVWEB1CMXK1F5BW"
  },
  "status": 429,
  "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.\"}]}"
 }
}
Status Code: 429
Error Object: "{\"__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.\"}]}"

And the code is

var ProductAdvertisingAPIv1 = require('./src/index');
var defaultClient = ProductAdvertisingAPIv1.ApiClient.instance;
defaultClient.accessKey = 'accessKey';
defaultClient.secretKey = 'secretKey';

defaultClient.host = 'webservices.amazon.com';
defaultClient.region = 'us-east-1';

var api = new ProductAdvertisingAPIv1.DefaultApi();
var getItemsRequest = new ProductAdvertisingAPIv1.GetItemsRequest();

getItemsRequest['PartnerTag'] = 'raassnacbt-21';
getItemsRequest['PartnerType'] = 'Associates';
getItemsRequest['ItemIds'] = ['B075LRK2QK'];
getItemsRequest['Condition'] = 'New';
getItemsRequest['Resources'] = ['Images.Primary.Medium', 'ItemInfo.Title', 'Offers.Listings.Price'];

function parseResponse(itemsResponseList) {
  var mappedResponse = {};
  for (var i in itemsResponseList) {
    mappedResponse[itemsResponseList[i]['ASIN']] = itemsResponseList[i];
  }
  return mappedResponse;
}

try {
  api.getItems(getItemsRequest, callback);
} catch (ex) {
  console.log("Exception: " + ex);
}

I am getting "too many requests" error even when making just one. also tried to run this on server just in case it had something to do with localhost. there is no manual modification, it is just the sdk code with my credentials. any idea what might be the issue?

This is a very common problem people face while using Amazon product API. Amazon works on a very different algorithm. It allocates API threshold/ usage limit based on the commission you have earned through amazon. Once your allocated limit is exhausted, you will receive such errors. To fix this, ask your friend to buy through your affiliate link. You will get some threshold.

Old topic, but maybe can be useful. I realized this error is also shown when authentication failed. So it is necessary to take into account that associate IDs are only active in a concrete region and also that new generated API Keys can take until 72h to be really active, so check these points if necessary apart from the quota stuff the other users mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM