{"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":"python","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,"search_vec":"'3.7':36 '4.0.1':33 'activ':40 'api':3,14,27,52 'bug':49 'cadenc':44 'comprehens':8 'current':30 'design':16 'fix':50 'frequent':46 'github':2,13,51 'github3.py':1,5 'interact':24 'irregular':42 'logic':19 'maintain':38 'method':22 'organ':20 'python':9,35 'python3':55 'releas':43 'requir':34 'rest':54 'though':41 'updat':47 'v3':15 'version':32 'wrapper':4,10,53","created_at":"2026-04-09T18:41:09.810268+00:00","updated_at":"2026-04-16T15:17:06.122352+00:00","problems":[{"fix":"Run `pip install github3.py` to install the library.","cause":"The 'github3.py' library is not installed in the Python environment you are currently using.","error":"ModuleNotFoundError: No module named 'github3'"},{"fix":"Authenticate using a valid Personal Access Token with the required scopes: `import github3; gh = github3.login(token='YOUR_PERSONAL_ACCESS_TOKEN')`","cause":"The provided GitHub username and password, or personal access token, is incorrect, expired, or lacks the necessary scopes for the requested operation.","error":"github3.exceptions.AuthenticationFailed: 401 Bad credentials"},{"fix":"Verify the spelling and existence of the resource. If it's a private resource, ensure your Personal Access Token has the correct scopes and that the token is valid and active.","cause":"The specific resource (e.g., repository, file, user, Gist) you are trying to access does not exist, or the authenticated user does not have sufficient permissions to view a private resource (GitHub returns 404 for non-existent or inaccessible private resources).","error":"github3.exceptions.NotFoundError: 404 Not Found"},{"fix":"Implement error handling to check the `X-RateLimit-Remaining` and `X-RateLimit-Reset` headers in API responses, and pause requests until the reset time. Using a Personal Access Token significantly increases the rate limit compared to unauthenticated requests. For example, `gh.rate_limit()` can retrieve current rate limit status.","cause":"Your application has made too many requests to the GitHub API within a short period, exceeding the allotted rate limit (either primary or secondary).","error":"API rate limit exceeded for user."},{"fix":"Consult the official `github3.py` documentation for your installed version to use the correct method or attribute. For this specific error, change `gh.me()` to `gh.user()`.","cause":"You are attempting to access a method or attribute that has been renamed or removed in the version of `github3.py` you are using (e.g., `me()` was renamed to `user()`), or the object type does not support that attribute.","error":"AttributeError: 'GitHub' object has no attribute 'me'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.1","cli_name":"github3","cli_version":"sh: 1: github3: not found","type":"library","homepage":null,"github":"https://github.com/sigmavirus24/github3.py","docs":"https://github3.readthedocs.io","changelog":"https://github3.readthedocs.io/en/latest/release-notes/index.html","pypi":"https://pypi.org/project/github3-py/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["crm-productivity","http-networking","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}