11. API to retrieve the product list
The API returns a list of products (and their corresponding IDs) that match the search query.
The product ID will need to be included in the order submission API for certain specific workflows.
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 | Mandatory | Desc |
---|---|---|
term | yes | String - Product search term |
Response
Case 1 : Shops that have previously registered order information or product information on the GHTK system.
{
"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 : Products whose information has never been entered into the GHTK system.
{
"success": true,
"data" : []
}
warning
In this case, the partner's order submission API should send product_code: ""
so that the GHTK system generates a new product code.