GitHub is an online tool for software collaboration.

This 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 username or organization_name

  • Get lists of repo issues, pull requests, and contributors for a given repo_name

  • 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 (GITHUB_USERNAME and GITHUB_PASSWORD), 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 to local "/tmp/"
parsons_readme_path = github.download_file("move-coop/parsons", "", local_path="/tmp/")


class parsons.GitHub(username=None, password=None, access_token=None)[source]

Creates a GitHub class for accessing the GitHub API.

Uses parsons.utilities.check_env to 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 GITHUB_USERNAME environment variable.

password: Optional[str]

Password of account to use for credentials. Can be set with GITHUB_PASSWORD environment variable.

access_token: Optional[str]

Access token to use for credentials. Can be set with GITHUB_ACCESS_TOKEN environment variable.