飞函官方 OpenAPI SDK for Python
Project description
飞函 IM OpenAPI SDK - Python
English | 中文
飞函,是安全稳定的私有化一站式办公平台,功能包括即时通讯、组织架构、音视频会议、网盘等。
本项目是飞函服务端的 Python SDK,用于通过 OpenAPI 与飞函服务端进行交互。使用前需要先自行部署飞函服务端,部署教程请参考快速部署文档。
安装
pip install feihan-sdk
快速开始
import asyncio
from feihan import FeihanClient, SendMessageReq, MessageContent, MessageText, MessageType_TEXT
async def main():
client = await FeihanClient.create(
"https://your-backend-url.com",
"your-app-id",
"your-app-secret",
)
# 可选:预热可提前获取访问凭证和同步服务端时间,减少首次调用的延迟
await client.preheat()
# 调用 API
resp = await client.im.message.send_message(SendMessageReq(
chat_id="chat-id",
message_type=MessageType_TEXT,
message_content=MessageContent(text=MessageText(content="飞函新版本发布!")),
))
print(resp.message_id)
# 使用完毕后关闭
await client.close()
asyncio.run(main())
客户端配置
FeihanClient.create() 支持通过关键字参数配置客户端行为:
from feihan import FeihanClient, LogLevel
client = await FeihanClient.create(
"https://your-backend-url.com",
"your-app-id",
"your-app-secret",
log_level=LogLevel.DEBUG, # 日志级别(默认: INFO)
request_timeout=30.0, # 请求超时秒数(默认: 60.0)
enable_encryption=False, # 启用请求加密(默认: True)
)
事件订阅
通过 WebSocket 接收实时事件推送:
from feihan import EventMessageReceive
def on_message(event: EventMessageReceive):
print("收到消息:", event.body)
client.im.message.event.on_message_receive(on_message)
# 取消订阅
client.im.message.event.off_message_receive(on_message)
上下文管理器
支持 async with 语法自动关闭客户端:
async with await FeihanClient.create(...) as client:
resp = await client.im.message.send_message(SendMessageReq(...))
环境要求
- Python 3.9+
相关链接
许可证
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
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 feihan_sdk-0.28.108.tar.gz.
File metadata
- Download URL: feihan_sdk-0.28.108.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
940005953b3a7ea220ff92ed41c3795c528fee928fdeaeadb0bb86b0adb45858
|
|
| MD5 |
a3faadd900fe306d79c5fbc8c6d91270
|
|
| BLAKE2b-256 |
f4c0979f66ce219d01680a727ad6f45538d2a99da268fbdc41fabeb268f9c3a4
|
Provenance
The following attestation bundles were made for feihan_sdk-0.28.108.tar.gz:
Publisher:
publish.yaml on feihan-im/openapi-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
feihan_sdk-0.28.108.tar.gz -
Subject digest:
940005953b3a7ea220ff92ed41c3795c528fee928fdeaeadb0bb86b0adb45858 - Sigstore transparency entry: 1206054048
- Sigstore integration time:
-
Permalink:
feihan-im/openapi-sdk-python@edd8a7c9f11a507f4e614e1179cd0032cd9bdd56 -
Branch / Tag:
refs/tags/v0.28.108 - Owner: https://github.com/feihan-im
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@edd8a7c9f11a507f4e614e1179cd0032cd9bdd56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file feihan_sdk-0.28.108-py3-none-any.whl.
File metadata
- Download URL: feihan_sdk-0.28.108-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f29662e0dce8b044c6413f8d7d9006f269928f2272c0c64bcb547de6a0d037f
|
|
| MD5 |
1e2b643ff8f06a10c2cb84dbf5537b10
|
|
| BLAKE2b-256 |
c8bf8e6a954346325c17c351b46e6ea4b3b5f30a2c2d2155511b97b0a954e6b9
|
Provenance
The following attestation bundles were made for feihan_sdk-0.28.108-py3-none-any.whl:
Publisher:
publish.yaml on feihan-im/openapi-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
feihan_sdk-0.28.108-py3-none-any.whl -
Subject digest:
8f29662e0dce8b044c6413f8d7d9006f269928f2272c0c64bcb547de6a0d037f - Sigstore transparency entry: 1206054053
- Sigstore integration time:
-
Permalink:
feihan-im/openapi-sdk-python@edd8a7c9f11a507f4e614e1179cd0032cd9bdd56 -
Branch / Tag:
refs/tags/v0.28.108 - Owner: https://github.com/feihan-im
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@edd8a7c9f11a507f4e614e1179cd0032cd9bdd56 -
Trigger Event:
push
-
Statement type: