API Github list contributors #24355
-
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! |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
No, you’re not doing anything wrong. As it states in the documentation:
Therefore, on larger repos, you may not be able to replicate the exact figure that we show on the website. |
Beta Was this translation helpful? Give feedback.
-
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 ? |
Beta Was this translation helpful? Give feedback.
-
The GitHub page has the correct number. Here’s why the API might give a higher number than you expect:
Using the example numbers, the GitHub page would read as 501 contributors but you would see 502 records. |
Beta Was this translation helpful? Give feedback.
-
Got it! Thank you for your explanations ! |
Beta Was this translation helpful? Give feedback.
-
Hi, I have the same problem. The GitHub page shows 834 contributors. https://api.github.com/repos/apple/swift/contributors?page=1002&per_page=1&anon=true I have listed all contributors and removed duplicates by “name”. After that, the list still has 910 contributors. Why do I still have more than 834 contributors? Could you please give me an idea of how can I get the exact number on the GitHub page? I would be thankful if you explain who is Anonymous user. I didn’t understand why some users are anonymous. As far as I know, the first 500 contributors are linked with the corresponding user, and others are anonymous. Why anonymous users exist before the 500th contributor? For example, the 350th contributor is anonymous |
Beta Was this translation helpful? Give feedback.
-
A user can be “anonymous” if there is no GitHub user associated with a given email address. And the reason that your number still may not match the one given by the UI is because the same GitHub user may have contributed using multiple email addresses. This is why I said above:
The API simply doesn’t return the information you need in order to be able to replicate the number we show. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explaination 😄 |
Beta Was this translation helpful? Give feedback.
No, you’re not doing anything wrong. As it states in the documentation:
Therefore, on larger repos, you may not be able to replicate the exact figure that we show on the website.