本文介绍了GitHub API获取用户/组织总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 GitHub API ,我如何计算截止到那时的用户/组织总数请求?
Using GitHub API, how can I count the total number of users/organizations at the time of the request?
Users and Organizations API responses do not contain last
Link header.
注意:由于费率限制.
推荐答案
GraphQL API v4
您可以获取用户数&使用 GraphQL API v4
{
user: search(type: USER, query: "type:user") {
userCount
}
org: search(type: USER, query: "type:org") {
userCount
}
}
给出:
{
"data": {
"user": {
"userCount": 24486303
},
"org": {
"userCount": 1629433
}
}
}
REST API v3
- 使用
- 搜索查询: https://api.github. com/search/users?q = type%3Auser
- 使用
type:org
的搜索查询: https://api.github. com/search/users?q = type%3Aorg - search query with
type:user
: https://api.github.com/search/users?q=type%3Auser - search query with
type:org
: https://api.github.com/search/users?q=type%3Aorg - : 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
- for user : https://github.com/search?q=type%3Auser&type=Users&utf8=%E2%9C%93
- for org : https://github.com/search?utf8=%E2%9C%93&q=type%3Aorg&type=Users
type:user
的REST API v3
结果为total_count
字段提供所需的值
The result gives total_count
field with the required value
它与您可以使用Github搜索找到的结果相匹配:
It matches the result you can find using Github search :
- 用户的
这篇关于GitHub API获取用户/组织总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!