Skip to main content

Async Python SDK for BoChat platform

Project description

bochat-sdk (Python)

BoChat 平台 Python 异步 SDK,接口语义与 crates/bochat_sdk Rust 版本保持一致。

安装

cd python-sdk
pip install -e .

启用 WebSocket 能力:

pip install -e ".[ws]"

运行 Example

简易运行说明见:

WS 相关对齐示例:

  • examples/ws_observe.py
  • examples/ws_dispatcher.py

ws_dispatcher.py 使用 Python 装饰器注册处理器(更贴合 Python 风格)。

快速开始

import asyncio
from bochat_sdk import BochatClient, CreateGroupRequest


async def main() -> None:
    client = BochatClient.builder("http://127.0.0.1:8080").build()
    try:
        await (
            client.auth()
            .login()
            .account("demo_user_01")
            .password("Passw0rd!")
            .send()
        )

        bots = await client.bots().list()
        first_bot = bots[0]
        client.set_bot_token(first_bot.token)

        group = await client.groups().create(
            CreateGroupRequest(
                name="python-sdk-demo",
                description="created by python sdk",
                group_code="PYSDK001",
                bot_id=first_bot.bot_id,
            )
        )

        sent = await client.messages().send_text(group.group_id, "hello from python sdk")
        print("msg_id=", sent.msg_id)
    finally:
        await client.close()


if __name__ == "__main__":
    asyncio.run(main())

对齐能力

  • 注册/登录 + 自动保存 user token
  • Bot 列表、创建、更新、删除、一键选中 bot token
  • 群创建/删除
  • 消息发送(含幂等键)和历史拉取
  • 文件上传/删除与下载 URL 构造
  • 可选 WebSocket 会话(自动重连、心跳、事件队列)

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

bochat_sdk-0.1.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

bochat_sdk-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file bochat_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: bochat_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for bochat_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 16c366e9604e07604bb262dddf29b789624a6d0c34b17c1a8f3ad2005e753555
MD5 52cee6e71b9895c85ed6aff25834f5c6
BLAKE2b-256 8d919a09e0ede0d778b6ff8ba65824ff97d0b27b2103aaaa9ee56f8e803eab9a

See more details on using hashes here.

File details

Details for the file bochat_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bochat_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for bochat_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee82c83de14626b7c12c1c0aec54c81bcf018ac54d5f2a27814788e22d3b6a94
MD5 d7547ba62f0628118f3658a41163643a
BLAKE2b-256 cb3cf50a55058167d4e9e9862a8f64012d1729686697e2f2c5f54dc72b4eacdb

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