代码之家  ›  专栏  ›  技术社区  ›  Nam Vu

获取GitHub上的组织列表

  •  14
  • Nam Vu  · 技术社区  · 12 年前

    是否有一个解决方法来获取GitHub上的组织列表?

    例如: https://github.com/showcases/open-source-organizations

    我们如何通过GitHub API或GitHub搜索做到这一点?

    5 回复  |  直到 11 年前
        1
  •  13
  •   Ivan Zuzak    12 年前

    您可以获得所有帐户的列表:

    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

        2
  •  7
  •   Gabor Meszaros    10 年前

    On June 17, 2015 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."
      },
      ...
    ]
    

    有关更多信息,请访问 the following link :

    列出所有组织

    按在GitHub上创建的顺序列出所有组织。

    注意:寻呼仅由 since 参数使用 Link header 获取组织下一页的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"
      }
    ]
    
        3
  •  1
  •   Bertrand Martel    6 年前

    注意,也可以使用 Github GraphQL v4 请求组织使用:

    {
      search(query: "type:org", type: USER, first: 100) {
        userCount
        nodes {
          ... on Organization {
            name
            createdAt
            description
          }
        }
      }
    }
    

    Try it in the explorer

        4
  •  0
  •   P. Shi    10 年前

    我遇到了类似的问题,也许我现在从github API文档中得到了答案。

    此处的详细文档: https://developer.github.com/v3/search/#search-users

    有几个参数可以使用。

    1. q :(字符串)。搜索词。
    2. sort :(字符串)。排序字段。可以是 followers , repositories 或 joined 。默认值:结果按最佳匹配排序。
    3. order :(字符串)。如果提供了排序参数,则为排序顺序。什么之中的一个 asc 或 desc 。默认值: 描述(desc)

    这个 q 搜索项还可以包含浏览器内用户搜索文档和搜索语法文档所描述的支持的用户搜索限定符的任意组合:

    • type 使用此限定符,您可以将搜索限制为仅个人帐户( user )或仅组织帐户( org ).
    • in 限定要搜索的字段。使用此限定符,您可以将搜索限制为用户名( login ),公共电子邮件( email ),全名( fullname )或它们的任意组合。
    • repos 根据用户拥有的存储库数量筛选用户。
    • location 根据用户配置文件中指示的位置筛选用户。
    • language 搜索具有与特定语言匹配的存储库的用户。
    • created 根据用户加入的时间筛选用户。
    • 追随者 根据用户的关注人数筛选用户。

    对于您的问题,您可以尝试此示例并进行更改。

    例如:

    https://api.github.com/search/users?q=language:objective-c+type:org&page=1

    请求GET并返回格式数据(json)。页面参数可以更改以获得更多页面的结果(但根据当前API文档,不超过1000页)。