Skip to main content

Asyncio-native Python client for the TrueNAS JSON-RPC WebSocket API

Project description

aiotruenas

Asyncio-native Python client for the TrueNAS JSON-RPC 2.0 WebSocket API (ws(s)://<host>/api/current, TrueNAS 25.04+).

No dependency on Home Assistant or any other framework — usable as a standalone library.

Installation

pip install .

Usage

import asyncio

from aiotruenas import TrueNASClient


async def main() -> None:
    async with TrueNASClient("truenas.local", "1-abcdef...") as client:
        info = await client.call("system.info")
        print(info)

        sub_id, _ = await client.subscribe("app.stats")
        try:
            events = await client.get_subscription_events(sub_id, event_timeout=5.0)
            print(events)
        finally:
            await client.unsubscribe(sub_id)


asyncio.run(main())

call() is a generic RPC surface — pass any TrueNAS JSON-RPC method name and its params (list or dict). Long-running operations that return a job id (scrub, replication, dataset lock/unlock, ...) can be polled automatically with job=True:

await client.call("pool.scrub.scrub", ["tank", "START"], job=True)

Connection and protocol failures are raised as typed exceptions (see aiotruenas.exceptions) rather than returned as an error code/string, so callers can except TrueNASAuthenticationError, except TrueNASConnectionError, etc.

Status

Early development (v1: generic call surface only, no typed per-domain convenience methods yet). See PROMPT.md for the full design brief and CLAUDE.md for repo guidance.

License

Apache-2.0, see LICENSE.

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

aiotruenas-1.1.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

aiotruenas-1.1.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file aiotruenas-1.1.0.tar.gz.

File metadata

  • Download URL: aiotruenas-1.1.0.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for aiotruenas-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b2e94f3a458799e831908d6f712cba2140fcb15907fae85c6adf0a6b8ec208f4
MD5 393ee14e05e3de0ad1f0a7838b02627a
BLAKE2b-256 f9c8a3bdc90c3684ce3a2a3028073da57696bd5816a8b48240929cadd483fe3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiotruenas-1.1.0.tar.gz:

Publisher: pypi.yaml on kayl-codes/aiotruenas

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

File details

Details for the file aiotruenas-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiotruenas-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for aiotruenas-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edaf06e3003781747c00cd7be86b69fc14c54360846dace09782011e2ad1a8f0
MD5 e1863a89ee186118782b9946ef6c5b82
BLAKE2b-256 75ffbf7e3cf0afd686b0a584e031fc07cbc87213c003dfe95f70e2694fd0b263

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiotruenas-1.1.0-py3-none-any.whl:

Publisher: pypi.yaml on kayl-codes/aiotruenas

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