pip install PyGitHub
You may want to use pip3
instead of pip
.
- Log into GitHub Enterprise on your browser
- Open Settings -> Developer settings -> Personal access tokens
- Create a new access token
- Grant
repo
scope - Treat your access token as your password.
- Grant
from github import Github
g = Github(base_url="https://{YOUR_HOSTNAME}/api/v3", login_or_token=YOUR_ACCESS_TOKEN)
repo = g.get_repo("{YOUR_ORGANIZATION}/{YOUR_REPO}")
- Open issues
repo.get_issues()
- All issues
repo.get_issues(state='all')
- Specific issue
repo.get_issue(number=ISSUE_NUMBER)
Print some issue information.
issue = repo.get_issue(number=123)
print(f"{issue.number}, {issue.state}, {issue.title}, {issue.assignee}, {issue.milestone}")
issue = repo.get_issue(number=123)
issue.edit(body=NEW_DESCRIPTION)
Reference: