Skip to main content

chattolib

Unofficial async Python library for building bots for the Chatto webchat server.

chattolib gives you a typed, Pythonic client for Chatto's protobuf-first Connect API (every public, admin, auth and discovery RPC is wrapped, with dataclasses for the responses) and a realtime WebSocket client that streams server events as they happen. On top of those sits a small bot framework (Bot) that handles joining rooms, replying, and reacting to events.

chattolib is a bot library. It drives bot accounts, which authenticate with a key used directly as a bearer token (no password, no /auth/login round-trip). Normal humans use the Chatto web app; you reach the API here as a bot. See the bot guide.

Chattolib versions track the Chatto server version they target. The request/response side is a self-contained Connect client over httpx with generated protobuf bindings (no connectrpc dependency); the realtime channel is a binary protobuf WebSocket at /api/realtime (needs the [realtime] extra).

Install

pip install chattolib

Quick start

import asyncio
from chattolib import ChattoClient


async def main():
    # Public discovery — no auth required
    async with ChattoClient() as anon:
        profile, login = await anon.get_server()
        print(f"Chatto {profile.version}: {profile.name}")

    # Authenticated calls — a bot key is used directly as a bearer token
    async with ChattoClient(token="cht_BK_...") as client:
        me = await client.me()
        print(f"Authenticated as {me.display_name}")

        for entry in await client.list_rooms():
            if entry.room:
                print(f"  - {entry.room.name}")


asyncio.run(main())

For a full bot (event handlers, say/reply/react, presence, auto-join), use the higher-level :class:~chattolib.bot.Bot facade — see docs/bots.md.

Realtime

Install with the extra:

pip install 'chattolib[realtime]'

Then stream live events:

from chattolib import stream_events

async with ChattoClient(token="cht_BK_...") as client:
    async for event in stream_events(client):
        print(event.kind, event.actor_id, event.payload)

event.kind names the protobuf oneof case (message_posted, reaction_added, presence_changed, notification_created, …). event.payload is the concrete protobuf sub-message — access its fields directly (e.g. event.payload.room_id). Realtime events are invalidation signals; use the corresponding Connect RPC (GetRoomEventsAround, GetNotification, GetUser, …) to hydrate the referenced resource.

Escape hatch

ChattoClient.services exposes the generated Connect service clients directly (one per Chatto service), for anything the Pythonic wrappers don't yet cover. For example:

from chattolib._pb.chatto.api.v1 import messages_pb2

resp = await client.services.messages.get_message(
    messages_pb2.GetMessageRequest(room_id=..., event_id=...)
)

License

  • chattolib's own code is licensed under MPL-2.0 (Mozilla Public License 2.0) — a weak, file-level copyleft. You can use, distribute, and embed chattolib in commercial or proprietary software; modifications to the library's own files must be released under MPL-2.0.
  • Vendored Chatto protobuf definitions under proto/chatto/** and the generated bindings under src/chattolib/_pb/chatto/** are Apache-2.0, matching upstream chattocorp/chatto.
  • Vendored buf.validate material is Apache-2.0 (from bufbuild/protovalidate).

See LICENSING.md for the full picture and REUSE.toml for the machine-readable licence map.

Note: chattolib versions 0.0.1 through 0.4.9 were released under MIT. Those releases remain MIT-licensed forever on PyPI; the MPL-2.0 relicence applies to newly published releases only.

Metadata

Release files for chattolib 0.5.0.post2

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

Source distribution (sdist)

Source distribution for chattolib 0.5.0.post2
File Size Uploaded Provenance Actions
chattolib-0.5.0.post2.tar.gz 190.5 kB Without provenance Details for chattolib-0.5.0.post2.tar.gz

Built distribution (wheel)

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

Total release size: 418.8 kB

Release files / chattolib-0.5.0.post2.tar.gz

Download URL chattolib-0.5.0.post2.tar.gz
Size 190.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bdce302f3fcb10ec50506675f558a1722ef63dcc808e4ef85490ba88c56e1d23
BLAKE2b-256 checksum
How to use checksums
0a19a103c3f86208abba8b550fb40e588d5ddb0d4212f65172961ca5bbcd9a5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / chattolib-0.5.0.post2-py3-none-any.whl

Download URL chattolib-0.5.0.post2-py3-none-any.whl
Size 228.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
804de0c3855a2b2f0c41c323a13da343c168abe6ead4522e34efd5f2436282c2
BLAKE2b-256 checksum
How to use checksums
15fde5f084173f897afa429a81b483df2e2aca6dbac66eeba45babad705e9df7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for chattolib 0.5.0.post2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.5.0.post2 This release

2 release files No provenance

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