6. Fee Calculation API
The API is used to calculate the shipping fee and other related surcharges for the order based on information such as the pickup address, delivery address, weight, and the selected service for the order ...
Request
Hyperlink
GET /services/shipment/fee
Headers
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
Parameters
Parameters | Required | Description |
---|---|---|
pick_address_id | no | String - Pickup location ID from the customer’s order management page. This field will take priority if not empty |
pick_address | no | String - Short pickup address (e.g., House No. 5, Block 3, Alley 11, Lane 45) |
pick_province | yes | String - Province/City of the pickup location |
pick_district | yes | String - District of the pickup location |
pick_ward | no | String - Ward/Commune of the pickup location |
pick_street | no | String - Street name of the pickup location |
address | no | String - Detailed delivery address (e.g., CT1 Building, Alley 58, Tran Binh Street) |
province | yes | String - Province/City of the recipient |
district | yes | String - District of the recipient |
ward | no | String - Ward/Commune of the recipient |
street | no | String - Street name of the recipient |
weight | yes | Integer - Weight of items in packages, unit: Gram |
value | no | Integer - The actual value of the order used to calculate the insurance fee, unit: VNĐ |
transport | no | String - Transportation method: "road" (by land), "fly" (by air). If the shipping method is invalid, GHTK will automatically default to the standard shipping method |
deliver_option | yes | String - Use the xfast shipping method. Accepts one of two values: "xteam" or "none" |
tags | no | array - Add tags to the order. Pass the order tag values into the tags array |
Code
- HTTP
- CURL
- PHP
GET /services/shipment/fee?address=P.503%20t%C3%B2a%20nh%C3%A0%20Auu%20Vi%E1%BB%87t,%20s%E1%BB%91%201%20L%C3%AA%20%C4%90%E1%BB%A9c%20Th%E1%BB%8D&province=H%C3%A0%20n%E1%BB%99i&district=Qu%E1%BA%ADn%20C%E1%BA%A7u%20Gi%E1%BA%A5y&pick_province=H%C3%A0%20N%E1%BB%99i&pick_district=Qu%E1%BA%ADn%20Hai%20B%C3%A0%20Tr%C6%B0ng&weight=1000&value=3000000&deliver_option=xteam HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
curl -X GET -H "Token: APITokenSample-ca441e70288cB0515F310742" \
"https://services.giaohangtietkiem.vn/services/shipment/fee?address=P.503%20t%C3%B2a%20nh%C3%A0%20Auu%20Vi%E1%BB%87t,%20s%E1%BB%91%201%20L%C3%AA%20%C4%90%E1%BB%A9c%20Th%E1%BB%8D&province=H%C3%A0%20n%E1%BB%99i&district=Qu%E1%BA%ADn%20C%E1%BA%A7u%20Gi%E1%BA%A5y&pick_province=H%C3%A0%20N%E1%BB%99i&pick_district=Qu%E1%BA%ADn%20Hai%20B%C3%A0%20Tr%C6%B0ng&weight=1000&value=3000000&deliver_option=xteam&tags%5B%5D=1"
<?php
$data = array(
"pick_province" => "Hà Nội",
"pick_district" => "Quận Hai Bà Trưng",
"province" => "Hà nội",
"district" => "Quận Cầu Giấy",
"address" => "P.503 tòa nhà Auu Việt, số 1 Lê Đức Thọ",
"weight" => 1000,
"value" => 3000000,
"transport" => "fly",
"deliver_option" => "xteam",
"tags" => [1,7]
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://services.giaohangtietkiem.vn/services/shipment/fee?" . http_build_query($data),
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
Response Information
Parameter | Description |
---|---|
fee.name | String - Name of the applied pricing package. Possible values: area1 , area2 , area3 |
fee.fee | Integer - Shipping cost, calculated in VND |
fee.insurance_fee | Integer - Insurance fee, calculated in VND |
fee.delivery | Boolean - Indicates whether delivery is supported at this address. If GHTK supports delivery to the location, it returns true ; otherwise, if delivery is not supported in this area, it returns false |
Success
{
"success": true,
"message": "",
"fee": {
"name": "area1",
"fee": 30400,
"insurance_fee": 15000,
"delivery_type": "only_hanoi",
"a": 3,
"dt": "local",
"extFees": [
{
"display": "(+ 7,400 đ)",
"title": "Phụ phí hàng dễ vỡ",
"amount": 7400,
"type": "fragile"
},
{
"display": "(+ 13,400 đ)",
"title": "Phụ phí hàng nông sản/thực phẩm khô",
"amount": 13400,
"type": "food"
}
],
"delivery": true
}
}
Note:
info
-
In case
pick_address_id
has a valid value, the information such as province, district, etc., of the pickup address will be taken according to this address ID, and the fieldspick_province
,pick_district
are not required to be submitted -
Add the variable deliver_option = xteam to calculate the shipping fee for the xfast package.