Skip to content

Instantly share code, notes, and snippets.

@geekygirldawn
Last active October 7, 2022 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekygirldawn/ef3bd920d1360ad1eed28bd647764f07 to your computer and use it in GitHub Desktop.
Save geekygirldawn/ef3bd920d1360ad1eed28bd647764f07 to your computer and use it in GitHub Desktop.
Get total GitHub contributions per year for a user
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