Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub API: how efficiently get the total contributors amount per repository?

Tags:

github-api

Is there a way to efficiently get the amount of all different contributors of a GitHub repository using the GitHub API?

I mean, without necessarily getting all the contributor objects and manually count the total amount.

like image 249
Francesco Borzi Avatar asked Jan 03 '23 22:01

Francesco Borzi


1 Answers

Yes, the trick is to request the list of contributors with one item per page. But include anon=true as a query param to include anonymous contributors as well

https://api.github.com/repos/:owner/:repo/contributors?per_page=1&anon=true

And in the response header (like it was mentioned in the previous answer), look for the Link property and get the value just before rel="last"

like image 104
Laksh Avatar answered Apr 27 '23 05:04

Laksh