37

Here's my query to the GitHub API

curl -i -u {user} https://api.github.com/orgs/{org}/repos?type=all

But this does not list all repos for this organization that I have access to. Specifically, it does not list repos in the organization that are part of a team that I am a member of.

If I were to query

curl -i -u {user} https://api.github.com/teams/{teamid}/repos

I would see the missing repos. If I were to navigate to github.com, I would see both private organization repos and my team repos next to each other on the same page. Is there a way to get all of these repos in the same API query?

user779860
  • 665
  • 1
  • 7
  • 15

7 Answers7

41

You can use the below command

gh repo list {organization-name}

before this login with below command

gh auth login

github.com/cli/cli

sastorsl
  • 2,015
  • 1
  • 16
  • 17
7

I apologize. It was listing all my repos...on subsequent pages. Learning about "page=" and "per_page=" was all I needed, and now I can see all of the repos I need.

user779860
  • 665
  • 1
  • 7
  • 15
  • Its a shame that there is no end point to get the total count of repos under a particular org. I kinda hacked using `per_page=500` so cover most cases. https://developer.github.com/v3/repos/#list-organization-repositories – Hozefa Apr 12 '17 at 06:16
  • 1
    per_page=100 is the max value. – Favo Yang Dec 20 '20 at 08:27
  • https://api.github.com/orgs/btcgpu/repos?type=all&per_page=100&page=1 – Anbarasu May 19 '22 at 10:25
4

To add to original answer, below command can be used if there are many repositories and you wanted to fetch required number of repos. Without -L flag it returns 30 items by default.

gh repo list <org> -L <#> 
kann
  • 687
  • 10
  • 22
4

If you have gh, the github cli (https://cli.github.com/) and jq (https://stedolan.github.io/jq/) you can do this:

gh repo list $ORG -L $COUNT --json name | jq '.[].name' | tr -d '"'

where $ORG is your organization name and $COUNT is the max number of repos returned

Fielding
  • 59
  • 5
1

Download the official gh cli, the github cli (https://cli.github.com/)

gh repo list $ORG -L $COUNT --json name --jq '.[].name'

Set $ORG equal to your organization name, and $COUNT to be the amount of Repos you want to list. (Set $COUNT equal to the amount of repos in the organization if you want to list them all)

0

curl -i -u "username":"password" https://your_git_url.com/organization_name | grep "codeRepository" | awk -F '"' '{print $6}'

andy magoon
  • 2,889
  • 2
  • 19
  • 14
0

Have you tried setting the "per_page"-attribute to "0"? I have seen some APIs using a default value of for example 20, but if you activately set it to 0, like ?per_page=0 you get all pages.