Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get user activity statistics from GitHub API

I've been poking through the GitHub API documentation and I can't seem to find a way to get the data that powers the "Contribution Activity" section and the contribution chart for a user's profile. Is there a way to get this through the API?

I know that there are user/:user/events and /recieved_events endpoints, but these seem to mostly consist of when the user stars repositories. I'm uninterested in the actual information of which repository/what commit/etc, but only interested in getting a time-series (or something like that) of commit/issue/etc. activity data that forms the contribution chart and activity portions of the profile page. Ideally numbers across all Github activity regardless of which repo/repo privacy/etc.

All I'm trying to do is incorporate this into my Github pages website.

like image 785
tuckerchapin Avatar asked May 15 '26 12:05

tuckerchapin


1 Answers

Most contribution data can be fetched using Github GraphQL API - https://developer.github.com/v4/

I was using this method for doing a widget that shows the last user contributions list. And it works well and offers many of filtering/grouping opportunities

a.e you can get contribs count by day:

{
  user(login: "orn0t") {
    contributionsCollection {
      contributionCalendar {
        totalContributions
        weeks {
          contributionDays {
            contributionCount
            weekday
            date
          }
        }
      }
    }
  }
}

If you're looking for working code examples:

you can view my project on Github - https://github.com/orn0t/gh-contrib-widget.

like image 135
Alexander Gor Avatar answered May 19 '26 03:05

Alexander Gor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!