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.9.tar.gz (124.8 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.9-py3-none-any.whl (161.6 kB view details)

Uploaded Python 3

File details

Details for the file chattolib-0.4.9.tar.gz.

File metadata

  • Download URL: chattolib-0.4.9.tar.gz
  • Upload date:
  • Size: 124.8 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.9.tar.gz
Algorithm Hash digest
SHA256 7d5647f945dd37844a4c5366a46c52e3df407dbac220a362ac81950040c2d6f7
MD5 623320d03c9dfc3bba9dabdb96a1dacf
BLAKE2b-256 f4b57f4db4efd8a48ea14ea7f282176a82e762ae18cba865603296ddd1ea0064

See more details on using hashes here.

File details

Details for the file chattolib-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: chattolib-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 161.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for chattolib-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 abd89d82c21f5fc6a9bb0c248ff62e6fb13f1b14730bc60be11e0a153ddc5efe
MD5 353cbb00379fbf902ab4d3371d5b3c7d
BLAKE2b-256 9b5531d5acdb3d328d71dcdae51852ad3e92ef596131f2ea6596a8bda98ee277

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