Skip to main content

snowland-qyweixin-python

version license python platform backend tests

Description

Unofficial open-source SDK for WeCom (Enterprise WeChat), built on top of snowland-http.

This SDK provides a unified, rate-limited HTTP transport layer via snowland-http. Every client exposes both synchronous and asynchronous (asyncio) APIs, backed by requests / httpx respectively.

Installation

Core dependencies (no concrete HTTP library — only the snowland-http transport abstraction):

pip install -r requirements.txt

HTTP backends are all optional: you can import and use the SDK without any backend installed, but calling the corresponding sync/async request methods will raise a clear message at runtime. Install only one of them as needed (do not install all at once):

pip install snowland-qyweixin[requests]   # sync only
pip install snowland-qyweixin[httpx]      # sync + async (recommended, one library covers both)
pip install snowland-qyweixin[aiohttp]    # async only
# or install a single one manually:
pip install requests / httpx / aiohttp

Quick Start

Synchronous client:

from qywechat import MessageClient

client = MessageClient(corpid="xxx", corpsecret="yyy", agentid=1000001)
client.send_text("hello", touser=["zhangsan", "lisi"])

Asynchronous client:

import asyncio
from qywechat import MessageClient

async def main():
    client = MessageClient(corpid="xxx", corpsecret="yyy", agentid=1000001)
    await client.send_text_async("hello", touser="zhangsan")

asyncio.run(main())

Group robot (Webhook):

from qywechat import Robot

robot = Robot("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx")
robot.send_markdown("**hello**")

Modules

Each client class provides both synchronous and asynchronous methods: the synchronous method uses the feature name (e.g. send_text), and the corresponding async method appends the _async suffix (e.g. send_text_async).

Module Client Class Features
message MessageClient Application messages (text/markdown/image/voice/video/file/textcard/news), group chat management (create/update/get) and group chat message sending
oa OAClient Approval: get approval number list, approval detail, submit approval application
contact ContactClient Contacts: CRUD for members and departments
external_contact ExternalContactClient External contact (customer acquisition): follow-user list, customer list, customer detail
robot Robot Group robot: text/markdown/image/news/file messages and media upload

Tests

python -m unittest discover -s qywechat/tests -p "test_*.py"

Notes

  • BaseClient holds both a synchronous and an asynchronous HttpClient, and access_token is reused within its validity period.
  • Synchronous methods only require any one synchronous library (candidates: requests, httpx); async methods only require any one asynchronous library (candidates: httpx, aiohttp). A missing library raises a clear message only when the corresponding method is actually used.
  • Global token-bucket rate limiting can be enabled via rate_limit=RateLimitConfig(...).

Metadata

Release files for snowland-qyweixin 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowland-qyweixin 0.1.0
File Size Uploaded
snowland_qyweixin-0.1.0.tar.gz 26.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snowland-qyweixin 0.1.0
File Interpreter ABI Platform
snowland_qyweixin-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.7 kB

Release files / snowland_qyweixin-0.1.0.tar.gz

Download URL snowland_qyweixin-0.1.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f804ca3ea19200a1212c2b471aa2c9bf3c4bc872a283498710c34cf304d61cc8
BLAKE2b-256 checksum
How to use checksums
d7eeeb8c7dfab1b1a5b09c058ab804887cec4f15590a8206b8c9f00419ca91cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / snowland_qyweixin-0.1.0-py3-none-any.whl

Download URL snowland_qyweixin-0.1.0-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
766ad7e335d66959a51a8b7ecd9d08e65664b2401caa4721fdede2fdba7583e0
BLAKE2b-256 checksum
How to use checksums
a5e23191402b5b070c3f06576af5a4c02d77d0264434f5e80f24211b4ecd9645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page