Package Tracker
Purpose
Helps implement and use a unified package tracking layer that can integrate multiple courier APIs (starting with 快递鸟). Use this skill when:
- - User wants to track a parcel by tracking number
- User asks to integrate express/courier query in code
- User mentions 快递鸟, Kdniao, or “快递查询”
Quick Start
- 1. Config: Copy
package_tracker.json.example to package_tracker.json, then fill in providers.kdniao.ebusiness_id and providers.kdniao.api_key.
- 2. Query (Python):
CODEBLOCK0
- 3. In code:
CODEBLOCK1
Provider: 快递鸟 (Kdniao)
- - 即时查询 RequestType: INLINECODE4
- Endpoint: INLINECODE5
- RequestData (JSON):
ShipperCode, LogisticCode, optional OrderCode, optional CustomerName (required for 顺丰 SF: last 4 digits of phone) - Sign:
RequestData (unencoded JSON, no spaces) + ApiKey → MD5 → Base64 → URL-encode
Do not put API keys in code; store them in package_tracker.json (and avoid committing it).
Adding Another Provider
- 1. Add a new module under
package_tracker/ implementing the same track interface (e.g. track(shipper_code, logistic_code, **kwargs) -> dict). - Register it in
package_tracker/registry.py, then select it via config (default) or pass provider=... in get_tracker(...).
Reference
- - 快递鸟即时查询: API 文档
- 本技能目录内已包含可运行的
package_tracker/(CLI + Python 包)与示例配置文件;安装到 ClawHub 后无需额外 clone 仓库即可直接执行上述命令。
包裹追踪器
目的
帮助实现和使用统一的包裹追踪层,可集成多家快递API(从快递鸟开始)。在以下场景使用此技能:
- - 用户希望通过运单号追踪包裹
- 用户要求在代码中集成快递查询功能
- 用户提及快递鸟、Kdniao或快递查询
快速开始
- 1. 配置:将 packagetracker.json.example 复制为 packagetracker.json,然后填写 providers.kdniao.ebusinessid 和 providers.kdniao.apikey。
- 2. 查询(Python):
bash
# 在技能目录(即此SKILL.md所在目录)中运行
python -m package_tracker track
# 例如:python -m package_tracker track ZTO 638650888018
- 3. 在代码中使用:
python
from packagetracker import gettracker
tracker = get_tracker()
result = tracker.track(shippercode=ZTO, logisticcode=638650888018)
快递提供商:快递鸟 (Kdniao)
- - 即时查询 RequestType: 1002
- 接口地址:https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx
- RequestData(JSON格式):ShipperCode、LogisticCode、可选 OrderCode、可选 CustomerName(顺丰SF必填:手机号后四位)
- 签名:RequestData(未编码的JSON,无空格)+ ApiKey → MD5 → Base64 → URL编码
请勿将API密钥写入代码中;应将其存储在 package_tracker.json 中(并避免提交到版本控制)。
添加其他快递提供商
- 1. 在 packagetracker/ 下添加新模块,实现相同的追踪接口(例如 track(shippercode, logisticcode, kwargs) -> dict)。
- 在 packagetracker/registry.py 中注册,然后通过配置(default)选择,或在 get_tracker(...) 中传入 provider=... 参数。
参考
- - 快递鸟即时查询:API 文档
- 本技能目录内已包含可运行的 packagetracker/(CLI + Python 包)与示例配置文件;安装到 ClawHub 后无需额外克隆仓库即可直接执行上述命令。