Bitzsoft.Integrations.Express.Zto
1.0.1
dotnet add package Bitzsoft.Integrations.Express.Zto --version 1.0.1
NuGet\Install-Package Bitzsoft.Integrations.Express.Zto -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.Express.Zto" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.Express.Zto" Version="1.0.1" />
<PackageReference Include="Bitzsoft.Integrations.Express.Zto" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.Express.Zto --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bitzsoft.Integrations.Express.Zto, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.Express.Zto@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.Express.Zto&version=1.0.1
#tool nuget:?package=Bitzsoft.Integrations.Express.Zto&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.Express.Zto
中通快递物流服务实现 -- 面向中通开放平台提供物流轨迹查询接入结构。
功能特性
- 基于中通开放平台 API,支持物流轨迹查询
- 认证方式:AppKey + AppSecret(HMAC-SHA256 签名)
- 对接流程:注册用户 → 资质认证 → 创建应用 → 添加服务 → 联调测试 → 上线
- 统一异常处理,供应商错误码自动映射为
ExpressException - 实现
IExpressProvider统一契约,可无缝替换其他供应商实现
安装
.NET CLI
dotnet add package Bitzsoft.Integrations.Express.Zto
PackageReference
<PackageReference Include="Bitzsoft.Integrations.Express.Zto" Version="1.0.0" />
配置
appsettings.json
{
"Express": {
"Zto": {
"AppKey": "你的AppKey",
"AppSecret": "你的AppSecret",
"BaseUrl": "https://jwzto.zto.com",
"HttpClientName": "ZtoExpress"
}
}
}
| 配置项 | 必填 | 默认值 | 说明 |
|---|---|---|---|
AppKey |
是 | — | 中通开放平台 AppKey |
AppSecret |
是 | — | 中通开放平台 AppSecret,参与签名计算 |
BaseUrl |
否 | https://jwzto.zto.com |
中通开放平台 API 基地址 |
HttpClientName |
否 | ZtoExpress |
命名 HttpClient 名称 |
注册服务
从 IConfiguration 绑定(推荐)
using Bitzsoft.Integrations.Express.Zto;
builder.Services.AddBitzsoftZtoExpress(
builder.Configuration.GetSection("Express:Zto"));
委托配置
builder.Services.AddBitzsoftZtoExpress(options =>
{
options.AppKey = "your_app_key";
options.AppSecret = "your_app_secret";
});
请求审计
内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认使用 NullRequestLogStore 不持久化。
// ① 默认:启用记录管道但不持久化(日志丢弃)
services.AddBitzsoftZtoExpress(options => { /* ... */ });
// ② 持久化:宿主注册 IRequestLogStore 实现后,所有出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
opts.MaxInMemoryBodyBytes = 64 * 1024; // 仅控制内存/加密临时文件切换,不截断正文
opts.SensitiveFields.Add("AppSecret");
});
services.AddBitzsoftZtoExpress(options => { /* ... */ });
使用示例
物流轨迹查询
using Bitzsoft.Integrations.Express.Interfaces;
using Bitzsoft.Integrations.Express.Models;
public class TrackingService
{
private readonly IExpressProvider _express;
public TrackingService(IExpressProvider express) => _express = express;
public async Task TrackAsync(string trackingNumber)
{
// 查询单个运单轨迹
ExpressTrackingInfo info = await _express.TrackAsync(trackingNumber);
Console.WriteLine($"状态: {info.State}, 轨迹数: {info.Traces.Count}");
foreach (var step in info.Traces)
Console.WriteLine($"[{step.Time:yyyy-MM-dd HH:mm}] {step.Description}");
// 批量查询
IReadOnlyList<ExpressTrackingInfo> batch =
await _express.BatchTrackAsync(new[] { "731001", "731002" });
}
}
核心类型一览
| 类型 | 说明 |
|---|---|
ZtoExpressProvider |
中通快递物流服务实现(IExpressProvider) |
ZtoOptions |
中通配置选项(AppKey / AppSecret / BaseUrl / HttpClientName) |
IExpressProvider |
通用物流操作契约(抽象层) |
ExpressTrackingInfo |
物流轨迹查询结果 |
实现状态
| 方法 | 状态 | 说明 |
|---|---|---|
TrackAsync |
已实现 | 按中通开放平台应用权限调用轨迹查询接口 |
BatchTrackAsync |
已实现 | 逐条调用轨迹查询 |
SubscribeAsync |
待开通 | 需在中通开放平台申请服务权限 |
CreateShipmentAsync |
待开通 | 需在中通开放平台申请服务权限 |
CancelShipmentAsync |
待开通 | 需在中通开放平台申请服务权限 |
GetQuoteAsync |
待开通 | 需在中通开放平台申请服务权限 |
GenerateWaybillAsync |
待开通 | 需在中通开放平台申请服务权限 |
DetectCarrierAsync |
待开通 | 需在中通开放平台申请服务权限 |
未实现的操作会抛出
NotSupportedException,提示需在中通开放平台注册并申请相关服务权限后获取接口文档。
依赖
| 包 | 说明 |
|---|---|
Bitzsoft.Integrations.Express |
抽象层(IExpressProvider 接口与模型) |
Bitzsoft.Integrations.Compatibility |
基础工具库 |
Bitzsoft.Integrations.RequestLogging |
出站请求记录管道 |
Microsoft.Extensions.Configuration.Abstractions |
配置抽象 |
Microsoft.Extensions.Http |
IHttpClientFactory(Typed Client 连接池) |
Microsoft.Extensions.Options.ConfigurationExtensions |
Options 配置节点绑定 |
注意事项
- 中通开放平台(https://open.zto.com/)需完成企业注册、资质认证、创建应用等流程
- 接口文档和服务权限以中通开放平台应用开通结果为准
- 仅轨迹查询已实现,寄件、取消、订阅等能力待按已开通服务扩展
IExpressProvider使用TryAddSingleton注册,如需同时注册多个供应商请单独引用并自行解析
相关包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.1)
- Bitzsoft.Integrations.Express (>= 1.0.1)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.1)
- Bitzsoft.Integrations.Express (>= 1.0.1)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.1)
- Bitzsoft.Integrations.Express (>= 1.0.1)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.Express.Zto:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.Express.All
快递物流服务聚合包 — 包含所有供应商实现 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 125 | 8/3/2026 |
| 1.0.0 | 129 | 8/2/2026 |
| 1.0.0-alpha.10 | 53 | 7/26/2026 |
| 1.0.0-alpha.9 | 61 | 7/12/2026 |
| 1.0.0-alpha.8 | 68 | 7/1/2026 |
| 1.0.0-alpha.7 | 78 | 6/16/2026 |
| 1.0.0-alpha.6 | 72 | 6/16/2026 |
| 1.0.0-alpha.5 | 68 | 6/14/2026 |
| 1.0.0-alpha.3 | 66 | 6/7/2026 |