本文介绍了搜索 API 中的 twitter 中的速率限制如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 1.1 版本的 Twitter 搜索 API.

I want to user Search API for twitter using 1.1 version.

每个应用程序有 450 个请求的限制.

There is a limit for 450 request per applications.

但我对这种速率限制有疑问.我认为这意味着我们可以在每 15 分钟的请求窗口中发出 450 个请求.

But I have a doubt in this rate limiting. I thought that it means we can make 450 request in every 15 mins of request window.

但我读过(但我不确定我读到了什么)类似默认情况下它会根据搜索查询返回 15 个状态.但是,如果您在单个请求中查询更多状态,则会根据状态数量进行考虑.

But I read(but i am not sure about what exactly i read) something like by default it returns 15 status based on search query. But if you query more status in single request it's considered based on the number of statuses.

他们是否只有每 15 分钟的速率限制,或者他们也有一天的速率限制?

Do they have a rate limit only for every 15 mins or they have rate limit for a day too?

所以我无法理解它究竟是如何工作的?有人能帮我解决这个问题吗?

So I couldn't understand how it exactly works ? Can any one help me with this?

推荐答案

速率限制按身份验证类型、用户或应用程序进行细分.用户身份验证是基于用户的任何 OAuth 过程.仅应用程序身份验证针对您的应用程序凭据,而不是基于用户.在搜索的情况下,您有 15 分钟的时间窗口,用户为 180,应用程序为 450.对于更高的速率限制(在搜索的情况下),请使用仅限应用程序的身份验证.这会给你:

Rate limits are segmented by the type of authentication, user or app. User authentication is any OAuth process that is based on the user. Application-only authentication is for your application credentials and not based on user. In the case of Search, you have a 15 minute window of 180 for user and 450 for app. For a higher rate limit (in the case of search) use application-only authentication. This will give you:

24 小时 x 4 15 分钟增量 x 每 15 分钟增量 450 个请求 == 每天 43200 个请求

24 hours x 4 15-minute increments x 450 requests per 15-minute increments == 43200 requests per day

您只需要控制您的应用,使其在 15 分钟的时间间隔内不超过 450 个请求.

You just have to control your app so that it doesn't exceed 450 requests in a 15 minute interval.

这是 Twitter 上有关速率限制的文档:

Here's Twitter's docs on rate limiting:

https://developer.twitter.com/en/docs/basics/限速

您还可以使用 X-Rate-Limit-Limit/Remaining/Reset HTTP 标头和速率限制端点来跟踪您所在的位置和可用的内容:

You can also use the X-Rate-Limit-Limit/Remaining/Reset HTTP headers and the rate-limiting endpoint to keep track of where you're at and what's available:

https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status

这篇关于搜索 API 中的 twitter 中的速率限制如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:59
查看更多