GitHubKit: GitHub SDK for Python

0.15.3 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

import os
from githubkit import GitHub

github_token = os.environ.get('GITHUB_TOKEN', '')

if not github_token:
    print("Error: GITHUB_TOKEN environment variable not set.")
else:
    github = GitHub(github_token)
    try:
        # Get information about the authenticated user
        user = github.rest.users.get_authenticated_user()
        print(f"Hello, {user.data.login} (ID: {user.data.id})!")

        # Example: list repositories for the authenticated user
        repos = github.rest.repos.list_for_authenticated_user()
        print(f"You have {len(repos.data)} repositories.")

    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →