async-zulip-bot-sdk

AsyncClient API

AsyncClient is the core async client for talking to the Zulip server.

Class: AsyncClient

from bot_sdk import AsyncClient

Initialization

client = AsyncClient(
    email: str | None = None,
    api_key: str | None = None,
    config_file: str | None = None,
    verbose: bool = False,
    retry_on_errors: bool = True,
    site: str | None = None,
    client: str | None = None,
    cert_bundle: str | None = None,
    insecure: bool | None = None,
    client_cert: str | None = None,
    client_cert_key: str | None = None,
)

Parameters

Config file format

[api]
email=bot@example.com
key=your-api-key-here
site=https://your-zulip-server.com

Key Methods

Lifecycle

User info

Messages

Events & long polling

Streams

Presence

Low-level

Usage Patterns

Context manager

async with AsyncClient() as client:
    profile = await client.get_profile()
    print(profile.full_name)

Manual management

client = AsyncClient()
try:
    await client.ensure_session()
    # ... use client ...
finally:
    await client.aclose()

With BotRunner

from bot_sdk import BotRunner, BaseBot

runner = BotRunner(
    lambda c: MyBot(c),
    client_kwargs={"config_file": "~/.zuliprc"}
)

async with runner:
    await runner.run_forever()

Exceptions

Notes