Project

gh_contrib

0.0
No commit activity in last 3 years
No release in over 3 years
Show contributions of GitHub.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

 Project Readme

gh_contrib

GitHub has a nice feature of contributions. But unfortunately they don't offer an official API. Now somehow we can get only from here (https://github.com/users/<username>/contributions). It returns HTML 😢. This is just parsing HTML to JSON or returns as Ruby's object.

Usage

CLI

$ gem install gh_contrib

$ gh_contrib username

$ echo 'GITHUB_USERNAME=username
$ GITHUB_PASSWORD=password' > .env

# or you can define on shell
# export GITHUB_USERNAME=username
# export GITHUB_PASSWORD=password

$ gh_contrib username
$ gh_contrib username -d month

API

require 'gh_contrib'

agent = GhContrib::Agent.new
puts agent.contributions 'username'

agent.login 'username', 'password'

puts agent.contributions 'username'
puts agent.contributions_by_month 'username'

Tips

  • Sum all the contributions with jq.
$ gh_contrib banyan | jq 'reduce .[].count as $item (0; . + $item)'
4698

Limitations

  • You can't enable two factor authentication for this user if you want to get the data as logged in 😢.

Caveat

  • Since it's not an official API, it might be broken anytime 😵.