A Python interface for Github's user contribution system
>>> from github_contributions import GithubUser
>>> user = GithubUser('bcongdon')
>>> print(user.contributions().today())
Day(date=datetime.date(2017, 7, 15), count=2, level=1)$ pip install githubcontributions
$ python
>>> import github_contributionsThe 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).
from github_contributions import GithubUser
user = GithubUser('bcongdon')
contribs = user.contributions()
print(contribs.days[0])
# Day(date=datetime.date(2016, 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]))
# 1509from github_contributions import GithubUser
user = GithubUser('bcongdon')
streak = user.current_streak()
print(len(streak))
# 501
print(streak[0].date)
# 2016-03-02)from github_contributions import GithubUser
user = GithubUser('sindresorhus')
contributions = user.contributions()
streaks = contributions.streaks()
print(len(streaks))
# 30
print(streaks[-1][0].date)
# 2017-07-15Read more about the github_contributions API on the ReadTheDocs page.
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! 😁
- Fork the repo.
- Create a new feature branch.
- Add your feature / make your changes.
- Install tox (
pip install tox) and runtoxin a terminal window to run the test and linting suite. - Create a PR.
- ???
- 🎉 Profit. 🎉
Inspired by akerl's githubstats Ruby gem