Skip to content

Instantly share code, notes, and snippets.

@allenh1
Created November 7, 2021 17:07
Show Gist options
  • Select an option

  • Save allenh1/9ea42c0327c1c90893cde51eede502f3 to your computer and use it in GitHub Desktop.

Select an option

Save allenh1/9ea42c0327c1c90893cde51eede502f3 to your computer and use it in GitHub Desktop.
Get GitHub Stats
from github import Github
import time
import os
token = os.getenv('GITHUB_API_TOKEN')
if not token:
print('Please create a GitHub token for use with the API')
quit()
g = Github(token)
me = g.get_user()
private_pr_count = 0
public_pr_count = 0
public_issue_count = 0
print("# Contributions")
for repo in g.get_user().get_repos():
pulls = repo.get_pulls(state='all')
issues = repo.get_issues(state='all')
for pr in pulls:
if pr.user.login == me.login:
if repo.private:
private_pr_count = private_pr_count + 1
else:
public_pr_count = public_pr_count + 1
print(" * %s (PR #%d): %s" % (repo.name, pr.number, pr.title))
for issue in issues:
if issue.user.login == me.login:
if not repo.private:
public_issue_count = public_issue_count + 1
print(" * %s (issue #%d): %s" % (repo.name, issue.number, issue.title))
time.sleep(1)
print()
print('# Summary for ' + me.name + '(' + me.login + '):')
print(' * private pull requests: %d' % (private_pr_count))
print(' * public pull requests: %d' % (public_pr_count))
print(' * public issues filed: %d' % (public_issue_count))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment