Async Python SDK for BoChat platform
Project description
bochat-sdk (Python)
BoChat 平台 Python 异步 SDK,接口语义与 crates/bochat_sdk Rust 版本保持一致。
安装
pip install bochat-sdk
启用 WebSocket 能力:
pip install "bochat-sdk[ws]"
本地开发安装:
cd python-sdk
pip install -e .
pip install -e ".[ws]"
运行 Example
简易运行说明见:
WS 相关对齐示例:
examples/ws_observe.pyexamples/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
Release history Release notifications | RSS feed
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.1.tar.gz
(21.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bochat_sdk-0.1.1.tar.gz.
File metadata
- Download URL: bochat_sdk-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fe6a9cd513fc53a1924d33804ff641eec098ddf2393e452f9beb3d680ebd214
|
|
| MD5 |
bd08f5d17298aeeec7e4c3b272a635a5
|
|
| BLAKE2b-256 |
eeec48bbbbccc23f141204ffa2a8a425af3c34eb71b81bf2eecce753eb349652
|
File details
Details for the file bochat_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bochat_sdk-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0bb3feeb5472e53227327a8962e4ab7b1417ea132ae634de745f77c13250bec
|
|
| MD5 |
9f13c1c4423c6f848db6d0213f6e0410
|
|
| BLAKE2b-256 |
5969b81de578a0b00249527da4b12fc6e734f9af5303798e449f97446ffaf077
|