New in 2.4: Test runs you can trust See what's new →

限流

限流:一个真实的固定窗口限流器(每个客户端每 60 秒 5 个请求),用于测试 429 和 Retry-After 的处理。客户端通过 X-Client-Id 请求头识别,没有时按 IP 识别。

请求示例

Make a rate-limited request that counts toward the limit. 完整参考和 Send 按钮(英文).

cURL
curl -X GET "https://api.testingapis.com/api/RateLimit" \
  -H "X-Client-Id: docs-demo"
在 Studio 中运行
响应 · 200 OK
{
  "message": "Request allowed.",
  "clientId": "id:docs-demo",
  "used": 1,
  "remaining": 4,
  "limit": 5,
  "windowSeconds": 60
}