Last active
October 7, 2022 09:07
-
-
Save geekygirldawn/ef3bd920d1360ad1eed28bd647764f07 to your computer and use it in GitHub Desktop.
Get total GitHub contributions per year for a user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using the GiHub GraphQL API contributionsCollection, you can get this pretty easily. | |
You need to get it for each type of contribution, but then you can add them up. Then | |
you could loop through a list of users to get this for each of them. | |
Documentation: https://docs.github.com/en/graphql/reference/objects#contributionscollection | |
Example GraphQL API Query: | |
query totalContributions{ | |
user(login: "geekygirldawn") { | |
name | |
contributionsCollection(from: "2021-01-01T00:00:00" to: "2021-12-31T00:00:00"){ | |
totalIssueContributions | |
totalCommitContributions | |
totalPullRequestContributions | |
totalPullRequestReviewContributions | |
} | |
} | |
} | |
Example Results (JSON format): | |
{ | |
"data": { | |
"user": { | |
"name": "Dawn Foster", | |
"contributionsCollection": { | |
"totalIssueContributions": 12, | |
"totalCommitContributions": 150, | |
"totalPullRequestContributions": 39, | |
"totalPullRequestReviewContributions": 13 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment