簡體   English   中英

亞馬遜產品廣告 api node.js sdk 請求節流問題

[英]amazon product advertising api node js sdk request throtteling issue

從 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.\"}]}"

代碼是

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

即使只發出一個請求,我也會收到“太多請求”錯誤。 還嘗試在服務器上運行它,以防萬一它與本地主機有關。 沒有手動修改,它只是帶有我的憑據的 sdk 代碼。 知道可能是什么問題嗎?

這是人們在使用亞馬遜產品 API 時面臨的一個非常普遍的問題。 亞馬遜采用了一種非常不同的算法。 它根據您通過亞馬遜賺取的佣金分配 API 閾值/使用限制。 一旦您分配的限制用完,您將收到此類錯誤。 要解決此問題,請讓您的朋友通過您的會員鏈接購買。 你會得到一些門檻。

老話題,但也許有用。 我意識到身份驗證失敗時也會顯示此錯誤。 因此,有必要考慮到關聯 ID 僅在特定區域中處於活動狀態,並且新生成的 API 密鑰可能需要 72 小時才能真正處於活動狀態,因此除了其他用戶提到的配額內容之外,如有必要,請檢查這些點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM