Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query repos within organization on GitHub using Github API

I need to assemble script, which will get names of repositories, starting from "test*", within particular organization, on Github.

Can anyone hint me - in which way to dig? Either this possible via some API queries, or I can do this via git command line?

like image 541
Vasiliy Vegas Avatar asked Sep 04 '25 16:09

Vasiliy Vegas


2 Answers

You can use a search query to filter the repository by keyword test located in repo name, description or README (but there is no filter for the repo name only) :

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

like image 136
Bertrand Martel Avatar answered Sep 07 '25 16:09

Bertrand Martel


Assembling all answers above I found, that to find all repos (including private) with some search criteria, within organization, I need to use following query:

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

like image 44
Vasiliy Vegas Avatar answered Sep 07 '25 18:09

Vasiliy Vegas