GitHub API 获取用户/组织总数

标签 github github-api

使用 GitHub API ,如何计算请求时的用户/组织总数?

UsersOrganizations API 响应不包含 last Link header .

备注 : 关注 next链接头直到最后一个,对我来说不是解决方案,因为 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
  • 使用 type:user 搜索查询:https://api.github.com/search/users?q=type%3Auser
  • 使用 type:org 搜索查询:https://api.github.com/search/users?q=type%3Aorg

  • 结果给出 total_count具有所需值的字段

    它匹配您可以使用 Github 搜索找到的结果:
  • 用户:https://github.com/search?q=type%3Auser&type=Users&utf8=%E2%9C%93
  • 对于组织:https://github.com/search?utf8=%E2%9C%93&q=type%3Aorg&type=Users
  • 关于GitHub API 获取用户/组织总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47502683/

    相关文章:

    java - NetBeans 8.1 无法连接到远程存储库

    php - 如何从 GitHub 推送到你的 VPS

    Python Git Bash CMD 脚本

    email - 获取提交者电子邮件

    git - Jenkins 配置和安全问题

    github - 列出所有 Unresolved 拉取请求评论

    python - [Python] 无法让 Travis CI 工作。路径问题

    Github actions 可重用工作流程目前不支持环境。我的黑客行为会阻止 secret 发挥作用吗?

    ios - GitHub API 未解析

    javascript - 可以在网站上嵌入 Github 问题列表(带有特定标签)吗?