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

use*_*ser 5 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
  }
}
Run Code Online (Sandbox Code Playgroud)

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

curl -i https://api.github.com/users/octocat GET /rate_limit
Run Code Online (Sandbox Code Playgroud)

这个命令会如何?


相关问题:

  1. 超过GitHub API限制:如何提高前端应用程序的速率限制
  2. jspm说“达到github速率限制”-如何解决?
  3. Github API:过早提取超出速率限制的问题
  4. https://developer.github.com/v3/#rate-limiting

oso*_*kit 12

您可以使用调用此端点

curl -H "Authorization: token OAUTH-TOKEN" -X GET https://api.github.com/rate_limit
Run Code Online (Sandbox Code Playgroud)

或类似的 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
Run Code Online (Sandbox Code Playgroud)

  • 如果我将“OAUTH-TOKEN”放入您的问题中,则会抛出错误:“curl:(6)无法解析主机:令牌,curl:(6)无法解析主机:OAUTH-TOKEN”。如果我使用 `curl -H "Authorization: token OAUTH-TOKEN" -X GET https://api.github.com/rate_limit`,它确实可以正常工作。你能更新答案吗? (2认同)