Skip to main content

Qing 平台统一 SDK - Python 客户端(与 npm 版 qing-client 对齐)

Project description

qing-client (Python)

Qing 平台统一 SDK 的 Python 版本,与 npm 包 qing-client 的 API 设计对齐。

安装

pip install -e /path/to/client/pip
# 或发布后
pip install qing-client

使用

网关模式(前端/统一网关)

from qingclient import Client
from qingclient.types import ClientConfig

config = ClientConfig(
    gateway_url="https://your-gateway.example.com",
    project_id="your-project-id",
    # 可选: org_id, app_id
)
client = Client(config)

# 登录后设置 token
res = client.auth.login("user", "password")
client.set_token(res.access_token)

# 调用各服务
user = client.user.get_current_user()
messages = client.msg.get_messages()

后端模式(直连各服务)

直连时各服务 URL 需包含该服务在后端的路径前缀,例如 token 服务为 .../api/token,这样 path /wxh5/accesstoken 才会请求到正确的完整路径。详见根目录 client/README.md 的「SDK 与现有架构对齐说明」。

from qingclient import Client
from qingclient.types import ClientConfig, UserContext

config = ClientConfig(
    auth_service_url="http://auth-svc",
    msg_service_url="http://msg-svc",
    user_service_url="http://user-svc",
    token_service_url="http://token-svc/api/token",  # 含路径前缀
    # ... 其他服务 URL
)
client = Client(config)

# 设置用户上下文(模拟请求方)
client.set_user_context(UserContext(
    user_id="uid",
    role="ADMIN",
    project_id="pid",
))

# 调用服务
messages = client.msg.get_messages()

服务列表(与 npm 一致)

  • client.auth - 认证
  • client.msg - 消息
  • client.user - 用户
  • client.token - Token 中控(公众号/小程序 access_token、jsapi_ticket、签名、小程序登录与获取手机号等)
  • client.file - 文件
  • client.ai - AI 对话
  • client.aigc - AIGC
  • client.provider - 提供商
  • client.usage - 用量
  • client.audit - 审计日志
  • client.fronthost - 前端托管
  • client.org - 组织
  • client.delivery_stream - 投递流
  • client.ez_ability - Ez 能力
  • client.im - IM
  • client.hub - 能力枢纽
  • client.task - 任务

版本

与 npm 包版本号对齐,见 pyproject.toml / setuptools-scm 或根目录 client 版本说明。

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

qing_client-0.0.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

qing_client-0.0.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file qing_client-0.0.0.tar.gz.

File metadata

  • Download URL: qing_client-0.0.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for qing_client-0.0.0.tar.gz
Algorithm Hash digest
SHA256 3951032fc1f63e89bdb695b20a32b66716ecec5e1a6babfb7563ba5c87328048
MD5 64daafb6c595f26d776efeee2654f8f2
BLAKE2b-256 c49a99232290a9041336743e4bf22d52993ecf1855a14458269ad77549b41d0e

See more details on using hashes here.

File details

Details for the file qing_client-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: qing_client-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for qing_client-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c1f492cc309bd33aa39fef47c6b92d35d854ebf0fac9d867472b3d5f49b1efd
MD5 567d27108ed17603a8c59b727471e18e
BLAKE2b-256 37cd83d934929c2003a7c5879e0ee0fd766ad2022e09e9bace5b8cd6a0c883b3

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