获取智能柜网点
接口说明
按邮编查询附近的智能柜/自提点,返回按距离升序排列的网点列表。下单时把 station_code 等信息填进 locker_station。
请求信息
- 方法:GET
- 路径:
/openapi/station/get-stations - 认证方式:标准 OpenAPI token(基于 MD5)
请求头
| 字段 | 说明 |
|---|---|
| Content-Type | application/json |
| x-auth-name | $API_NAME |
| x-auth-seed | $SEED(13 位毫秒级 UNIX 时间戳) |
| x-auth-token | $TOKEN(MD5 哈希) |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| postcode | string | 否 | 用于查找附近网点的邮政编码。不传时返回空列表,因此实际使用中必须传 |
Token 生成说明
token 只由凭证和 seed 计算得出 —— 请求参数不参与。
seed = "1746700000000" (13 位毫秒时间戳)
token = md5( strtolower(api_name) + api_key + seed )认证
本接口使用标准 OpenAPI 认证(MD5 token)。
完整的认证说明与多语言示例见认证与签名。
响应信息
响应为 JSON 格式。
响应结构
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 结果码。0 = 成功,1 = 失败 |
| message | string | 结果描述 |
| data | array | 网点列表 |
成功响应
- HTTP 状态码:200
json
{
"code": 0,
"message": "success",
"data": [
{
"Zipcode": "544774",
"Station_Name": "Parcel Santa - Terrasse",
"Station_Address": "- 21 Terrasse Ln, Singapore 544774",
"Address_Detail": "Terrasse, Arcadia Clubhouse 1, basement, outside MA office",
"Distance": 197.977,
"Station_Code": "PK1689"
},
{
"Zipcode": "546692",
"Station_Name": "Parcel Santa - The Waterline",
"Station_Address": "- 167 Poh Huat Road West Singapore 546695",
"Address_Detail": "The Waterline, B1 Carpark, beside the Ejector Pit",
"Distance": 305.928,
"Station_Code": "PK1655"
},
{
"Zipcode": "530628",
"Station_Name": "Pick - 628 Hougang Avenue 8",
"Station_Address": "628 Hougang Avenue 8",
"Address_Detail": "Near Lift A & B ",
"Distance": 321.347,
"Station_Code": "PK622"
},
{
"Zipcode": "544604",
"Station_Name": "Parcel Santa - Hundred Palms Residences",
"Station_Address": "- 276 Yio Chu Kang Rd, Singapore 544604",
"Address_Detail": "Hundred Palms Residences, Blk 276 main bicycle parking/washing area, behind management office",
"Distance": 390.707,
"Station_Code": "PK1691"
},
{
"Zipcode": "530641",
"Station_Name": "Pick - 641 Hougang Avenue 8",
"Station_Address": "641 Hougang Avenue 8",
"Address_Detail": "Near Letterbox",
"Distance": 428.492,
"Station_Code": "PK129"
},
{
"Zipcode": "550139",
"Station_Name": "Pick - 139 Serangoon North Avenue 2",
"Station_Address": "139 Serangoon North Avenue 2",
"Address_Detail": "Near Lift A & B",
"Distance": 449.037,
"Station_Code": "PK371"
},
{
"Zipcode": "530623",
"Station_Name": "Pick - 623 Hougang Avenue 8",
"Station_Address": "623 Hougang Avenue 8",
"Address_Detail": "Near Lift C",
"Distance": 524.894,
"Station_Code": "PK893"
},
{
"Zipcode": "550512",
"Station_Name": "Pick - 512 Serangoon North Avenue 4",
"Station_Address": "512 Serangoon North Avenue 4",
"Address_Detail": "Near Letterbox",
"Distance": 614.865,
"Station_Code": "PK327"
},
{
"Zipcode": "530615",
"Station_Name": "Pick - 615 Hougang Avenue 8",
"Station_Address": "615 Hougang Avenue 8",
"Address_Detail": "Near Lift A",
"Distance": 695.57,
"Station_Code": "PK551"
},
{
"Zipcode": "546053",
"Station_Name": "Parcel Santa - Bliss @Kovan",
"Station_Address": "- 4 Simon Lane Singapore 546018",
"Address_Detail": "Bliss @Kovan, Blk 6B, B1 Carpark, Outside Lift Lobby",
"Distance": 710.982,
"Station_Code": "PK1564"
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
| data[].Zipcode | string | 网点邮编 |
| data[].Station_Name | string | 网点名称 |
| data[].Station_Address | string | 网点地址 |
| data[].Address_Detail | string | 网点位置补充说明(如所在楼层、参照物) |
| data[].Distance | float | 与所查邮编的距离,单位米 |
| data[].Station_Code | string | 网点编码;下单时作为 locker_station.station_code 传入 |
字段名首字母大写
本接口的字段名是 Zipcode、Station_Name 这种首字母大写写法,与其他接口的小写下划线风格不同,解析时注意。
失败响应
- HTTP 状态码:200(业务错误)或 4xx/5xx(系统错误)
json
{
"code": 1,
"message": "xxxxx error",
"data": []
}常见错误:
- 认证失败 → code
1;具体 message 取决于失败原因(如x-auth-token: INVALID、x-auth-seed: TIMEOUT)—— 见认证与签名
结果码
| Code | 说明 |
|---|---|
| 0 | 成功 |
| 1 | 失败 |
调用示例
Bash
bash
API_NAME="your_api_name"
API_KEY="your_api_key"
SEED=$(date +%s%3N)
TOKEN=$(printf '%s' "$(echo -n "$API_NAME" | tr '[:upper:]' '[:lower:]')${API_KEY}${SEED}" | md5sum | cut -d' ' -f1)
# Query all stations
curl -G "https://api.test.wmgdelivery.com/v1/openapi/station/get-stations" \
-H "x-auth-name: $API_NAME" \
-H "x-auth-seed: $SEED" \
-H "x-auth-token: $TOKEN"
# Query stations near a postal code
curl -G "https://api.test.wmgdelivery.com/v1/openapi/station/get-stations" \
--data-urlencode "postcode=529510" \
-H "x-auth-name: $API_NAME" \
-H "x-auth-seed: $SEED" \
-H "x-auth-token: $TOKEN"Windows PowerShell
powershell
$API_NAME = "your_api_name"
$API_KEY = "your_api_key"
$SEED = [string]([DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds())
$raw = [System.Text.Encoding]::UTF8.GetBytes($API_NAME.ToLower() + $API_KEY + $SEED)
$md5 = [System.Security.Cryptography.MD5]::Create().ComputeHash($raw)
$TOKEN = -join ($md5 | ForEach-Object { $_.ToString("x2") })
$headers = @{
"x-auth-name" = $API_NAME
"x-auth-seed" = $SEED
"x-auth-token" = $TOKEN
}
$response = Invoke-RestMethod `
-Uri "https://api.test.wmgdelivery.com/v1/openapi/station/get-stations?postcode=529510" `
-Method Get -Headers $headers
$response | ConvertTo-Json -Depth 10Python
python
import hashlib, time
import requests
API_NAME = 'your_api_name'
API_KEY = 'your_api_key'
SEED = str(int(time.time() * 1000))
TOKEN = hashlib.md5((API_NAME.lower() + API_KEY + SEED).encode()).hexdigest()
headers = {
'x-auth-name': API_NAME,
'x-auth-seed': SEED,
'x-auth-token': TOKEN,
}
resp = requests.get(
'https://api.test.wmgdelivery.com/v1/openapi/station/get-stations',
params={'postcode': '529510'},
headers=headers,
)
print(resp.json())Node.js / TypeScript
typescript
import crypto from 'node:crypto';
const API_NAME = 'your_api_name';
const API_KEY = 'your_api_key';
const SEED = String(Date.now());
const TOKEN = crypto.createHash('md5').update(API_NAME.toLowerCase() + API_KEY + SEED).digest('hex');
const url = new URL('https://api.test.wmgdelivery.com/v1/openapi/station/get-stations');
url.searchParams.set('postcode', '529510');
const resp = await fetch(url.toString(), {
headers: {
'x-auth-name': API_NAME,
'x-auth-seed': SEED,
'x-auth-token': TOKEN,
},
});
console.log(JSON.stringify(await resp.json(), null, 2));PHP
php
<?php
$API_NAME = 'your_api_name';
$API_KEY = 'your_api_key';
$SEED = (string)(time() * 1000);
$TOKEN = md5(strtolower($API_NAME) . $API_KEY . $SEED);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.test.wmgdelivery.com/v1/openapi/station/get-stations?' . http_build_query(['postcode' => '529510']));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-auth-name: ' . $API_NAME,
'x-auth-seed: ' . $SEED,
'x-auth-token: ' . $TOKEN,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
curl_close($ch);
echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
?>注意事项
postcode是查询依据:不传时返回空列表,因此请始终传入要查找网点的邮编。- 下单时把
Station_Code作为创建订单的locker_station.station_code传入。 - 认证 token 不包含请求参数,只用凭证和 seed 计算。
x-auth-seed必须是 13 位毫秒级 UNIX 时间戳,且与服务器时间相差不超过 ±10 分钟。- 所有参数区分大小写。
错误码
| code | message | 说明 |
|---|---|---|
1 | 认证错误消息 | 认证失败;具体 message 取决于失败原因 —— 完整清单见认证与签名 |