简体   繁体   English

亚马逊产品广告 api node.js sdk 请求节流问题

[英]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.从 nodejs sdk 调用亚马逊产品广告 api 时,我收到此错误响应。

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.没有手动修改,它只是带有我的凭据的 sdk 代码。 any idea what might be the issue?知道可能是什么问题吗?

This is a very common problem people face while using Amazon product API.这是人们在使用亚马逊产品 API 时面临的一个非常普遍的问题。 Amazon works on a very different algorithm.亚马逊采用了一种非常不同的算法。 It allocates API threshold/ usage limit based on the commission you have earned through amazon.它根据您通过亚马逊赚取的佣金分配 API 阈值/使用限制。 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.因此,有必要考虑到关联 ID 仅在特定区域中处于活动状态,并且新生成的 API 密钥可能需要 72 小时才能真正处于活动状态,因此除了其他用户提到的配额内容之外,如有必要,请检查这些点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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