Amazon API 提交请求太快

Amazon API submitting requests too quickly

我正在创建一个游戏比较网站,并希望在其中包含亚马逊价格。我面临的问题是使用他们的 API 来获取我已有的 25,000 种产品的价格。

我目前正在使用 Amazons API 的 ItemLookup 并让它检索价格,但是在大约 10 个结果后我收到一条错误消息 'You are submitting requests too quickly. Please retry your requests at a slower rate'。

降低请求速率的最佳方法是什么?

谢谢,

因为它只说在 10 个结果之后你应该检查你能得到多少结果。如果它总是在 10 个快速请求后出现,你可以使用

 wait(500)

或更多毫秒。如果仅在 10 次之后,您可以构建一个循环并每 9 次请求执行此操作。

If your application is trying to submit requests that exceed the maximum request limit for your account, you may receive error messages from Product Advertising API. The request limit for each account is calculated based on revenue performance. Each account used to access the Product Advertising API is allowed an initial usage limit of 1 request per second. Each account will receive an additional 1 request per second (up to a maximum of 10) for every ,600 of shipped item revenue driven in a trailing 30-day period (about [=10=].11 per minute).

来自Amazon API Docs

如果您只计划 运行 这一次,那么只需在请求之间休眠一秒钟。

如果您计划 运行 更频繁地进行此操作,则可能值得对其进行更多优化,方法是确保查询到 return 所需的时间长度已被占用关闭睡眠(因此,如果我的 API 查询需要 200 毫秒才能返回,我们只睡眠 800 毫秒)

当你的要求很多重复。 那么你就可以创建一个每天都清晰的缓存上下文。 或者联系aws购买授权

即使延迟 1 秒或更多秒,我也遇到了同样的问题。

我相信当您开始发出过多的请求而只延迟一秒钟时,亚马逊会不喜欢这样,并认为您是垃圾邮件发送者。

您必须生成另一个密钥对(并在发出进一步请求时使用它)并延迟 1.1 秒才能再次发出快速请求。

这对我有用。