Nav apraksta

TheCodemancer eae1a44b2e Track Chatto 0.4.9 3 mēneši atpakaļ
.beans eb66ff29f6 Track Chatto 0.4.9 3 mēneši atpakaļ
proto eb66ff29f6 Track Chatto 0.4.9 3 mēneši atpakaļ
scripts 1bd6b70c27 Switch transport to the official connectrpc Python package (0.4.2.post2) 3 mēneši atpakaļ
src eb66ff29f6 Track Chatto 0.4.9 3 mēneši atpakaļ
tests 1bd6b70c27 Switch transport to the official connectrpc Python package (0.4.2.post2) 3 mēneši atpakaļ
.beans.yml afd27f241a Update for Chatto v0.1.0-beta.3 schema 4 mēneši atpakaļ
.gitignore 7128b64618 Stop tracking robochatto.env and robochatto.db 3 mēneši atpakaļ
CLAUDE.md 1bd6b70c27 Switch transport to the official connectrpc Python package (0.4.2.post2) 3 mēneši atpakaļ
LICENSE c73577aeac Add README, MIT license, and PyPI long description 6 mēneši atpakaļ
README.md 23cc5182bd Implement realtime WebSocket client (chatto.realtime.v1) 3 mēneši atpakaļ
pyproject.toml eb66ff29f6 Track Chatto 0.4.9 3 mēneši atpakaļ

README.md

chattolib

Unofficial async Python client library for the Chatto webchat API.

Chattolib versions track the Chatto server version they target. 0.4.2 targets Chatto 0.4.2's ConnectRPC API. The upstream server dropped GraphQL in favour of a protobuf-first Connect API (see ADR-042 in chattocorp/chatto), and this release is a full rewrite for that transport. Request/response traffic uses Connect JSON over HTTP; 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
    async with await ChattoClient.login("username", "password") as client:
        me = await client.me()
        print(f"Logged in as {me.display_name}")

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

asyncio.run(main())

Realtime

Install with the extra:

pip install 'chattolib[realtime]'

Then stream live events:

from chattolib import stream_events

async with await ChattoClient.login("username", "password") 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.call(service, method, request) invokes any Connect RPC by full service name, e.g. await client.call("chatto.api.v1.MessageService", "GetMessage", {"roomId": ..., "eventId": ...}).

License

MIT