Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub API: how to get total number of accessible repositories

What is the GitHub API endpoint that provides the info on the TOTAL number of repositories a user has access to?

I don't just mean repos that the user owns, or repos the user has as public, I mean ALL repos. Basically, the same list that user would see when browsing the repos on GitHub.com when logged in.

I know how to get a list of those, but that's limited to 100 at a time. Is there an API endpoint that would simply return the TOTAL number of them, without my having to retrieve all of them and count?

like image 532
user1902183 Avatar asked Oct 17 '22 17:10

user1902183


1 Answers

Only the GraphQL API v4 would allow such a query with a "total number" request.

You can test queries in developer.github.com.

The query using repositories is only for repos accessible by a user, not for all GitHub repos. (RepositoryConnection)

query {
  viewer {
    repositories(isFork: false) {
      totalCount
    }
  }
}

But for all repositories, you would need to use Google BigQuery GitHub Data, which you can start exploring though dataset/bigquery-public-data:github_repos.

like image 123
VonC Avatar answered Oct 20 '22 22:10

VonC