API Github list contributors

Hi everyone,

I’m currently working with the GitHub API and i think there is a problem (or the mistake is mine but i don’t know where)

I tried to know the number of contributors for a specific repository thanks to this endpoint :

https://developer.github.com/v3/repos/#list-contributors

Work well on small repository but seems to be wrong on bigger repository

For example, let’s take the repository twbs/bootstrap

On the github page, it display 1007 contributors

If i try this one : https://api.github.com/repos/twbs/bootstrap/contributors?per_page=1&page=900

I want the 900th contributors. But nothing appeared. Actually, it work below the page 381, but then, up to 381, nothing appear. Like if there is only 381 contributors

So at first i tought the problem was with anonymous contributors. So i tried to add them like this :

https://api.github.com/repos/twbs/bootstrap/contributors?per_page=1&page=900&anon=true

(I added the query anon and set it to true)

And it worked. And actually it worked too much because, if i try to have the 1100th contributors like this:

https://api.github.com/repos/twbs/bootstrap/contributors?per_page=1&page=1100&anon=true

API return me a response with someone but the github page display 1007 contributors.

Am i doing something wrong ?

Thanks for help!

1 Like

No, you’re not doing anything wrong. As it states in the documentation:

To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.

Therefore, on larger repos, you may not be able to replicate the exact figure that we show on the website.

3 Likes

Thank you for your answer lee-dohm

I read this sentence in the documentation but i don’t care about GitHub user information so i tought it will work anyway with anonymous contributors

But i don’t understand, if i count anonymous contributors, why do i have more contributors than show on the GitHub page ? Who has the correct number ? The API or the GitHub page ?

The GitHub page has the correct number.

Here’s why the API might give a higher number than you expect:

  1. If the repository has more than 500 contributors (for example 501, 500 associated with GitHub information and 1 by definition anonymous)
  2. One or more of the least active contributors made commits with more than one email address (for example 2 different email addresses)

Using the example numbers, the GitHub page would read as 501 contributors but you would see 502 records.

Got it!

Thank you for your explanations !

1 Like