snowland-topwms
TOPWMS 开放平台Python SDK(非官方),基于 snowland-http 实现:
- 限流:默认 300 次/分钟(文档硬性限制),超出 WMS 会报错。
- 可插拔后端:
requests(同步)/httpx(同步+异步)/aiohttp(异步),或auto自动探测。 - 自动鉴权:
AppKey请求头 + 请求体 MD5 双重签名Signature,调用方无需关心。 - 同步/异步:每个接口均提供
<name>与<name>_async两种方法。 - Webhook 校验:内置推送回调签名校验。
安装
本 SDK 依赖 snowland-http(已发布到 PyPI,安装时自动下载)。提供两种安装方式。
方式一:从 PyPI 安装
pip install "snowland-topwms[httpx]"
安装后直接
import snowland_topwms即可,无需本地源码;snowland-http及所选传输后端会一并自动安装。
快速开始
from snowland_topwms import TopWmsClient
client = TopWmsClient(
app_key="你的appKey",
app_secret="你的appSecret",
base_url="https://<host>/api/open/erp", # 文档中的接口基址
)
# 商品 SKU 详情(参数一律以函数关键字参数传入,禁止整包 dict)
resp = client.get_goods_detail(goods_sku_outer_id="123")
print(resp.code, resp.message, resp.data)
# 异步
import asyncio
resp = asyncio.run(client.get_goods_detail_async(goods_sku_outer_id="123"))
# 未声明字段用 **kwargs 透传(key 即请求体原始字段名)
resp = client.list_inventory(warehouse_id="W1", page_no=1, pageSize=20)
# 文档未列出/自定义接口(同样关键字参数化)
resp = client.call_api("/some/custom/path", foo="bar")
鉴权说明
签名算法(来自官方「快速接入」):
- 将请求体 JSON 字符串进行 32 位 MD5 加密;
- 将得到的 MD5 串与
appSecret拼接; - 再次 32 位 MD5,结果作为
Signature请求头。
AppKey 与 Signature 自动写入请求头,Content-Type: application/json 自动设置。
SDK 会对发送内容逐字节保持一致地参与签名,确保与服务端校验一致。
接口路径核对
所有接口路径与字段均已依据 doc/api.md 引用的官方 OpenAPI 规范
(Apifox 分享文档,索引见 doc/api.md)核实,并通过联调测试确认路由正确,全部标注
verified=True。
端点声明按业务类型拆分在
snowland_topwms/api 各子模块中
(base/warehouse/goods/inventory/stocking/return_order/logistics/outbound),
由 snowland_topwms/endpoints.py 聚合成总表,
客户端自动生成参数化方法。新增/修正接口只需改动对应分类模块,无需改动 client.py。
接收 WMS 消息推送(Webhook)
from snowland_topwms import verify_signature
# 收到回调时,用原始请求体字符串校验签名
raw_body = request.get_data(as_text=True) # Flask 示例
sig = request.headers.get("Signature")
if verify_signature(raw_body, "你的appSecret", sig):
... # 合法回调
测试
pip install -e ".[all]"
python -m unittest discover -s tests -v
Metadata
Release files for snowland-topwms 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snowland_topwms-0.1.0.tar.gz | 23.5 kB | Without provenance | Details for snowland_topwms-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snowland_topwms-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for snowland_topwms-0.1.0-py3-none-any.whl |
Total release size: 51.9 kB
Release files / snowland_topwms-0.1.0.tar.gz
| Download URL | snowland_topwms-0.1.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6308c747e20f3ac79721a4483e1fd55cce0bc3d2db96da9bcff44c911a03727
|
|
BLAKE2b-256 checksum How to use checksums |
cce5db0655eb5466062fdaced0892c1dd2b621e25d12035e653d07b60b7d7ff3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / snowland_topwms-0.1.0-py3-none-any.whl
| Download URL | snowland_topwms-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
573e2f1d0f46ff7b5321bbb27046b6d4a6a2c37da81b533a74f5ffc1a5a460f7
|
|
BLAKE2b-256 checksum How to use checksums |
066159aad105b474494853689ee4c1694d5aca0a3337f0acc655dd82a8c96d7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for snowland-topwms 0.1.0
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.