Skip to main content
REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

速率限制的 REST API 终结点

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

关于速率限制

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

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

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

  • search 对象提供用于搜索的 REST API 的速率限制状态(代码搜索除外)。 有关详细信息,请参阅“搜索的 REST API 端点”。

  • code_search 对象提供用于搜索代码的 REST API 的速率限制状态。 有关详细信息,请参阅“搜索的 REST API 端点”。

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

  • integration_manifest 对象提供 POST /app-manifests/{code}/conversions 操作的速率限制状态。 有关详细信息,请参阅“从清单注册 GitHub 应用”。

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

  • code_scanning_upload 对象提供用于将 SARIF 结果上传到代码扫描的速率限制状态。 有关详细信息,请参阅“将 SARIF 文件上传到 GitHub”。

  • actions_runner_registration 对象提供在 GitHub Actions 中注册自托管运行器的速率限制状态。 有关详细信息,请参阅“自托管运行器的 REST API 终结点”。

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

Get rate limit status for the authenticated user

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

Some categories of endpoints have custom rate limits that are separate from the rate limit governing the other REST API endpoints. For this reason, the API response categorizes your rate limit. Under resources, you'll see objects relating to different categories:

  • The core object provides your rate limit status for all non-search-related resources in the REST API.
  • The search object provides your rate limit status for the REST API for searching (excluding code searches). For more information, see "Search."
  • The code_search object provides your rate limit status for the REST API for searching code. For more information, see "Search code."
  • The graphql object provides your rate limit status for the GraphQL API. For more information, see "Resource limitations."
  • The integration_manifest object provides your rate limit status for the POST /app-manifests/{code}/conversions operation. For more information, see "Creating a GitHub App from a manifest."
  • The dependency_snapshots object provides your rate limit status for submitting snapshots to the dependency graph. For more information, see "Dependency graph."
  • The code_scanning_upload object provides your rate limit status for uploading SARIF results to code scanning. For more information, see "Uploading a SARIF file to GitHub."
  • The actions_runner_registration object provides your rate limit status for registering self-hosted runners in GitHub Actions. For more information, see "Self-hosted runners."
  • The source_import object is no longer in use for any API endpoints, and it will be removed in the next API version. For more information about API versions, see "API Versions."

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”的细粒度访问令牌

This endpoint works with the following fine-grained token types:

令牌不需要任何权限。

如果仅请求公共资源,则无需身份验证即可使用此终结点。

“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, "used": 1, "remaining": 4999, "reset": 1691591363 }, "search": { "limit": 30, "used": 12, "remaining": 18, "reset": 1691591091 }, "graphql": { "limit": 5000, "used": 7, "remaining": 4993, "reset": 1691593228 }, "integration_manifest": { "limit": 5000, "used": 1, "remaining": 4999, "reset": 1691594631 }, "source_import": { "limit": 100, "used": 1, "remaining": 99, "reset": 1691591091 }, "code_scanning_upload": { "limit": 500, "used": 1, "remaining": 499, "reset": 1691594631 }, "actions_runner_registration": { "limit": 10000, "used": 0, "remaining": 10000, "reset": 1691594631 }, "scim": { "limit": 15000, "used": 0, "remaining": 15000, "reset": 1691594631 }, "dependency_snapshots": { "limit": 100, "used": 0, "remaining": 100, "reset": 1691591091 }, "code_search": { "limit": 10, "used": 0, "remaining": 10, "reset": 1691591091 } }, "rate": { "limit": 5000, "used": 1, "remaining": 4999, "reset": 1372700873 } }