获取以下 Github URL:https://github.com/google
如何确定google
是用户还是组织?
我需要知道这一点才能以正确的方式查询 Github 的 graphql API。
获取以下 Github URL:https://github.com/google
如何确定google
是用户还是组织?
我需要知道这一点才能以正确的方式查询 Github 的 graphql API。
如果您有用户/组的登录名(用户名),您可以使用organization
&user
分别搜索组织和用户,并检查两个字段中的哪个不是null
:
{
org: organization(login: "google") {
name
members {
totalCount
}
}
user: user(login: "google") {
name
login
}
}
这使 :
{
"data": {
"org": {
"name": "Google",
"members": {
"totalCount": 1677
}
},
"user": null
}
}
或使用变量作为login
输入,在资源管理器中尝试
对于 Rest API v3,它要简单得多,因为它不区分用户和组织:https ://developer.github.com/v3/users :
curl -s 'https://api.github.com/users/google' | jq -r '.type'
组织
curl -s 'https://api.github.com/users/torvalds' | jq -r '.type'
用户