GitHub is an online tool for software collaboration.
GitHub class uses the PyGitHub library
to make requests to the GitHub REST API. The class provides methods to:
Get an individual user, organization, repo, issue, or pull request
Get lists of user or organization repos for a given
Get lists of repo issues, pull requests, and contributors for a given
Download files and tables
- API Credentials
If you have a GitHub account you can use your normal username and password to authenticate with the API.
You can also use a personal access token.
To instantiate the GitHub class using a username and password, you can store your username
and password as environmental variables (
or pass them in as arguments. Alternatively, you can provide a personal access token as an
environmental variable (
GITHUB_ACCESS_TOKEN) or as an argument.
from parsons import GitHub # Authenticate by passing a username and password arguments github = GitHub(username='my_username', password='my_password') # Authenticate by passing an access token as an argument github = GitHub(access_token='my_access_token') # Authenticate with environmental variables github = GitHub()
With the class instantiated, you can now call various endpoints.
# Get repo by its full name (account/name) parsons_repo = github.get_repo("move-coop/parsons") # Get the first page of a repo's issues as a Table parsons_issues_table = github.list_repo_issues("move-coop/parsons") # Download Parsons README.md to local "/tmp/README.md" parsons_readme_path = github.download_file("move-coop/parsons", "README.md", local_path="/tmp/README.md")
- class parsons.GitHub(username=None, password=None, access_token=None)[source]
Creates a GitHub class for accessing the GitHub API.
parsons.utilities.check_envto load credentials from environment variables if not supplied. Supports either a username and password or an access token for authentication. The client also supports unauthenticated access.
- username: Optional[str]
Username of account to use for credentials. Can be set with
- password: Optional[str]
Password of account to use for credentials. Can be set with
- access_token: Optional[str]
Access token to use for credentials. Can be set with