Skip to main content

GitHarbor

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status PyUp

Read the documentation!

GitHarbor is a unified Python client for Git hosting platforms. One API covers repositories on GitHub, GitLab, Azure DevOps, Gitea / Codeberg and local Git checkouts: pass a URL (or path), get a repository object, and work with branches, commits, issues, pull requests, releases and files without caring which backend is behind it.

Key features

  • One API, many hosts: create_repository(url) picks the provider from the URL.
  • Typed results: every provider returns the same dataclasses (Branch, Commit, Issue, PullRequest, Release, Tag, User, Workflow, WorkflowRun).
  • Sync and async: every method has an *_async twin (list_issues / list_issues_async).
  • Functional API: module-level functions that take a repository URL (githarbor.functional).
  • MCP server: expose repository operations to LLM agents via the githarbor command.
  • Pick your SDKs: each backend is an optional extra, nothing heavy is installed by default.

Installation

Install GitHarbor with the extras for the platforms you need:

pip install "githarbor[github]"          # GitHub via PyGithub
pip install "githarbor[github,gitlab]"   # several providers
pip install "githarbor[all]"             # all providers, diff parsing and the MCP server
Extra Provides
github GitHub (PyGithub)
aiogithubapi GitHub (async, aiogithubapi)
gitlab GitLab (python-gitlab)
gitea / pygitea Gitea and Codeberg (giteapy / py-gitea)
azure Azure DevOps
local Local repositories (GitPython)
diff Creating pull requests from unified diffs (unidiff)
mcp MCP server (FastMCP)

Quickstart

from githarbor import create_repository

repo = create_repository("https://github.com/phil65/githarbor")

print(repo.name, repo.default_branch)
for branch in repo.list_branches():
    print(branch.name)

latest = repo.get_latest_release()
print(latest.tag_name, latest.published_at)

Credentials are passed as keyword arguments or read from environment variables (GITHUB_TOKEN, GITLAB_TOKEN, GITEA_TOKEN, AZURE_DEVOPS_PAT):

from githarbor import create_repository

github_repo = create_repository("https://github.com/owner/repo", token="github_pat_...")
gitlab_repo = create_repository("https://gitlab.com/owner/repo", token="glpat-...")
azure_repo = create_repository("https://dev.azure.com/org/project/_git/repo", token="azure_pat")
local_repo = create_repository("/path/to/checkout")  # needs the "local" extra

Working with repositories

Repository information

# Language statistics, e.g. {"Python": 10000, "JavaScript": 5000}
languages = repo.get_languages()

# Activity counts over the last 30 days
activity = repo.get_recent_activity(
    days=30, include_commits=True, include_prs=True, include_issues=True
)

Branches and tags

branches = repo.list_branches()
main_branch = repo.get_branch("main")

tags = repo.list_tags()
tag = repo.get_tag("v1.0.0")

diff = repo.compare_branches(
    base="main", head="feature", include_commits=True, include_files=True, include_stats=True
)

Commits

from datetime import datetime

commit = repo.get_commit("abcd1234")

commits = repo.list_commits(
    branch="main",
    since=datetime(2024, 1, 1),
    until=datetime(2024, 2, 1),
    author="username",
    path="src/",
    max_results=100,
)

results = repo.search_commits(query="fix bug", branch="main", max_results=10)

Issues and pull requests

open_issues = repo.list_issues(state="open")
issue = repo.get_issue(123)
new_issue = repo.create_issue(title="Bug report", body="Steps to reproduce...", labels=["bug"])

prs = repo.list_pull_requests(state="open")  # or "closed" or "all"
pr = repo.get_pull_request(456)

Releases

latest = repo.get_latest_release(include_drafts=False, include_prereleases=False)
releases = repo.list_releases(include_drafts=False, include_prereleases=True, limit=10)
release = repo.get_release("v1.0.0")

Repository content

# Download a single file or a whole directory
repo.download(path="README.md", destination="local/")
repo.download(path="src/", destination="local/src", recursive=True)

# Iterate over files
for file_path in repo.iter_files(path="src/", ref="main", pattern="*.py"):
    print(file_path)

CI/CD workflows

workflows = repo.list_workflows()
workflow = repo.get_workflow("workflow_id")
run = repo.get_workflow_run("run_id")

Contributors

contributors = repo.get_contributors(sort_by="commits", limit=10)  # or "name" / "date"

Async usage

Every operation has an async counterpart:

import asyncio

from githarbor import create_repository


async def main() -> None:
    repo = create_repository("https://github.com/phil65/githarbor")
    issues, releases = await asyncio.gather(
        repo.list_issues_async(state="open"),
        repo.list_releases_async(limit=5),
    )
    print(len(issues), [r.tag_name for r in releases])


asyncio.run(main())

Owners

create_owner() works with users and organizations (GitHub):

from githarbor.users import create_owner

owner = create_owner("https://github.com/phil65")
for repository in owner.list_repositories():
    print(repository.name)

Functional API

githarbor.functional offers the same operations as plain functions that take the repository URL first. Repository instances are cached per URL.

from githarbor.functional import get_latest_release, list_issues_async

release = get_latest_release("https://github.com/phil65/githarbor")
issues = await list_issues_async(  # inside an async function
    "https://github.com/phil65/githarbor", state="open"
)

These functions are also registered as Jinja globals and filters for jinjarope environments.

MCP server

With the mcp extra, GitHarbor runs as an MCP server:

githarbor                                  # stdio transport
githarbor --transport sse --port 8000      # SSE transport
githarbor --repo-path https://github.com/owner/repo  # tools bound to one repository

Error handling

from githarbor import create_repository
from githarbor.exceptions import (
    FeatureNotSupportedError,
    RepositoryNotFoundError,
    ResourceNotFoundError,
)

try:
    repo = create_repository("https://github.com/nonexistent/repo")
except RepositoryNotFoundError:
    print("Repository does not exist or no provider supports the URL")

try:
    issue = repo.get_issue(999999)
except ResourceNotFoundError:
    print("Issue does not exist")

try:
    workflows = repo.list_workflows()
except FeatureNotSupportedError:
    print("This provider does not support workflows")

Metadata

Release files for githarbor 1.0.4

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

Source distribution (sdist)

Source distribution for githarbor 1.0.4
File Size Uploaded Provenance Actions
githarbor-1.0.4.tar.gz 77.1 kB With provenance Details for githarbor-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for githarbor 1.0.4
File Interpreter ABI Platform Actions
githarbor-1.0.4-py3-none-any.whl Python 3 none any Details for githarbor-1.0.4-py3-none-any.whl

Total release size: 171.0 kB

Release files / githarbor-1.0.4.tar.gz

Download URL githarbor-1.0.4.tar.gz
Size 77.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eb00071f3365503c26d779cbcd2f5aeb3e2cb69c5ac01125fe0cf5caea184d36
BLAKE2b-256 checksum
How to use checksums
757ee2e2897295d9f60815960e2766f78caf3e02768cbd3ead53265b8adfeffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / githarbor-1.0.4-py3-none-any.whl

Download URL githarbor-1.0.4-py3-none-any.whl
Size 93.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
490f306d40dbe2796f96187545e07809001a014c35ceeb908fcc2e56df832abe
BLAKE2b-256 checksum
How to use checksums
b083766047c3824e92ed3b32393f7ff1ed8cd30ed6cba06a222b03ae505c3269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for githarbor 1.0.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for githarbor-1.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

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