GitHub API 得到 users/organizations 的总数

GitHub API get total number of users/organizations

使用GitHub API,如何计算请求时users/organizations的总数?

Users and Organizations API responses do not contain last Link header.

注意:跟随next Link header直到最后一个,对我来说不是解决方案,因为rate limits 免费帐户。

GraphQL API v4

您可以使用 GraphQL API v4 获取用户数和组织数:

{
  user: search(type: USER, query: "type:user") {
    userCount
  }
  org: search(type: USER, query: "type:org") {
    userCount
  }
}

Try it in the explorer

给出:

{
  "data": {
    "user": {
      "userCount": 24486303
    },
    "org": {
      "userCount": 1629433
    }
  }
}

REST API v3

结果为 total_count 字段提供了所需的值

它与您可以使用 Github 搜索找到的结果相匹配: