Skip to main content

Harbor API Python SDK

Typed synchronous and asynchronous clients for the Harbor API.

pip install harbor-framework-client

The distribution is named harbor-framework-client and the import package is harbor_client. The unrelated harbor-client project on PyPI is a different package. Python 3.12 or newer is required. Install the tus extra for resumable uploads: pip install "harbor-framework-client[tus]".

Quickstart

from harbor_client import HarborAPIClient

with HarborAPIClient(token="your-api-key") as client:
    for job in client.jobs.list(state="running"):
        print(job.id, job.name)

token takes a string or a callable that returns the current token. Each client owns one connection pool; use it as a context manager or call close().

Async

import asyncio

from harbor_client import AsyncHarborAPIClient


async def main() -> None:
    async with AsyncHarborAPIClient(token="your-api-key") as client:
        async for job in client.jobs.list():
            print(job.id, job.name)


asyncio.run(main())

AsyncHarborAPIClient also accepts async_token, an async callable that returns the token. Call await client.aclose() when you do not use the context manager.

Pagination

List methods return pagers. Iterate a pager for items across all pages, or use iter_pages() for one page at a time:

pager = client.jobs.list(page_size="50")
for page in pager.iter_pages():
    print(len(page))

Errors

HTTP errors raise harbor_client.core.ApiError or one of its subclasses exported from harbor_client, such as NotFoundError, UnauthorizedError and ConflictError. The error carries status_code and the parsed problem body; its message shows the problem's detail. Error messages never include request or response headers.

from harbor_client import NotFoundError

try:
    client.jobs.get(job_id="3f6c2a1e-8b4d-4e2a-9c1f-5d7e8a9b0c12")
except NotFoundError as error:
    print(error.status_code, error.body)

The client validates requests and responses against the API contract it was built from. A request or response that does not match raises harbor_client.ContractError.

Configuration

Option Purpose
base_url Target another deployment. client.set_base_url(...) changes it later.
harbor_api_version API version sent in the Harbor-API-Version header. Defaults to the version this release was generated from.
timeout, retry Default request timeout in seconds and retry policy.
headers Extra headers sent with every request.
transport A custom httpx.BaseTransport, for example for proxies or tests.
httpx_client, http_client Reuse an httpx.Client or a requests.Session. An httpx.AsyncClient is not accepted.

Per call, pass request_options={"timeout_in_seconds": 30, "max_retries": 2}, or additional_headers and additional_query_parameters.

File transfers

StorageTransfers uploads and downloads task, dataset, job and trial files through signed storage grants, including resumable TUS uploads:

from pathlib import Path

from harbor_client import UploadFile
from harbor_client.transfers import StorageTransfers

transfers = StorageTransfers(client)
transfers.download(
    kind="job",
    resource_id="3f6c2a1e-8b4d-4e2a-9c1f-5d7e8a9b0c12",
    role="archive",
    destination=Path("job.tar.gz"),
)

Use AsyncStorageTransfers with AsyncHarborAPIClient. Upload sources must stay unchanged until the upload completes. A failed transfer raises StorageTransferError, which carries upload_id so complete_upload can resume a finished upload.

Reference

reference.md lists every resource and method.

License

Apache-2.0. See LICENSE.

Metadata

Release files for harbor-framework-client 0.3.0

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

Source distribution (sdist)

Source distribution for harbor-framework-client 0.3.0
File Size Uploaded Provenance Actions
harbor_framework_client-0.3.0.tar.gz 258.8 kB With provenance Details for harbor_framework_client-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for harbor-framework-client 0.3.0
File Interpreter ABI Platform Actions
harbor_framework_client-0.3.0-py3-none-any.whl Python 3 none any Details for harbor_framework_client-0.3.0-py3-none-any.whl

Total release size: 654.9 kB

Release files / harbor_framework_client-0.3.0.tar.gz

Download URL harbor_framework_client-0.3.0.tar.gz
Size 258.8 kB
Tags Source
SHA-256 checksum
How to use checksums
da4effeb230943d26725d735afeb8c83c0fdf78ea458f3031f0bb56c3277dff0
BLAKE2b-256 checksum
How to use checksums
66759596f4dcd598c31c1e5dff8f3773b21610d12e9530cc40d577f81b3bac8f
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 21, 2026.

Transparency log

Release files / harbor_framework_client-0.3.0-py3-none-any.whl

Download URL harbor_framework_client-0.3.0-py3-none-any.whl
Size 396.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c04e2b384edde07b6aba481103c02bbe138845b2a4be49dd4ad1b8fbcb4659cb
BLAKE2b-256 checksum
How to use checksums
cfbe9f1ccfd2451f3fc192b991aa0e2e08f69103b5ce5ca82318703528baef16
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 21, 2026.

Transparency log

Security for harbor-framework-client 0.3.0

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 harbor_framework_client-0.3.0.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 21, 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