使用Github API在GitHub上的组织内查询存储库

时间:2018-07-17 13:15:25

标签: git github github-api

我需要汇编脚本,该脚本将从Github上特定组织内的“ test *”开始获取存储库的名称。

谁能暗示我-用哪种挖掘方式?可以通过一些API查询来实现,还是可以通过git命令行来实现?

2 个答案:

答案 0 :(得分:1)

您可以使用search query来通过仓库名称,描述或自述文件中的关键字test来过滤存储库(但没有针对仓库名称的过滤器):

Github API v3 Rest

https://api.github.com/search/repositories?q=org%3Agithub%20test&per_page=100

Github API v4 GraphQL

{
  search(query: "test org:github", type: REPOSITORY, first: 100) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          nameWithOwner
        }
      }
    }
  }
}

Try it in the explorer

答案 1 :(得分:0)

将上面找到的所有答案组合在一起,要在组织内找到具有某些搜索条件的所有存储库(包括私有存储库),我需要使用以下查询:

https://api.github.com/search/repositories?q=org:MY_ORG:MY_SEARCHCRITERIA&page=1&per_page=100&access_token=MY_ACCESSTOKEN

相关问题