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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chattolib-0.4.2.post2.tar.gz
  • Upload date:
  • Size: 124.1 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.post2.tar.gz
Algorithm Hash digest
SHA256 5678978dff575b04f7a363279c4901a2ebb91ded7133d721e2aca1be628d7bee
MD5 0625abcc71e545ed6414a486e11dfa80
BLAKE2b-256 4f71a91167a06e1eb31a9cf9b16f442c4f10442c5d99672a6a093a06a13776f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chattolib-0.4.2.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 79783159392a3f54b811997cac4805fad9a653a27e8743915999ab180cf36483
MD5 82810b4071c8f35d3b042a460d3f7b32
BLAKE2b-256 0337b287f25c0351e6d25f12df6da7aa62e4c475524da4b1bbe33513ce826e0d

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