Skip to main content

GitHub Client SDK — Python Library for GitHub API Automation

PyPI version Python Version License: MIT Build Status Downloads

Overview

GitHub Client SDK is a powerful and easy-to-use Python library designed to simplify interaction with the GitHub REST API v3 and automate GitHub Actions workflows, environment variables, and repository management tasks.

This SDK provides a clean interface for developers, DevOps engineers, and automation specialists to seamlessly integrate GitHub operations into Python projects and CI/CD pipelines.

Key Features

  • 🔄 GitHub Actions Workflow Management: Create, list, and delete workflows effortlessly via Python.
  • 🔐 OAuth Authentication Support: Securely authenticate using OAuth tokens.
  • ⚙️ Environment Variable Handling: Create, update, and delete environment variables for GitHub workflows.
  • 🧩 Lightweight & Extensible: Minimal dependencies and easy to extend for custom needs.
  • 🚀 Supports Python 3.9+: Compatible with modern Python environments.
  • 💻 Interactive CLI: Built-in command-line interface for easy interaction.

Installation

Install the latest version of GitHub Client SDK directly from PyPI:

pip install github-client-sdk

Or clone the repository and install dependencies:

git clone https://github.com/azimhossaintuhin/github-client-sdk.git
cd github-client-sdk
pip install -r requirements.txt

Quick Start Guide

Authentication

from github_client_sdk.auth import AuthClient
import os

# Initialize the auth client
auth = AuthClient(
    client_id=os.getenv("CLIENT_ID"),
    client_secret=os.getenv("CLIENT_SECRET"),
    redirect_uri="http://localhost:8000/callback",
    scope=["repo", "user:email", "workflow"]
)

# Get authentication URL
auth_url = auth.get_auth_url()
print(f"Visit this URL to authorize: {auth_url}")

# Get access token
code = input("Enter the authorization code: ")
access_token = auth.get_access_token(code)

# Get user information
user_info = auth.get_user_info(access_token)
print(user_info)

Managing Workflows

from github_client_sdk.client import GitHubClient
from github_client_sdk.workflow import Workflow

# Initialize the client
client = GitHubClient(token="your_oauth_token")

# Create workflow instance
workflow = Workflow(client, "username", "repository_name")

# Create a new workflow
workflow_name = "new-workflow"
workflow_path = "path/to/workflow.yaml"
response = workflow.create_workflow(workflow_name, workflow_path)
print(f"Workflow creation response: {response}")

# List workflows
workflows = workflow.get_workflows()
print(workflows)

# Delete workflow
workflow.delete_workflow("workflow_id")

Managing Environment Variables

from github_client_sdk.variables import Variables

# Initialize variables client
variables = Variables(client, "username", "repository_name")

# Get all variables
all_variables = variables.get_variables()
print(all_variables)

# Create a new variable
variables.create_variable("TEST_VARIABLE", "TEST_VALUE")

# Update an existing variable
variables.update_variable("TEST_VARIABLE", "NEW_VALUE")

# Get a specific variable
variable = variables.get_variable("TEST_VARIABLE")
print(variable)

# Delete a variable
variables.delete_variable("TEST_VARIABLE")

Using the CLI

The SDK comes with a built-in CLI for easy interaction:

# Start the interactive shell
github-client-shell

# Available commands in the shell:
# 1. authenticate     : Authenticate with GitHub
# 2. get-user-info   : Fetch and display user info
# 3. set-env-variable: Set environment variables
# 4. get-env-variables: Get environment variables
# 5. logout          : Logout from GitHub
# 6. clear           : Clear the screen
# 7. exit            : Exit the shell

Environment Variables

The SDK requires the following environment variables to be set:

  • CLIENT_ID: Your GitHub OAuth App client ID
  • CLIENT_SECRET: Your GitHub OAuth App client secret

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md guide before submitting a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Metadata

Release files for github-client-sdk 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for github-client-sdk 1.1.2
File Size Uploaded Provenance Actions
github_client_sdk-1.1.2.tar.gz 10.9 kB Without provenance Details for github_client_sdk-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for github-client-sdk 1.1.2
File Interpreter ABI Platform Actions
github_client_sdk-1.1.2-py3-none-any.whl Python 3 none any Details for github_client_sdk-1.1.2-py3-none-any.whl

Total release size: 24.9 kB

Release files / github_client_sdk-1.1.2.tar.gz

Download URL github_client_sdk-1.1.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e17e70898ac3e3d168a983b8bf2944095942198094cd055f1a2c6bb274f758e5
BLAKE2b-256 checksum
How to use checksums
555aa35227cf1692c7086abcf24da3731c1f99b73e06cb09588687aa8a019380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

Release files / github_client_sdk-1.1.2-py3-none-any.whl

Download URL github_client_sdk-1.1.2-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bc6defb11c6635eebad48fe7ab5b16172e5763de554a91c308af1fab42a0fb3
BLAKE2b-256 checksum
How to use checksums
b87f311cd90b7ee845c2be1f505f626226f99f49b4f311e975812ceefdf90416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

Security for github-client-sdk 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page