GitHarbor
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
*_asynctwin (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
githarborcommand. - 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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| githarbor-1.0.3.tar.gz | 75.8 kB | With provenance | Details for githarbor-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| githarbor-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for githarbor-1.0.3-py3-none-any.whl |
Total release size: 168.7 kB
Release files / githarbor-1.0.3.tar.gz
| Download URL | githarbor-1.0.3.tar.gz |
|---|---|
| Size | 75.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9a2575c89ca8b84ee2832503e1366eaa7ffaf04a9828b3bb31009542ff58015
|
|
BLAKE2b-256 checksum How to use checksums |
6976e088c13673613538cc0a6fa76bc0b9498de25f0f61b464ac8e9ef07c25c9
|
| 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 22, 2026.
Transparency logRelease files / githarbor-1.0.3-py3-none-any.whl
| Download URL | githarbor-1.0.3-py3-none-any.whl |
|---|---|
| Size | 92.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ce8d8bf5b771f3b0fad7c9e0ad7b7e135b4ab1a50633e821ab66b29b98c5f3f
|
|
BLAKE2b-256 checksum How to use checksums |
dcf5e77ef3e03c11aa2989be4948a1d38ca09fe91008d5408da6a39d37ec3195
|
| 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 22, 2026.
Transparency logSecurity for githarbor 1.0.3
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.
Attestation for githarbor-1.0.3.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 22, 2026.
Transparency logA 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.