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.3.tar.gz (124.0 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.3-py3-none-any.whl (160.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chattolib-0.4.3.tar.gz
  • Upload date:
  • Size: 124.0 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.3.tar.gz
Algorithm Hash digest
SHA256 2119565abfcd40cf5f37685f7d7c9433545fe4ac5f2eb44d23e947486084ea55
MD5 a8205d24a4472b018d87b8e10eba9439
BLAKE2b-256 f3b0e2d1a6e69e8ffb90b946c30b7aef9e8c55ff45c5f642b5982f883e051da3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chattolib-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 160.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e57f640c2f3b61024fda22d44ce88c0450bcd4c2a43afb9f069274d0219e09e
MD5 0f780fb14cdd2d90f595eadaced0455f
BLAKE2b-256 aecbdf738627258153b4f969b5c240aa26e70ac1d78aaebbb8790251923873b0

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