亚马逊产品广告API NodeJS SDK请求阻塞问题

gblwokeq  于 2022-12-29  发布在  Node.js
关注(0)|答案(2)|浏览(157)

当我从nodejs sdk调用amazon产品广告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.\"}]}"

密码是

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);
}

我得到了“太多的请求”错误,即使只做一个。也试图在服务器上运行这个,以防万一它与localhost有关。没有手动修改,它只是我的凭据的sdk代码。任何想法可能是什么问题?

py49o6xq

py49o6xq1#

这是人们在使用亚马逊产品API时遇到的一个非常常见的问题。亚马逊采用了一种非常不同的算法。它根据你通过亚马逊赚取的佣金来分配API阈值/使用限制。一旦你分配的限制耗尽,你就会收到这样的错误。要解决这个问题,请你的朋友通过你的会员链接购买。你会得到一些阈值。

oxiaedzo

oxiaedzo2#

老主题,但可能会有用。我意识到这个错误也显示时,身份验证失败。因此,有必要考虑到,关联ID只在一个具体的区域是活动的,而且新生成的API密钥可能需要到72小时才能真正活动,所以检查这些点,如果必要,除了配额的东西,其他用户提到。

相关问题