GitHub Contributions API - Ruby Library

Published: 2016-03-16

By: MJ Rossetti



Project Page

I wanted to get a comprehensive history of my GitHub commits and store them in a database.

I started using the Octokit Ruby library to interface with the official GitHub API, but it only provides 90 days of event history.

Only events created within the past 90 days will be included in timelines. Events older than 90 days will not be included (even if the total number of events in the timeline is less than 300). -

After searching the Internet, I discovered the GitHub Archive, a service which “record[s] the public GitHub timeline, archive[s] it, and make[s] it easily accessible for further analysis.” The dataset is available on Google BigQuery.

I could have written scripts to run against Google BigQuery, but ultimately I found another existing service called the GitHub Contributions Archive which displays comprehensive event history from the GitHub Archive for each user. One of the most convenient parts of this service is that in addition to including contributions to a user’s own repositories, it also includes contributions to repositories not owned by the user.

After inquiring, I learned the Contributions Archive makes the underlying data available via JSON API.

User Request:


User Response:


Events Request:


Events Response:

    {}, {}, {}, etc ...

To interface with this data using the Ruby language, I wrote and published a small library to help facilitate the HTTP GET requests.

user = GithubContributionsApi.user("octocat")

events = GithubContributionsApi.user_events("octocat")

my_events = GithubContributionsApi.user_events("s2t2", :page => 2)

Star the repo if you find it helpful.