{"id":2045,"library":"github3-py","title":"github3.py: GitHub API Wrapper","description":"github3.py is a comprehensive Python wrapper for the GitHub API (v3), designed with a logical organization of methods to interact with the API. It is currently at version 4.0.1, requires Python 3.7+, and maintains an active, though irregular, release cadence with frequent updates and bug fixes.","status":"active","version":"4.0.1","language":"en","source_language":"en","source_url":"https://github.com/sigmavirus24/github3.py","tags":["github","api","wrapper","rest","python3"],"install":[{"cmd":"pip install github3.py","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP client for making requests to the GitHub API.","package":"requests","optional":false},{"reason":"Used for URI template expansion.","package":"uritemplate","optional":false},{"reason":"For parsing dates and times from the API responses.","package":"python-dateutil","optional":false},{"reason":"Used for JSON Web Token (JWT) handling, likely for app authentication.","package":"PyJWT","optional":false}],"imports":[{"note":"The primary function to authenticate and get a GitHub object.","symbol":"login","correct":"from github3 import login"},{"note":"General module import for accessing other utilities or API functions directly.","symbol":"github3","correct":"import github3"}],"quickstart":{"code":"import os\nfrom github3 import login\n\n# It's highly recommended to use a Personal Access Token (PAT) for authentication,\n# especially when 2FA is enabled, to avoid repeated prompts.\n# Store your token in an environment variable, e.g., GITHUB_TOKEN.\nTOKEN = os.environ.get('GITHUB_TOKEN', 'YOUR_GITHUB_TOKEN') # Replace with actual token or ensure env var is set\n\nif TOKEN and TOKEN != 'YOUR_GITHUB_TOKEN':\n    gh = login(token=TOKEN)\n    if gh:\n        print(f\"Successfully authenticated as: {gh.me().login}\")\n        # Example: Get your repositories\n        print(\"Your repositories:\")\n        for repo in gh.iter_repos(type='owner'):\n            print(f\"- {repo.name}\")\n    else:\n        print(\"Authentication failed. Check your GITHUB_TOKEN.\")\nelse:\n    print(\"GITHUB_TOKEN environment variable not set or is placeholder. Please set it for proper authentication.\")\n    print(\"You can generate a PAT at: https://github.com/settings/tokens\")","lang":"python","description":"This quickstart demonstrates how to authenticate with github3.py using a Personal Access Token (PAT), which is the recommended approach to avoid rate limits and issues with Two-Factor Authentication. It then fetches and prints the authenticated user's repositories."},"warnings":[{"fix":"Update calls to `Comparison.commits` to `Comparison.original_commits` for the old behavior (max 250 commits), or adapt to the new paginated `Comparison.commits` method for full commit lists.","message":"In version 4.0.0, the `Comparison.commits` method was renamed to `original_commits`. The `commits` method now uses GitHub's API to get the full commit list out of the compare endpoint, enabling pagination/iterator functionality. This change affects how commit lists are retrieved from `Comparison` objects.","severity":"breaking","affected_versions":"4.0.0+"},{"fix":"Review code interacting with collection iterations. If full object details are required, either fetch the full object using its ID (e.g., `gh.user(short_user.login)`) or call the `.refresh()` method on the 'short' object to populate all attributes.","message":"Starting with version 1.0.0, methods that iterate over collections (e.g., users, organizations, issues, pull requests, teams) now return distinct 'short' classes (e.g., `ShortUser`, `ShortOrganization`, `ShortIssue`, `ShortPullRequest`, `ShortTeam`) instead of the full object. This means if you expect full attributes immediately, you might need to explicitly fetch the full object or call `refresh()` on the 'short' object.","severity":"breaking","affected_versions":"1.0.0+"},{"fix":"Always use a Personal Access Token (PAT) for authentication when 2FA is enabled. PATs can be generated from your GitHub settings and provide a more secure and seamless experience. Store tokens securely, e.g., in environment variables.","message":"When using username/password authentication with GitHub's Two-Factor Authentication (2FA) enabled, `github3.py` will prompt for a 2FA code on *every* API call, which is highly inefficient and disruptive.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are referencing documentation for your installed version. For current versions (1.0.0+), use `gh.me()` to get the authenticated user object.","message":"For older versions of `github3.py` (e.g., 0.9.x), retrieving the authenticated user's information was done via `gh.user()`. In newer versions (1.0.0+), the correct method is `gh.me()`. Mixing documentation versions can lead to `AttributeError`s.","severity":"gotcha","affected_versions":"Pre-1.0.0 and 1.0.0+"},{"fix":"If you require these omitted attributes for a specific repository object, call the `.refresh()` method on that `Repository` object. This will make an additional API call to retrieve the full details. Example: `repo.refresh()`.","message":"When listing repositories via the API, GitHub often refuses to return certain attributes (e.g., `source` and `parent`) to save bandwidth. These attributes will be `None` or missing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Python environment meets the `requires_python` specification for the desired `github3.py` version. For `github3.py==4.x`, use Python 3.7+. If you must use an older Python version, consider pinning `github3.py==1.3.0`.","message":"Versions of `github3.py` prior to 1.3.0 supported older Python versions (e.g., Python 2.x, 3.5, 3.6). Current versions (4.x) require Python 3.7 or newer. Attempting to install or run newer versions on unsupported Python interpreters will result in errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}