【问题标题】:List all (private) repositories of a GitHub organization列出 GitHub 组织的所有(私有)存储库
【发布时间】:2021-07-11 10:35:56
【问题描述】:

我是 GitHub 组织的所有者。该组织中的所有存储库都设置为私有。 在 Web UI 仪表板中,我可以看到我的组织中有 112 个存储库。但是,当我通过 API (https://docs.github.com/en/rest/reference/repos#list-organization-repositories) 请求所有存储库时,我只能得到大约 30 个。

curl -i -u username:oauth-token https://api.github.com/orgs/org/repos

在 URL 中添加像 ?type=all 这样的查询字符串没有任何区别。

感谢您的帮助和想法。

K

【问题讨论】:

    标签: rest github curl github-api


    【解决方案1】:

    默认情况下,GitHub API 在此处每页返回 30 个结果。正如文档链接中所说,尝试设置per_page(最大100)以获得更多:

    https://api.github.com/orgs/org/repos?per_page=100
    

    并使用page 参数获取下一页:

    https://api.github.com/orgs/org/repos?per_page=100&page=2
    

    【讨论】:

    【解决方案2】:

    诀窍是使用paging query parameters AND 到quote the request URI

    curl -i -u username:oauth-token "https://api.github.com/orgs/org/repos?per_page=100&page=1"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-24
      • 1970-01-01
      • 2013-09-09
      • 2017-02-10
      • 2015-08-30
      • 2016-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多