Get Shipping Label (PDF)
API Overview
Returns the shipping label for a parcel as a Base64-encoded PDF string. Decode and save the result as a .pdf file to print or archive the label. The endpoint automatically returns the appropriate label format based on the parcel's service type.
Request Information
- Method: GET
- Path:
/openapi/order-shipping-label/get-shipping-label - Authentication: Standard OpenAPI token (MD5-based)
Request Headers
| Field | Description |
|---|---|
| Content-Type | application/json |
| x-auth-name | $API_NAME |
| x-auth-seed | $SEED (13-digit millisecond Unix timestamp) |
| x-auth-token | $TOKEN (MD5 hash) |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| tracking_num | string | Yes | WMG parcel tracking number |
Token Generation Example
The authentication token is computed from your credentials and seed only -- request parameters are not included.
seed = "1746700000000" (13-digit ms timestamp)
token = md5( strtolower(api_name) + api_key + seed )Authentication
This endpoint uses Standard OpenAPI Authentication (MD5 token).
For complete authentication instructions and code examples, see Authentication Guide.
Response Information
The response is in JSON format.
Response Format
| Field | Type | Description |
|---|---|---|
| code | integer | Result code. 0 = success, 1 = failure |
| message | string | Result description |
| data | object | Response payload |
Success Response
- Status Code: 200
- Response Body:
json
{
"code": 0,
"message": "success",
"data": {
"base64": "JVBERi0xLjcKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWJRFs8NTJkNTBjMzZkMjQ4ODFjMDVkYTM4NGQxODg2ODU2Yzc+PDUyZDUwYzM2ZDI0ODgxYzA1ZGEzODRkMTg4Njg1NmM3Pl0KPj4Kc3RhcnR4cmVmCjg5NTQ3CiUlRU9GCg=="
}
}| Field | Type | Description |
|---|---|---|
| data.base64 | string | Base64-encoded PDF content. Decode to obtain the raw PDF bytes |
Error Response
- Status Code: 200 (business logic error) or 4xx/5xx (system error)
- Response Body:
json
{
"code": 1,
"message": "Order Not Found!",
"data": []
}Common errors:
- Authentication failure → code
1; the message depends on the cause (e.g.x-auth-token: INVALID,x-auth-seed: TIMEOUT) — see signature.md - Order not found -- code
1, messageOrder Not Found!
Code Reference
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Failure |
Example
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)
# Fetch label and decode to PDF
curl -G "https://api.test.wmgdelivery.com/v1/openapi/order-shipping-label/get-shipping-label" \
--data-urlencode "tracking_num=WMG1234567" \
-H "x-auth-name: $API_NAME" \
-H "x-auth-seed: $SEED" \
-H "x-auth-token: $TOKEN" \
| python3 -c "import sys,json,base64; d=json.load(sys.stdin); open('label.pdf','wb').write(base64.b64decode(d['data']['base64']))"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/order-shipping-label/get-shipping-label?tracking_num=WMG1234567" `
-Method Get -Headers $headers
# Decode Base64 and save as PDF
[System.IO.File]::WriteAllBytes("label.pdf", [Convert]::FromBase64String($response.data.base64))
Write-Host "Label saved to label.pdf"Python
python
import hashlib, time, base64
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/order-shipping-label/get-shipping-label',
params={'tracking_num': 'WMG1234567'},
headers=headers,
)
data = resp.json()
if data['code'] == 0:
with open('label.pdf', 'wb') as f:
f.write(base64.b64decode(data['data']['base64']))
print('Label saved to label.pdf')
else:
print('Error:', data['message'])Node.js / TypeScript
typescript
import crypto from 'node:crypto';
import fs from 'node:fs';
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/order-shipping-label/get-shipping-label');
url.searchParams.set('tracking_num', 'WMG1234567');
const resp = await fetch(url.toString(), {
headers: {
'x-auth-name': API_NAME,
'x-auth-seed': SEED,
'x-auth-token': TOKEN,
},
});
const data = await resp.json() as { code: number; data: { base64: string } };
if (data.code === 0) {
fs.writeFileSync('label.pdf', Buffer.from(data.data.base64, 'base64'));
console.log('Label saved to label.pdf');
}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/order-shipping-label/get-shipping-label?' . http_build_query(['tracking_num' => 'WMG1234567']));
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, 15);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['code'] === 0) {
file_put_contents('label.pdf', base64_decode($data['data']['base64']));
echo "Label saved to label.pdf\n";
} else {
echo 'Error: ' . $data['message'] . "\n";
}
?>Notes
- Decode
data.base64using standard Base64 to obtain the raw PDF bytes before saving or printing. - The authentication token does not include request parameters; only credentials and seed are used.
- The seed must be a 13-digit millisecond Unix timestamp and within ±10 minutes of server time.
- All parameters are case-sensitive.
Error Codes
| code | message | Description |
|---|---|---|
1 | Authentication error message | Authentication failed; the returned message depends on the cause — see the full list in signature.md |
1 | Order Not Found! | No order exists for the given tracking_num under this client |
1 | Underlying carrier API error | Surfaced when the label generation pipeline (Singpost / Spring / built PDF) returns an error — message text comes from the carrier service |