[英]How to get a list of the companies and organizations that contributed to a repository on GitHub?
[英]Get list of organizations on GitHub
是否有解決方法來獲取 GitHub 上的組織列表?
例如: https : //github.com/showcases/open-source-organizations
我們如何通過 GitHub API 或 GitHub 搜索來做到這一點?
您可以獲得所有帳戶的列表:
https://developer.github.com/v3/users/#get-all-users
type
參數會告訴您它是用戶還是組織。
另一種方法是使用搜索 API:
https://developer.github.com/v3/search/#search-users
您可以指定type:org
以僅獲取組織:
2015 年 6 月 17 日, GitHub 添加了一個新的 API 來獲取組織:
curl https://api.github.com/organizations
[
{
"login": "github",
"id": 9919,
"url": "https://api.github.com/orgs/github",
"repos_url": "https://api.github.com/orgs/github/repos",
"events_url": "https://api.github.com/orgs/github/events",
"members_url": "https://api.github.com/orgs/github/members{/member}",
"public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/9919?v=3",
"description": "GitHub, the company."
},
...
]
可以在以下鏈接中找到其他信息:
按在 GitHub 上創建的順序列出所有組織。
注意:分頁完全由since
參數提供支持。 使用鏈接標題獲取組織下一頁的 URL。
參數
回復
Status: 200 OK
Link: <https://api.github.com/organizations?since=135>; rel="next"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
----------------------------------------------------------------------
[
{
"login": "github",
"id": 1,
"url": "https://api.github.com/orgs/github",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}
]
請注意,也可以使用Github GraphQL v4來請求組織使用:
{
search(query: "type:org", type: USER, first: 100) {
userCount
nodes {
... on Organization {
name
createdAt
description
}
}
}
}
我和你遇到了類似的問題,也許我現在可以從 github API 文檔中得到答案。
詳細文檔在此: https : //developer.github.com/v3/search/#search-users
有幾個參數可以使用。
q
:(字符串)。 搜索詞。sort
:(字符串)。 排序字段。 可以是followers
、 repositories
或joined
。 默認:結果按最佳匹配排序。order
:(字符串)。 如果提供了 sort 參數,則為排序順序。 asc
或desc
。 默認值: desc
q
搜索詞還可以包含受支持的用戶搜索限定符的任意組合,如瀏覽器內用戶搜索文檔和搜索語法文檔所述:
type
使用此限定符,您可以將搜索限制為僅個人帳戶 ( user
) 或僅組織帳戶 ( org
)。in
限定要搜索的字段。 使用此限定符,您可以將搜索限制為僅用戶名 ( login
)、公共電子郵件 ( email
)、全名 ( fullname
) 或這些的任意組合。repos
根據用戶擁有的存儲庫數量過濾用戶。location
按個人資料中指示的location
過濾用戶。language
搜索具有與特定語言匹配的存儲庫的用戶。created
根據用戶加入的時間過濾用戶。followers
根據他們擁有的追隨者數量過濾用戶。對於你的問題,你可以試試這個例子並改變它。
例如:
https://api.github.com/search/users?q=language:objective-c+type:org&page=1
請求 GET 並返回格式數據 (json)。 可以更改頁面參數以獲得更多頁面的結果(但不超過 1000,根據當前的 API 文檔)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.