How can I get a list of all repositories in an organization where I am an admin or collaborator?

I’m a member of the GitHub Organization bigOrg, with ~8000 repositories. I am a collaborator or an administrator for about 50 of them. How can I query any of the GitHub APIs and retrieve a list of these ~50 repositories?

1 Like

@magnus-longva-bouvet You can try the Rest or GraphQL API to list repositories you have permissionson on within an organisation
Two links to related documentation areas


Repositories

Maybe the API could help? https://api.github.com/users/[username]/repos

I’m aware of the API methods to query a list of repositories for an organization or an account respectively, but I can’t figure out a way to get what I want without sending 8000 queries. I hope there’s a way, I just haven’t figured it out yet.

This doesn’t answer the question I asked, but it might be close enough to solve my use case. This GraphQL query seems to return all repositories for which I am a collaborator or administrator but not an owner. Repositories owned by bigOrg are returned, but so are repositories owned by any other organization.

{
  viewer {
    repositories(first: 100, affiliations: [COLLABORATOR, ORGANIZATION_MEMBER]) {
      totalCount
      pageInfo {
        endCursor
        hasNextPage
      }
      nodes{
        url
        name
          owner {
            login
          }
        }
      }
   }
 }

I was able to query a specific organization
I noticed your query above was on viewer (so that scope is related to what “you” the viewer has access to.
query {
organization(login: ORGANIZATION-NAME) {
repositories (first: 100) { blah, blah

this may work for you

1 Like