Skip to main content

wechat-py

微信 API 的 Python SDK 基础框架,使用 uv 管理依赖,支持 Python 3.9 及以上版本。

安装

发布到 PyPI 后,可以使用以下命令安装:

uv add wechatpay-python
# 或 pip install wechatpay-python

开发

uv sync --group dev
uv run pytest
uv run ruff check .
uv build

使用

from wechat_py import WeChatAPIError, WeChatClient

try:
    with WeChatClient() as client:
        result = client.request(
            "GET", "/some/api", params={"access_token": "YOUR_ACCESS_TOKEN"}
        )
        print(result)
except WeChatAPIError as exc:
    print(exc.code, exc.message)

示例中的路径是占位符,使用时请替换为实际接口。当前框架提供同步 JSON 请求、HTTP 和微信 API 错误处理;业务接口、access token 获取和刷新尚未实现。调用方负责凭证管理,避免将密钥提交到仓库。网络或 HTTP 错误以及非 JSON 对象响应会抛出 WeChatTransportError。

可通过 http_client 注入已配置的 httpx.Client;注入的客户端由调用方负责关闭。默认客户端可通过 base_url 和 timeout 配置,并由 WeChatClient 关闭。

发布到 PyPI

构建并发布当前版本:

uv build
uv publish dist/wechatpay_python-0.0.1.tar.gz dist/wechatpay_python-0.0.1-py3-none-any.whl

发布前需具备 PyPI 项目发布权限,并按 uv 提示提供 PyPI API token。请勿将 token 写入项目文件或提交到仓库。

Metadata

Release files for wechatpay-python 0.0.1

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

Source distribution (sdist)

Source distribution for wechatpay-python 0.0.1
File Size Uploaded Provenance Actions
wechatpay_python-0.0.1.tar.gz 18.6 kB Without provenance Details for wechatpay_python-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wechatpay-python 0.0.1
File Interpreter ABI Platform Actions
wechatpay_python-0.0.1-py3-none-any.whl Python 3 none any Details for wechatpay_python-0.0.1-py3-none-any.whl

Total release size: 23.8 kB

Release files / wechatpay_python-0.0.1.tar.gz

Download URL wechatpay_python-0.0.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
183e4a847f6913b831c2dc89e0b2c97632e23ffd715deecb9a50e9b47dea6419
BLAKE2b-256 checksum
How to use checksums
6efe07d78ce4862a9d4c275e0d0974f38bfe9be884e2d2c1b8197943fe727d93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / wechatpay_python-0.0.1-py3-none-any.whl

Download URL wechatpay_python-0.0.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b612b0e5b67fcdd02480438a3b73c54dfbe942ac7e9ca24387ec57c95bb88bcf
BLAKE2b-256 checksum
How to use checksums
ce30c61d4f601bb83b89d0c8075df4b9106dce27706b2af2a93fd20444e6a18d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for wechatpay-python 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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