11. Product Information API
This API returns a list of products (along with their product IDs) based on a search keyword
- Product codes are required in specific operational flows when placing an order via the order creation API
Endpoint
GET /services/kho-hang/thong-tin-san-pham?term=laptop
Headers
- Token:
{API_TOKEN}
- X-Client-Source:
{PARTNER_CODE}
- Content-Type:
application/json
Sample Request
- HTTP
- CURL
- PHP
GET /services/kho-hang/thong-tin-san-pham?term=laptop HTTP/1.1
Token: {API_TOKEN}
X-Client-Source: {PARTNER_CODE}
curl -X GET -H "Token: {API_TOKEN}"\
-H "X-Client-Source: {PARTNER_CODE}"\
"{OPEN_API}/services/kho-hang/thong-tin-san-pham?term=laptop"
<?php
$data = array(
"term" => "laptop",
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "{OPEN_API}/services/kho-hang/thong-tin-san-pham?" . http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"Token: {API_TOKEN}",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo 'Response: ' . $response;
?>
Parameters
Parameter | Required | Description |
---|---|---|
term | yes | String - Name of products requiring information |
Response
Case 1: The shop has previously registered the product with GHTK
{
"success": true,
"data" : [
{
"full_name": "Laptop Asus",
"product_code": "23304A3MHLMVMXX625",
"weigh": 2,
"cost": 8000000
},
{
"full_name": "Laptop Dell",
"product_code": "23304A3MHLMVMXX888",
"weigh": 2.5,
"cost": 12000000
}
]
}
Case 2: The product has not been registered on GHTK before
{
"success": true,
"data" : []
}
warning
In this case, the partner’s system must send product_code: ""
in the order creation API request. GHTK’s system will then auto-generate a new product code.