Skip to main content

Async Python client for the Karakeep API

Project description

aiokarakeep

Async Python client for the Karakeep API.

This package is intended to provide the API communication layer for the Karakeep Home Assistant integration. It accepts an injected aiohttp ClientSession, which lets Home Assistant own connection pooling and lifecycle.

Requirements

  • Python 3.11 or newer
  • aiohttp 3.9 or newer

Installation

pip install aiokarakeep

Usage

from aiohttp import ClientSession
from aiokarakeep import KarakeepClient


async with ClientSession() as session:
    client = KarakeepClient(
        base_url="https://karakeep.example.com",
        token="YOUR_API_TOKEN",
        session=session,
    )
    stats = await client.async_get_stats()

API

KarakeepClient expects:

  • base_url: Karakeep instance URL, for example https://karakeep.example.com
  • token: Karakeep API token
  • session: caller-owned aiohttp.ClientSession
  • timeout: optional request timeout in seconds, defaulting to 15

Available methods:

  • async_get_stats() calls GET /api/v1/users/me/stats and returns the JSON object from Karakeep.
  • async_get_health() calls GET /api/health and returns the JSON object plus status_code. If the endpoint returns non-JSON content, the method returns {"status": "unknown", "status_code": ...}.
  • async_get_version() calls GET /api/version and returns the version string, or None when the endpoint is unavailable or does not expose a version.

Exceptions

The client maps transport and response failures to typed exceptions:

  • KarakeepAuthError: Karakeep returned HTTP 401 or 403.
  • KarakeepConnectionError: Karakeep could not be reached.
  • KarakeepTimeoutError: the request timed out.
  • KarakeepInvalidResponseError: Karakeep returned malformed or unexpected JSON.
  • KarakeepApiError: Karakeep returned another HTTP error, or aiohttp reported a generic client error.

All package exceptions inherit from KarakeepError.

Development

uv run --extra test pytest -q

Build and check release artifacts:

uv run --extra release python -m build --installer uv
uv run --extra release twine check dist/*

See RELEASE_CHECKLIST.md before publishing a release to PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiokarakeep-0.3.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiokarakeep-0.3.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file aiokarakeep-0.3.0.tar.gz.

File metadata

  • Download URL: aiokarakeep-0.3.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiokarakeep-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0760ac3c2ad84c89258814ef4f4f4bded93c7cf69016db623f2acc98ae29fe63
MD5 8a86a14158d20434da910d46220e01d1
BLAKE2b-256 be9037ab6ecc5894745bc4a96ec54d21e62abf4d670e26193e2ebc7e955c7def

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiokarakeep-0.3.0.tar.gz:

Publisher: publish.yml on sli-cka/aiokarakeep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiokarakeep-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiokarakeep-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiokarakeep-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7f7e0f171554d165d5db5308e3c1b8dac1a0474d119ef2f082cb514707c161e
MD5 4f78f7cab90e22e6462942dbccd66e7c
BLAKE2b-256 b5b073b1d8747ad8e35e9760c0e0bf394dc939ba899507a64b0bdfa3887e959b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiokarakeep-0.3.0-py3-none-any.whl:

Publisher: publish.yml on sli-cka/aiokarakeep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page