首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HTTP API速率限制HTTP响应头的示例

HTTP API速率限制HTTP响应头的示例
EN

Stack Overflow用户
提问于 2013-04-16 02:49:31
回答 2查看 67K关注 0票数 88

附加的超文本传输协议状态码(RFC6585)之一是

在哪里可以找到对此HTTP响应状态有用的HTTP / REST API速率限制HTTP响应头的示例?

EN

回答 2

Stack Overflow用户

发布于 2013-04-16 02:49:31

以下是HTTP API速率限制HTTP响应头的一些示例。取自四个常用的REST API: Github、Vimeo、Twitter和Imgur:

Github速率限制http://developer.github.com/v3/#rate-limiting

代码语言:javascript
复制
#=============================#=============================================#
# HTTP Header                 # Description                                 #
#=============================#=============================================#
| X-RateLimit-Limit           | Request limit per hour                      |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Remaining       | The number of requests left for the time    |
|                             | window                                      |
+-----------------------------+---------------------------------------------+

Vimeo速率限制http://developer.vimeo.com/guidelines/rate-limiting

代码语言:javascript
复制
#=============================#=============================================#
# HTTP Header                 # Description                                 #
#=============================#=============================================#
| X-RateLimit-Limit           | Request limit per day / per 5 minutes       |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Remaining       | The number of requests left for the time    |
|                             | window                                      |
+-----------------------------+---------------------------------------------+
| X-RateLimit-Reset           | The remaining window before the rate limit  |
|                             | resets in UTC epoch seconds                 |
+-----------------------------+---------------------------------------------+

Twitter REST API速率限制https://dev.twitter.com/docs/rate-limiting/1.1

注:推特使用类似Vimeo的标题,但每个名称中都有另一个破折号。

代码语言:javascript
复制
#=============================#=============================================#
# HTTP Header                 # Description                                 #
#=============================#=============================================#
| X-Rate-Limit-Limit          | The rate limit ceiling for that given       |
|                             | request                                     |
+-----------------------------+---------------------------------------------+
| X-Rate-Limit-Remaining      | The number of requests left for the         |
|                             | 15 minute window                            |
+-----------------------------+---------------------------------------------+
| X-Rate-Limit-Reset          | The remaining window before the rate limit  |
|                             | resets in UTC epoch seconds                 |
+-----------------------------+---------------------------------------------+

Imgur API速率限制http://api.imgur.com/

代码语言:javascript
复制
#=============================#=============================================#
# HTTP Header                 # Description                                 #
#=============================#=============================================#
| X-RateLimit-UserLimit       | Total credits that can be allocated         |
+-----------------------------+---------------------------------------------+
| X-RateLimit-UserRemaining   | Total credits available                     |
+-----------------------------+---------------------------------------------+
| X-RateLimit-UserReset       | Timestamp (unix epoch) for when the credits |
|                             | will be reset                               |
+-----------------------------+---------------------------------------------+
| X-RateLimit-ClientLimit     | Total credits that can be allocated for the |
|                             | application in a day                        |
+-----------------------------+---------------------------------------------+
| X-RateLimit-ClientRemaining | Total credits remaining for the application |
|                             | in a day                                    |
+-----------------------------+---------------------------------------------+
票数 139
EN

Stack Overflow用户

发布于 2013-05-24 22:22:49

除了特定于API的报头之外,不要忘记最简单的standard Retry-After header

服务器发送“Retry After”标头字段,以指示用户代理在发出后续请求之前应该等待多长时间。此字段的值可以是HTTP日期,也可以是接收到响应后延迟的秒数。

该标准在使用503或3xx状态代码时提出了具体的附加建议:

当与503 (服务不可用)响应一起发送时,Retry After指示客户端预期服务不可用的时间。与任何3xx (重定向)响应一起发送时,Retry-After表示在发出重定向请求之前要求用户代理等待的最短时间。

票数 34
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16022624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档