Skip to main content
我们经常发布文档更新,此页面的翻译可能仍在进行中。 有关最新信息,请访问英语文档
REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

速率限制

使用 REST API 检查当前速率限制状态。

关于速率限制

你可以在任何时候检查当前的速率限制状态。 有关速率限制规则的详细信息,请参阅“REST API 中的资源”。

用于搜索项的 REST API 具有自定义速率限制,与控制其他 REST API 终结点的速率限制不同。 有关详细信息,请参阅“搜索”。 GraphQL API 也有自定义速率限制,它与 REST API 中的速率限制不同且计算方式也不同。 有关详细信息,请参阅“资源限制”。 出于这些原因,API 响应会对速率限制进行分类。 在 resources 下,你将看到与不同类别相关的对象:

  • core 对象提供 REST API 中所有非搜索相关资源的速率限制状态。

  • search 对象提供用于搜索的 REST API 的速率限制状态。

  • graphql 对象提供 GraphQL API 的速率限制状态。

  • integration_manifest 对象提供 POST /app-manifests/{code}/conversions 操作的速率限制状态。 有关详细信息,请参阅“Registering a GitHub App from a manifest”。

  • dependency_snapshots 对象提供将快照提交到依赖项关系图的速率限制状态。 有关详细信息,请参阅“依赖项关系图”。

有关速率限制响应中的标头和值的详细信息,请参阅“REST API 中的资源”。

Get rate limit status for the authenticated user

适用于 GitHub Apps

Note: Accessing this endpoint does not count against your REST API rate limit.

Note: The rate object is deprecated. If you're writing new API client code or updating existing code, you should use the core object instead of the rate object. The core object contains the same information that is present in the rate object.

“Get rate limit status for the authenticated user”的 HTTP 响应状态代码

状态代码说明
200

OK

304

Not modified

404

Resource not found

“Get rate limit status for the authenticated user”的示例代码

get/rate_limit
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/rate_limit

Response

Status: 200
{ "resources": { "core": { "limit": 5000, "remaining": 4999, "reset": 1372700873, "used": 1 }, "search": { "limit": 30, "remaining": 18, "reset": 1372697452, "used": 12 }, "graphql": { "limit": 5000, "remaining": 4993, "reset": 1372700389, "used": 7 }, "integration_manifest": { "limit": 5000, "remaining": 4999, "reset": 1551806725, "used": 1 }, "code_scanning_upload": { "limit": 500, "remaining": 499, "reset": 1551806725, "used": 1 } }, "rate": { "limit": 5000, "remaining": 4999, "reset": 1372700873, "used": 1 } }