【问题标题】:Github API: List the last N public repositoriesGithub API:列出最后 N 个公共存储库
【发布时间】:2018-10-07 06:47:36
【问题描述】:

我想使用 Github 的 API (here) 从 Github 获取最后一个公共存储库

我试图了解List all public repositories 端点的工作原理,尤其是since 参数。

这个参数是什么?这会返回一个 id 大于 since 值的存储库列表吗?

我如何使用它来获取最后的“n”个公共存储库? 例如,我想列出最后 50 个公共存储库。

【问题讨论】:

    标签: github github-api


    【解决方案1】:

    您可以使用带有参数is:public created:>2018-04-28:18:00:00Z 的 Github 搜索 api 来获取在特定日期之后创建的所有公共存储库。您可以选择最后一小时的日期时间。如果您返回的存储库少于 50 个,则只需将其设置为 2 小时后

    使用 GraphQL API v4:

    {
      search(query: "is:public created:>2018-04-28T18:00:00Z", type: REPOSITORY, last: 50) {
        repositoryCount
        pageInfo {
          endCursor
          startCursor
        }
        edges {
          node {
            ... on Repository {
              name
              createdAt
            }
          }
        }
      }
    }
    

    您必须按照createdAt 进行排序,因为没有按创建日期排序(仅按作者日期和提交者日期检查this

    Try it in the explorer

    对于 Rest API v3

    https://api.github.com/search/repositories?q=is:public%20created:%3E2018-04-28T18:00:00Ztraversing paginationLink 标头一起使用

    【讨论】:

      猜你喜欢
      • 2017-07-29
      • 1970-01-01
      • 2018-06-23
      • 2022-11-20
      • 1970-01-01
      • 2021-04-07
      • 1970-01-01
      • 2013-12-11
      • 2013-06-10
      相关资源
      最近更新 更多