4

I'm making an Android app that uses the GitHub API. My goal is to make a list of repositories for a github user.

I've tried using GET /users/:username/repos, but it doesn't return all of the info I need. How can I get all of the repository data for each repository belonging to the user?

damon
  • 14,485
  • 14
  • 56
  • 75

1 Answers1

4

By making requests to /users/:username/repos you get the list of repositories for the specified user but they contain the important fields. This is called Summary Representation.

Stars

The list of repositories contain repository objects containing the stargazers_count which is the number of stars.

Commits count

Get the contributors and sum the commit counts, like described in this answer.

Releases

Use the /repos/:owner/:repo/releases endpoint:

GET /repos/:owner/:repo/releases?per_page=1

Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
      <https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999

You can use rel="last" from the the Link header to get the releases count (in this example 5).

By using per_page=1 we limit the number of objects per page to one, so we can just get then the number of pages and know it's the same with the number of releases.

Community
  • 1
  • 1
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474