已上架商品默认支持 API 分享。请在个人中心查看自己的 App ID 和 API 密钥;下单从该账号余额扣款,不需要提供登录密码。
https://zhanghaodao.com,App ID 和 App Key 分别填写个人中心的 App ID、API 密钥。https://zhanghaodao.com,API Key 填写个人中心的 App ID,API Secret 填写个人中心的 API 密钥。请勿在地址后重复追加接口路径。Next 接口前缀:https://zhanghaodao.com/api/v1/upstream。使用 Dujiao-Next-Api-Key、Dujiao-Next-Timestamp、Dujiao-Next-Signature 请求头;时间戳允许偏差 60 秒。
签名:HMAC-SHA256(API Secret, METHOD + "\n" + PATH + "\n" + TIMESTAMP + "\n" + MD5(原始请求体)),输出小写十六进制。PATH 不含域名和查询参数,空请求体也参与 MD5。
支持连接测试、分类、分页商品、SKU 下单、订单查询和签名发货回调。同一账号和下游订单号重复提交只返回已有订单,不重复扣款。回调地址仅允许公网 HTTP/HTTPS;已支付采购单不支持自动取消或退款。
Dujiao-Next 官方协议文档。下面的 X-API-Key 文档为本站通用 API,与上述 Next 签名协议不同。
所有API请求需要在请求头中携带API密钥:
X-API-Key: your_api_keyAuthorization: Bearer your_api_key您可以在用户中心查看和管理您的API密钥
Base URL: https://zhanghaodao.com/api
响应格式: JSON
编码: UTF-8
/goods 获取商品列表,支持分页和筛选
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
group_id | integer | query | 可选 | 商品分组ID |
type | integer | query | 可选 | 商品类型 |
search | string | query | 可选 | 搜索关键词 |
per_page | integer | query | 可选 | 每页数量,最多100 默认值: 15 |
page | integer | query | 可选 | 页码 默认值: 1 |
{ "success": true, "message": "操作成功", "data": { "current_page": 1, "data": [ { "id": 1, "name": "商品名称", "description": "商品描述", "picture": "https:\/\/example.com\/picture.jpg", "price": 99, "sales_volume": "api.example_data.total_100", "type": 1, "type_name": "规格名称", "subs": [ { "id": 1, "name": "规格名称", "price": 99, "stock": "api.example_data.total_100" } ] } ], "total": "api.example_data.total_100", "per_page": 15 }
} curl -X GET "https://zhanghaodao.com/api/goods" \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zhanghaodao.com/api/goods");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-API-Key: your_api_key", "Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch); import requests headers = { "X-API-Key": "your_api_key", "Content-Type": "application/json"
} response = requests.get( "https://zhanghaodao.com/api/goods", headers=headers
) fetch("https://zhanghaodao.com/api/goods", { method: "GET", headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" }
})
.then(response => response.json())
.then(data => ); /goods/{id} 根据商品ID获取商品详细信息
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
id | integer | path | 必填 | 商品ID |
{ "success": true, "message": "操作成功", "data": { "id": 1, "name": "商品名称", "description": "商品描述", "detail": "商品详情内容", "usage_instructions": "使用说明", "picture": "https:\/\/example.com\/picture.jpg", "price": 99, "sales_volume": "api.example_data.total_100", "type": 1, "type_name": "规格名称", "require_login": false, "subs": [] }
} curl -X GET "https://zhanghaodao.com/api/goods/{id}" \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zhanghaodao.com/api/goods/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-API-Key: your_api_key", "Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch); import requests headers = { "X-API-Key": "your_api_key", "Content-Type": "application/json"
} response = requests.get( "https://zhanghaodao.com/api/goods/{id}", headers=headers
) fetch("https://zhanghaodao.com/api/goods/{id}", { method: "GET", headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" }
})
.then(response => response.json())
.then(data => ); /goods/{id}/stock 获取商品各规格的库存信息
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
id | integer | path | 必填 | 商品ID |
{ "success": true, "message": "操作成功", "data": { "goods_id": 1, "goods_name": "商品名称", "subs": [ { "sub_id": 1, "sub_name": "规格名称", "stock": "api.example_data.total_100", "price": 99 } ] }
} curl -X GET "https://zhanghaodao.com/api/goods/{id}/stock" \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zhanghaodao.com/api/goods/{id}/stock");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-API-Key: your_api_key", "Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch); import requests headers = { "X-API-Key": "your_api_key", "Content-Type": "application/json"
} response = requests.get( "https://zhanghaodao.com/api/goods/{id}/stock", headers=headers
) fetch("https://zhanghaodao.com/api/goods/{id}/stock", { method: "GET", headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" }
})
.then(response => response.json())
.then(data => ); /balance 获取当前用户的余额信息
{ "success": true, "message": "操作成功", "data": { "balance": 1000, "total_spent": 5000, "level_name": "白银会员" }
} curl -X GET "https://zhanghaodao.com/api/balance" \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zhanghaodao.com/api/balance");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-API-Key: your_api_key", "Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch); import requests headers = { "X-API-Key": "your_api_key", "Content-Type": "application/json"
} response = requests.get( "https://zhanghaodao.com/api/balance", headers=headers
) fetch("https://zhanghaodao.com/api/balance", { method: "GET", headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" }
})
.then(response => response.json())
.then(data => ); /purchase 创建订单并购买商品
| 参数名 | 类型 | 位置 | 必填 | 说明 |
|---|---|---|---|---|
goods_id | integer | query | 必填 | 商品ID |
sub_id | integer | query | 必填 | 商品规格ID |
quantity | integer | query | 必填 | 购买数量 最小值: 1 |
email | string | query | 可选 | 联系邮箱 |
payway | string | query | 必填 | 支付方式ID或"balance"(余额支付) |
search_pwd | string | query | 可选 | 查询密码 |
{ "success": true, "message": "订单创建成功", "data": { "order_sn": "订单号", "status": 4, "total_price": 99, "actual_price": 94.05, "balance_used": 0 }
} curl -X POST "https://zhanghaodao.com/api/purchase" \ -H "X-API-Key: your_api_key" \ -H "Content-Type: application/json" $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://zhanghaodao.com/api/purchase");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-API-Key: your_api_key", "Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch); import requests headers = { "X-API-Key": "your_api_key", "Content-Type": "application/json"
} response = requests.post( "https://zhanghaodao.com/api/purchase", headers=headers
) fetch("https://zhanghaodao.com/api/purchase", { method: "POST", headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" }
})
.then(response => response.json())
.then(data => );