{"id":4022,"library":"githubkit","title":"GitHubKit: GitHub SDK for Python","description":"GitHubKit is a comprehensive, type-hinted SDK for interacting with the GitHub REST API and GraphQL API, and for parsing webhooks. It supports the latest GitHub API versions and provides a consistent interface for various GitHub features. The current version is 0.15.3, with frequent releases often driven by updates to GitHub's OpenAPI specification.","status":"active","version":"0.15.3","language":"en","source_language":"en","source_url":"https://github.com/yanyongyu/githubkit","tags":["github","sdk","api","rest","graphql","webhook","async"],"install":[{"cmd":"pip install githubkit","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for HTTP requests, provides async capabilities.","package":"httpx","optional":false},{"reason":"Used for data model serialization/deserialization and validation (Pydantic v2 required).","package":"pydantic","optional":false}],"imports":[{"note":"Main client for authenticated GitHub API access (tokens, personal access tokens).","symbol":"GitHub","correct":"from githubkit import GitHub"},{"note":"Client for GitHub App authentication.","symbol":"AppGitHub","correct":"from githubkit import AppGitHub"},{"note":"Function to parse GitHub webhook payloads and verify signatures.","symbol":"parse_webhook","correct":"from githubkit.webhooks import parse_webhook"},{"note":"Base exception for GitHub API errors.","symbol":"GitHubException","correct":"from githubkit.exception import GitHubException"}],"quickstart":{"code":"import os\nfrom githubkit import GitHub\n\ngithub_token = os.environ.get('GITHUB_TOKEN', '')\n\nif not github_token:\n    print(\"Error: GITHUB_TOKEN environment variable not set.\")\nelse:\n    github = GitHub(github_token)\n    try:\n        # Get information about the authenticated user\n        user = github.rest.users.get_authenticated_user()\n        print(f\"Hello, {user.data.login} (ID: {user.data.id})!\")\n\n        # Example: list repositories for the authenticated user\n        repos = github.rest.repos.list_for_authenticated_user()\n        print(f\"You have {len(repos.data)} repositories.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the GitHubKit client with a Personal Access Token (PAT) and make a simple REST API call to fetch the authenticated user's details and their repositories. Ensure `GITHUB_TOKEN` is set in your environment."},"warnings":[{"fix":"Review your API calls and ensure compatibility with GitHub REST API version 2026-03-10. If necessary, you can explicitly set an older API version when initializing the client, e.g., `GitHub(token, api_version='2022-11-28')`.","message":"In `v0.15.0`, the default GitHub REST API version was updated to `2026-03-10`. This might introduce breaking changes to existing code if your application relied on older API behaviors or response structures for endpoints that changed in the new API version. Review GitHub's API changelog for this version.","severity":"breaking","affected_versions":">=0.15.0"},{"fix":"Initialize your `GitHub` client once at the application startup or within a global scope (e.g., as a global variable, dependency injection, or FastAPI `Depends`) and pass the same instance to all functions or methods that need to interact with the GitHub API.","message":"It is highly recommended to reuse `GitHub` or `AppGitHub` client instances rather than creating a new one for each request. Creating multiple clients can lead to performance issues due to re-establishing connections and not utilizing connection pooling efficiently.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `githubkit.webhooks.parse_webhook(payload, signature, secret)` and ensure you pass the correct webhook secret configured in your GitHub App or repository settings. The `parse_webhook` function handles the signature verification automatically and raises an error if it fails.","message":"When handling GitHub webhooks, failing to verify the `X-Hub-Signature-256` header (or `X-GitHub-Signature`) can lead to security vulnerabilities, allowing attackers to send forged payloads to your endpoint.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement robust error handling for `githubkit.exception.RateLimitError`. Consider using a retry mechanism with exponential backoff, or consult the `x-ratelimit-reset` header to know when the rate limit will reset and pause requests accordingly.","message":"GitHub API requests are subject to rate limiting. Not handling `githubkit.exception.RateLimitError` or checking `response.headers['x-ratelimit-remaining']` can lead to your application being temporarily blocked.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}