6. Print Label API
This API provides printing label for the package order in PDF format.
info
This label can be pasted on the physical package and it contains the order details. E.g: barcode, shipping addresses, label id, ...
- GHTK provides 2 types of order labels: portrait and landscape.
- Supported sizes: A5 or A6 (default).
Label samples
Sample for A5 landscape
Sample for A5 portrait
Request
Endpoint
GET /services/label/{TRACKING_ORDER}?original={ORIGINAL}&paper_size={PAPER_SIZE}
Headers
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
Parameters
Parameter | Mandatory (Y/N) | Description |
---|---|---|
TRACKING_ORDER | Y | GHTK’s reference ID (order.label) |
ORIGINAL | N | String - Label printing type: portrait (vertical) or landscape (horizontal) (default is portrait). |
PAPER_SIZE | N | String - Label size: A5, A6 (default is A6). |
Code
- HTTP
- CURL
- PHP
GET /services/label/{TRACKING_ORDER} HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
curl -X GET -H "Token: {API_TOKEN}" \
-H "Token: {API_TOKEN}" \
-H "X-Client-Source: {PARTNER_CODE}" \
"https://services.giaohangtietkiem.vn/services/label/{TRACKING_ORDER}"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/label/{TRACKING_ORDER}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"Token: APITokenSample-ca441e70288cB0515F310742",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Response
The system will return the result as a binary PDF file. The returned result is described as follows:
Successful request
HTTP/1.1 200 OK
tuneContent-Type: application/pdf
Content-Disposition: attachment; filename=""
shareContent-Transfer-Encoding: binary
Failed response
Failed response: label id is not recognized or cannot be found
{
"success": false,
"message": "Mã vận đơn không hợp lệ, không tìm thấy vận đơn",
"error_code": "40102",
"log_id": "..."
}