如何检查我的GitHub当前速率限制?

时间:2017-08-01 00:42:28

标签: github github-api

GitHub页面https://developer.github.com/v3/rate_limit/显示速率限制状态,例如:

响应

Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
X-RateLimit-Reset: 1372700873
{
  "resources": {
    "core": {
      "limit": 5000,
      "remaining": 4999,
      "reset": 1372700873
    },
    "search": {
      "limit": 30,
      "remaining": 18,
      "reset": 1372697452
    }
  },
  "rate": {
    "limit": 5000,
    "remaining": 4999,
    "reset": 1372700873
  }
}

但只说我需要检查GET /rate_limit。但是如何使用呢?我应该像这样做一个命令吗?

curl -i https://api.github.com/users/octocat GET /rate_limit

这个命令怎么样?

相关问题:

  1. GitHub API limit exceeded: how to increase the rate limit in front-end apps
  2. jspm saying "github rate limit reached" - how to fix?
  3. Github API: Fetch issues with exceeds rate limit prematurely
  4. https://developer.github.com/v3/#rate-limiting

1 个答案:

答案 0 :(得分:2)

您可以使用

调用此端点
curl -H "Authorization: token OAUTH-TOKEN" -X GET https://api.github.com/rate_limit
Ruby中的

或类似内容

require 'uri' 
require 'net/http'    

url = URI("https://api.github.com/rate_limit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)     
request["authorization"] = 'Authorization: token OAUTH-TOKEN'

response = http.request(request) 
puts response.read_body