A Python interface for Github's user contribution system

api-client, api-wrapper, github, github-api, python, python-library
pip install GithubContributions==0.3.0



:octocat: A Python interface for Github's user contribution system

Build Status Documentation Status PyPI version MIT Licensed

>>> from github_contributions import GithubUser
>>> user = GithubUser('bcongdon')
>>> print(user.contributions().today())
Day(, 7, 15), count=2, level=1)


$ pip install githubcontributions
$ python
>>> import github_contributions

Why github_contributions?

The Github Data API does not provide data on the contribution graphs for users. While you can get fine-grained details on the stats of specific repositories, there is not currently an API for a user's overall contributions.

Calculating a user's contributions by aggregating their repositories is expensive, and can require a prohibitive number of API calls. github_contributions can fetch an entire year of contribution data in 1 request.

github_contributions exposes user contribution data (i.e. the sum of commits, issues created, and PRs reviewed per day), and also exposes Github's 'contribution level' data (the colors displayed on the contribution graph).

Basic Usage

Getting a User's Contribution History

from github_contributions import GithubUser

user = GithubUser('bcongdon')
contribs = user.contributions()

# Day(, 7, 10), count=6, level=1)

contribs_2016 = user.contributions(start_date='2016-01-01', end_date='2016-12-31')
print(sum([day.count for day in contribs_2016.days]))
# 1509

Getting a User's Current Streak

from github_contributions import GithubUser

user = GithubUser('bcongdon')
streak = user.current_streak()
# 501

# 2016-03-02)

Getting a User's Past Streaks

from github_contributions import GithubUser

user = GithubUser('sindresorhus')
contributions = user.contributions()
streaks = contributions.streaks()

# 30

# 2017-07-15


Read more about the github_contributions API on the ReadTheDocs page.

Projects that use github_contributions

github_contributions is used in the following projects. If you have a project that does something neat with this library, submit a PR or send me a message to be added to this list. 😀

  • git-trophy - Create a 3D Printed Model of Your Github Contributions


Contributions to github_contributions are welcomed! 😁

  1. Fork the repo.
  2. Create a new feature branch.
  3. Add your feature / make your changes.
  4. Install tox (pip install tox) and run tox in a terminal window to run the test and linting suite.
  5. Create a PR.
  6. ???
  7. 🎉 Profit. 🎉


Inspired by akerl's githubstats Ruby gem