Skip to main content

Async Python client library for the Chatto webchat Connect API

Project description

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

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

chattolib-0.4.2.post1.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

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

chattolib-0.4.2.post1-py3-none-any.whl (55.1 kB view details)

Uploaded Python 3

File details

Details for the file chattolib-0.4.2.post1.tar.gz.

File metadata

  • Download URL: chattolib-0.4.2.post1.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for chattolib-0.4.2.post1.tar.gz
Algorithm Hash digest
SHA256 2f69a0408a16a3a609414055b9a1524381dbebef1720222347fa3afa0db04aad
MD5 32d024fca1b5325cfb41de3ee8b28f4f
BLAKE2b-256 18ab143f5ead29d4e07a5c7b8f4e1d539849e9f041a4c64d0001ee718d732b9c

See more details on using hashes here.

File details

Details for the file chattolib-0.4.2.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for chattolib-0.4.2.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 34f6104b9357943bb43a11ba24d80bfb8b84dbd1a7c4301fa7e9f11bfa3e1f8d
MD5 601b79baeb54f829388602096e22456b
BLAKE2b-256 ca1ca891028a75bd27685adbbfa4f7d4ef3f135843ee5e215bb3f030815fe932

See more details on using hashes here.

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