限制HTTP响应报头的HTTP API速率的实例[关闭](Examples of HTTP API

2019-08-31 07:05发布

一个附加的HTTP状态代码的( RFC6585 )是

  • 429个请求过多

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

Answer 1:

以下是限制HTTP响应头HTTP API率的一些例子。 Github上,Vimeo的,Twitter和Imgur:从四种常见的REST API措施:

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

#=============================#=============================================#
# 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

#=============================#=============================================#
# 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

注:Twitter使用头与像Vimeo的相似的名字,但在每个名字另一个冲刺。

#=============================#=============================================#
# 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/

#=============================#=============================================#
# 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                                    |
+-----------------------------+---------------------------------------------+


Answer 2:

除了API特定的头文件,不要忘了谦虚,标准Retry-After头。



文章来源: Examples of HTTP API Rate Limiting HTTP Response headers [closed]