Skip to main content

wps365 — WPS365 全域业务 API Python 绑定

WPS365 云文档工具(wps365-rs)的 Python 绑定:基于 PyO3 将核心库编译为 CPython 扩展模块,提供云盘文件与智能文档修改/导出、待办、组织架构、知识库、日历日程、邮箱、消息、会议、审批、传统/智能/多维表格等全域能力的同步 Python API。

CLI 与桌面 GUI 用法见仓库根 README,本页仅覆盖 Python 绑定。

安装(源码构建)

# 仓库根目录:uv 管理的 venv + maturin
uv venv .venv --python 3.13
uv pip install --python .venv maturin

# 构建并安装到 venv(editable,改 Rust 代码后重复执行即可)
cd crates/wps365-python
VIRTUAL_ENV=<仓库根>/.venv ../../.venv/Scripts/maturin develop

# 或只出分发物
uv build --wheel

快速上手

from wps365 import Client, Wps365Error

client = Client()                     # 凭据解析:构造参数 > 环境变量 > 配置文件
# client = Client(sid="V02S...")      # 也可直接传入 wps_sid

for item in client.search("季度报告"):
    print(item["name"], item["link_url"])

result = client.upload(r"D:\报告.xlsx", folder="项目文档", share=True)
info = client.download(result["file_id"], dest="./下载")
text = client.read(result["file_id"])["markdown"]    # 在线文档抽取正文

Client 平铺全部 230 个方法(认证 / 云盘 / 文件 / 智能文档 / 待办 / 组织 / 知识库 / 日历 / 邮箱 / 消息 / 会议 / 审批 / 表格三件套 / 搜索 / 收藏 / 回收站 / 评论 / 标签),完整签名见随包分发的 wps365.pyi(IDE 自动补全开箱可用)。所有方法为同步阻塞调用,执行期间释放 GIL;返回值为 openapi 原始响应序列化而来的 dict / list / str。

凭据

优先级(首个非空者生效):构造参数 sid > 环境变量 WPS_SID > wps_sid > COOKIE(解析其中 wps_sid 字段)> 配置文件 auth_state.wps_sid。

获取 wps_sid:浏览器登录 kdocs.cn → F12 → Application → Cookies → 复制 wps_sid 值。

错误处理

全部错误以 Wps365Error(Exception 子类)抛出,消息格式为「[机器错误码] 描述」,错误码与 CLI 一致(AUTH_EXPIRED_NO_SID / INVALID_PARAM / API_ERROR / IO_ERROR 等),可按前缀分支处理。

静态检查

  • mypy / Pyright(Pylance):开箱即用,读取随包分发的 wps365.pyi。
  • Pylint:默认不导入 C 扩展,会对 wps365.Client 等成员误报 no-member(E1101),需在使用方项目放行:
# 使用方项目的 pyproject.toml(或同目录 .pylintrc)
[tool.pylint.main]
extension-pkg-allow-list = ["wps365"]

测试

cd crates/wps365-python
../../.venv/Scripts/python.exe -m pytest tests/ -v                        # 离线冒烟
WPS365_PYTHON_LIVE=1 ../../.venv/Scripts/python.exe -m pytest tests/ -v   # 含真实 API 用例

License

MIT

Metadata

Release files for wps365 0.5.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 wps365 0.5.0
File Size Uploaded
wps365-0.5.0.tar.gz 113.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for wps365 0.5.0
File
wps365-0.5.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
wps365-0.5.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
wps365-0.5.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
wps365-0.5.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
wps365-0.5.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details

Total release size: 19.0 MB

Release files / wps365-0.5.0.tar.gz

Download URL wps365-0.5.0.tar.gz
Size 113.0 kB
Tags Source
SHA-256 checksum
How to use checksums
78385cae4a9b7ffdc945eecd5e8d0299aaeea813b5fcbdf3972b2f2e6e89c47a
BLAKE2b-256 checksum
How to use checksums
1393cf35815775a0f2c8cde1a729a450e4f723770fe3f528706d94edf856fbe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / wps365-0.5.0-cp313-cp313-win_amd64.whl

Download URL wps365-0.5.0-cp313-cp313-win_amd64.whl
Size 3.8 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
c6323366e95b04fc4328dc2bdd5774f2ecaa8152a4ac361ab98be635bb403778
BLAKE2b-256 checksum
How to use checksums
f67566b02981fe6d7702f64c2d982802a46a71e922100ee01c6f1691e80c7b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / wps365-0.5.0-cp312-cp312-win_amd64.whl

Download URL wps365-0.5.0-cp312-cp312-win_amd64.whl
Size 3.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6eff2bdf708088cb893a7a78286ef45d12f5fd15f60b830c6ac890e0f76b469c
BLAKE2b-256 checksum
How to use checksums
b56448182e80121eb64ec4c166b32f529d4f4f27b1a887996eb8e7132592c6ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / wps365-0.5.0-cp311-cp311-win_amd64.whl

Download URL wps365-0.5.0-cp311-cp311-win_amd64.whl
Size 3.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
cfe7659ed2180914b30c90d34748dd8773aeaa8ef4ecd4e1a82272e66e4b7523
BLAKE2b-256 checksum
How to use checksums
30f7338c7cdea853d5a50528bac39abdd328f6be2e84683afbddb4382cb2b46a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / wps365-0.5.0-cp310-cp310-win_amd64.whl

Download URL wps365-0.5.0-cp310-cp310-win_amd64.whl
Size 3.8 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5176ac84fddbc601c15fc2bb61bcc6d72ba8e883a2cceeb3ead58ca928ffc94f
BLAKE2b-256 checksum
How to use checksums
1b56712c1eef99010e90438600221436b975f509468a5326ecdbc2b0512c1cdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / wps365-0.5.0-cp39-cp39-win_amd64.whl

Download URL wps365-0.5.0-cp39-cp39-win_amd64.whl
Size 3.8 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
befb4270fd27195afb9eaf71b4725832145b973cad8f961beac57018cd2264a0
BLAKE2b-256 checksum
How to use checksums
3cb78d45e592b6a11bf037d6f9e209bfc034036151c59f7e4c2340fec53dd66b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

This release

0.5.0 This release

6 release files

0.4.0

6 release files

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