簡體   English   中英

獲取 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以僅獲取組織:

https://api.github.com/search/users?q=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。

參數

  • 名稱:自從
  • 類型:字符串
  • 描述:您看到的最后一個組織的整數 ID。

回復

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

有幾個參數可以使用。

  1. q :(字符串)。 搜索詞。
  2. sort :(字符串)。 排序字段。 可以是followersrepositoriesjoined 默認:結果按最佳匹配排序。
  3. order :(字符串)。 如果提供了 sort 參數,則為排序順序。 ascdesc 默認值: 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM