我目前正在 ping foursquare field 平台,以便协调我公司的数据与 foursquare 的数据。有关 field 协调的信息如下:https://developer.foursquare.com/overview/mapping
速率限制在 header 中显示为 X_RATELIMIT_REMAINING。我有一个生产者推出新的请求,还有一个接触 foursquare api 的消费者。我想找到一种方法让生产者检查速率限制而不花费剩余的请求。
有谁知道有什么方法可以做到这一点吗?
最佳答案
不幸的是,没有“虚拟”端点来检查您的速率限制。他们有一个多端点,但据我记得他们会计算批处理内的每个请求。
您可以计算您这边的速率限制。这是一个解释:
The window should still update be updating in real time.
To be clear, if your rate limit is 500, at 11:00, you send 5 requests, the X-RateLimit-Remaining will be 495. If you wait a few minutes to 11:05, and send another request, X-Rate-Limit remaining will be 494 -- it won't have reset yet.
It's not until 12:01 that you'll get back the 5 requests that you'd made at 11:00. So, if you request again at 12:01, your limit would be 498 (-1 for the request you just did, -1 for the 11:05 request).
Requesting again at 12:06, and you'll be back up to 499 (the full limit, minus what you just used).
来自此线程:API Quota exceeded
如果您重现此逻辑并计算每个端点发出的每个请求,您就可以猜测您的速率限制。很抱歉没有更简单的方法来做到这一点:(
关于api - 有没有一种方法可以检查 Foursquare field 速率限制,而无需实际支付请求费用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11048300/