Record search
2 min
If you haven't gone through the prerequisites and the v2 structure, please have a look at Overview
The recordQuery object is used for searching for records. Use this for retrieving Products, Categories, CMS Pages or your own Custom Entity types when your customer has submitted a search query.
Record search
This is an example to fetch instant auto complete using APIs.
POST
https://{{hostname}}/cs/v2/search
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://eucs15v2.ksearchnet.com/cs/v2/search',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"recordQueries": [
{
"id": "productSearch",
"typeOfRequest": "SEARCH",
"settings": {
"query": {
"term": "short"
},
"limit": 5,
"typeOfRecords": [
"KLEVU_PRODUCT"
]
}
}
],
"context": {
"apiKeys": [
"klevu-156925593843210765"
]
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: text/plain'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Try it here!