Guide
Smart Search
Record search
2 min
if you haven't gone through the prerequisites and the v2 structure, please have a look at overview docid\ czeodl0skcuv 18ipuplr 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 { "tab" "examples", "url" "https //{{hostname}}/cs/v2/search", "name" "record search", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[], "bodydataparameters" \[ { "kind" "required", "name" "id", "type" "string", "description" "every suggestion request must have a unique identifier associated with it when a result is retrieved, the id of each query is associated with it's respective response " }, { "kind" "required", "name" "typeofrequest", "type" "string", "description" "this parameter defines the type of request, which should be 'search' for standard search queries there are other values available, detailed elsewhere in the documentation " }, { "kind" "required", "name" "query", "type" "string", "description" "the search term or phrase for which the suggestions are retrieved from klevu search " } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "3xlvmt855lgkjoht0npxg", "code" "{\n \\"meta\\" {\n \\"qtime\\" 7,\n \\"responsecode\\" 200\n },\n \\"queryresults\\" \[\n {\n \\"id\\" \\"productsearch\\",\n \\"meta\\" {\n \\"qtime\\" 6,\n \\"noofresults\\" 5,\n \\"totalresultsfound\\" 104,\n \\"typeofsearch\\" \\"wildcard and\\",\n \\"offset\\" 0,\n \\"debugginginformation\\" {},\n \\"notificationcode\\" 1,\n \\"searchedterm\\" \\"short\\",\n \\"apikey\\" \\"klevu 156925593843210765\\",\n \\"ispersonalised\\" false\n },\n \\"records\\" \[\n {\n \\"discount\\" \\"\\",\n \\"hidegroupprices\\" \\"\\",\n \\"type\\" \\"shorts\\",\n \\"itemgroupid\\" \\"4384016334910\\",\n \\"freeshipping\\" \\"\\",\n \\"storebasecurrency\\" \\"gbp\\",\n \\"price\\" \\"45 00\\",\n \\"toprice\\" \\"\\",\n \\"imageurl\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 green main 3ac6ebe5 2c3e 45cf 91cf ec54de5e5e3a medium jpg?v=1575477721\\",\n \\"currency\\" \\"gbp\\",\n \\"instock\\" \\"yes\\",\n \\"id\\" \\"31366431146046\\",\n \\"imagehover\\" \\"\\",\n \\"sku\\" \\"wsh12 28 green\\",\n \\"brand\\" \\"ksd\\",\n \\"startprice\\" \\"\\",\n \\"image\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 green main 3ac6ebe5 2c3e 45cf 91cf ec54de5e5e3a medium jpg?v=1575477721\\",\n \\"deliveryinfo\\" \\"\\",\n \\"hideaddtocart\\" \\"\\",\n \\"saleprice\\" \\"45 0\\",\n \\"swatchesinfo\\" \\"\\",\n \\"weight\\" \\"\\",\n \\"klevu category\\" \\"klevu product;products;;shorts @ku\@kucategory\@ku@\\",\n \\"totalvariants\\" 0,\n \\"groupprices\\" \\"\\",\n \\"url\\" \\"https //jsv2 shopify demo ksearchmisc com/products/erika running short green\\",\n \\"tags\\" \\"body hugging, green, nylon, running, short\\",\n \\"size\\" \\"small\\",\n \\"name\\" \\"erika running short\\",\n \\"shortdesc\\" \\"a great short with a body hugging design, the erika running short is perfect for runners who prefer a fitted short rather than the traditional baggy variety • seafoam pattern running shorts • elastic waistband • snug fit • 4''\\",\n \\"category\\" \\"shorts\\",\n \\"typeofrecord\\" \\"klevu product\\"\n },\n {\n \\"discount\\" \\"\\",\n \\"hidegroupprices\\" \\"\\",\n \\"type\\" \\"shorts\\",\n \\"itemgroupid\\" \\"4384016269374\\",\n \\"freeshipping\\" \\"\\",\n \\"storebasecurrency\\" \\"gbp\\",\n \\"price\\" \\"45 00\\",\n \\"toprice\\" \\"\\",\n \\"imageurl\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 purple main c57ce41e 7b0e 4cd2 a0de 18ddb6d2017a medium jpg?v=1575477720\\",\n \\"currency\\" \\"gbp\\",\n \\"instock\\" \\"yes\\",\n \\"id\\" \\"31366431080510\\",\n \\"imagehover\\" \\"\\",\n \\"sku\\" \\"wsh12 28 purple\\",\n \\"brand\\" \\"ksd\\",\n \\"startprice\\" \\"\\",\n \\"image\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 purple main c57ce41e 7b0e 4cd2 a0de 18ddb6d2017a medium jpg?v=1575477720\\",\n \\"deliveryinfo\\" \\"\\",\n \\"hideaddtocart\\" \\"\\",\n \\"saleprice\\" \\"45 0\\",\n \\"swatchesinfo\\" \\"\\",\n \\"weight\\" \\"\\",\n \\"klevu category\\" \\"klevu product;products;;shorts @ku\@kucategory\@ku@\\",\n \\"totalvariants\\" 0,\n \\"groupprices\\" \\"\\",\n \\"url\\" \\"https //jsv2 shopify demo ksearchmisc com/products/erika running short purple\\",\n \\"tags\\" \\"body hugging, nylon, red, running, short\\",\n \\"size\\" \\"large\\",\n \\"name\\" \\"erika running short\\",\n \\"shortdesc\\" \\"a great short with a body hugging design, the erika running short is perfect for runners who prefer a fitted short rather than the traditional baggy variety • seafoam pattern running shorts • elastic waistband • snug fit • 4''\\",\n \\"category\\" \\"shorts\\",\n \\"typeofrecord\\" \\"klevu product\\"\n },\n {\n \\"discount\\" \\"\\",\n \\"hidegroupprices\\" \\"\\",\n \\"type\\" \\"shorts\\",\n \\"itemgroupid\\" \\"4384016203838\\",\n \\"freeshipping\\" \\"\\",\n \\"storebasecurrency\\" \\"gbp\\",\n \\"price\\" \\"45 00\\",\n \\"toprice\\" \\"\\",\n \\"imageurl\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 red main 9999e03f 694d 4f0c 83ab 8c0200029275 medium jpg?v=1575477719\\",\n \\"currency\\" \\"gbp\\",\n \\"instock\\" \\"yes\\",\n \\"id\\" \\"31366431014974\\",\n \\"imagehover\\" \\"\\",\n \\"sku\\" \\"wsh12 28 red\\",\n \\"brand\\" \\"ksd\\",\n \\"startprice\\" \\"\\",\n \\"image\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/wsh12 red main 9999e03f 694d 4f0c 83ab 8c0200029275 medium jpg?v=1575477719\\",\n \\"deliveryinfo\\" \\"\\",\n \\"hideaddtocart\\" \\"\\",\n \\"saleprice\\" \\"45 0\\",\n \\"swatchesinfo\\" \\"\\",\n \\"weight\\" \\"\\",\n \\"klevu category\\" \\"klevu product;products;;shorts @ku\@kucategory\@ku@\\",\n \\"totalvariants\\" 0,\n \\"groupprices\\" \\"\\",\n \\"url\\" \\"https //jsv2 shopify demo ksearchmisc com/products/erika running short red\\",\n \\"tags\\" \\"body hugging, nylon, red, running, short\\",\n \\"size\\" \\"medium\\",\n \\"name\\" \\"erika running short\\",\n \\"shortdesc\\" \\"a great short with a body hugging design, the erika running short is perfect for runners who prefer a fitted short rather than the traditional baggy variety • seafoam pattern running shorts • elastic waistband • snug fit • 4''\\",\n \\"category\\" \\"shorts\\",\n \\"typeofrecord\\" \\"klevu product\\"\n },\n {\n \\"discount\\" \\"\\",\n \\"hidegroupprices\\" \\"\\",\n \\"type\\" \\"shorts\\",\n \\"itemgroupid\\" \\"4384040386622\\",\n \\"freeshipping\\" \\"\\",\n \\"storebasecurrency\\" \\"gbp\\",\n \\"price\\" \\"32 50\\",\n \\"toprice\\" \\"\\",\n \\"imageurl\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/msh03 black main a8796b84 9c70 4146 9c73 2295b0d260a7 medium jpg?v=1575478122\\",\n \\"currency\\" \\"gbp\\",\n \\"instock\\" \\"yes\\",\n \\"id\\" \\"31366465781822\\",\n \\"imagehover\\" \\"\\",\n \\"sku\\" \\"msh03 32 black\\",\n \\"brand\\" \\"kke\\",\n \\"startprice\\" \\"\\",\n \\"image\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/msh03 black main a8796b84 9c70 4146 9c73 2295b0d260a7 medium jpg?v=1575478122\\",\n \\"deliveryinfo\\" \\"\\",\n \\"hideaddtocart\\" \\"\\",\n \\"saleprice\\" \\"32 5\\",\n \\"swatchesinfo\\" \\"\\",\n \\"weight\\" \\"\\",\n \\"klevu category\\" \\"klevu product;products;;shorts @ku\@kucategory\@ku@\\",\n \\"totalvariants\\" 0,\n \\"groupprices\\" \\"\\",\n \\"url\\" \\"https //jsv2 shopify demo ksearchmisc com/products/meteor workout short black\\",\n \\"tags\\" \\"black, machine, nylon, relaxed fit, short, summer\\",\n \\"size\\" \\"small\\",\n \\"name\\" \\"meteor workout short\\",\n \\"shortdesc\\" \\"step into the meteor workout short for an incredibly lightweight fitness experience its breathable construction and an inner brief provide additional comfort and support, while the adjustable waistband offers the perfect fit to take you to the fi\\",\n \\"category\\" \\"shorts\\",\n \\"typeofrecord\\" \\"klevu product\\"\n },\n {\n \\"discount\\" \\"\\",\n \\"hidegroupprices\\" \\"\\",\n \\"type\\" \\"shorts\\",\n \\"itemgroupid\\" \\"4384039665726\\",\n \\"freeshipping\\" \\"\\",\n \\"storebasecurrency\\" \\"gbp\\",\n \\"price\\" \\"29 00\\",\n \\"toprice\\" \\"\\",\n \\"imageurl\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/msh05 gray main 0f869cff 09fb 403a a209 cf092f4d3c1a medium jpg?v=1575478112\\",\n \\"currency\\" \\"gbp\\",\n \\"instock\\" \\"yes\\",\n \\"id\\" \\"31366465060926\\",\n \\"imagehover\\" \\"\\",\n \\"sku\\" \\"msh05 32 gray\\",\n \\"brand\\" \\"ksd\\",\n \\"startprice\\" \\"\\",\n \\"image\\" \\"https //cdn shopify com/s/files/1/0116/9457/1582/products/msh05 gray main 0f869cff 09fb 403a a209 cf092f4d3c1a medium jpg?v=1575478112\\",\n \\"deliveryinfo\\" \\"\\",\n \\"hideaddtocart\\" \\"\\",\n \\"saleprice\\" \\"29 0\\",\n \\"swatchesinfo\\" \\"\\",\n \\"weight\\" \\"\\",\n \\"klevu category\\" \\"klevu product;products;;shorts @ku\@kucategory\@ku@\\",\n \\"totalvariants\\" 0,\n \\"groupprices\\" \\"\\",\n \\"url\\" \\"https //jsv2 shopify demo ksearchmisc com/products/hawkeye yoga short gray\\",\n \\"tags\\" \\"gray, machine, nylon, relaxed fit, short, summer\\",\n \\"size\\" \\"medium\\",\n \\"name\\" \\"hawkeye yoga short\\",\n \\"shortdesc\\" \\"what more do you need than a sporty yoga short made with organic cotton and a little spandex for mobility? the hawkeye yoga short brings a stylish, standard fit you can sport with confidence outside the studio • dark gray shorts with red a\\",\n \\"category\\" \\"shorts\\",\n \\"typeofrecord\\" \\"klevu product\\"\n }\n ],\n \\"filters\\" \[]\n }\n ]\n}", "language" "200", "customlabel" "" } ], "selectedlanguageid" "3xlvmt855lgkjoht0npxg" }, "examples" { "languages" \[ { "id" "jsu7dlyyj euh63ysp682", "code" "{\n \\"recordqueries\\" \[\n {\n \\"id\\" \\"productsearch\\",\n \\"typeofrequest\\" \\"search\\",\n \\"settings\\" {\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"limit\\" 5,\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}", "language" "json", "customlabel" "request body (json)" }, { "id" "8yg33te4jzfowp5yebmjh", "code" "\<?php\n\n$curl = curl init();\n\ncurl setopt array($curl, array(\n curlopt url => 'https //eucs15v2 ksearchnet com/cs/v2/search',\n curlopt returntransfer => true,\n curlopt encoding => '',\n curlopt maxredirs => 10,\n curlopt timeout => 0,\n curlopt followlocation => true,\n curlopt http version => curl http version 1 1,\n curlopt customrequest => 'post',\n curlopt postfields =>'{\n \\"recordqueries\\" \[\n {\n \\"id\\" \\"productsearch\\",\n \\"typeofrequest\\" \\"search\\",\n \\"settings\\" {\n \\"query\\" {\n \\"term\\" \\"short\\"\n },\n \\"limit\\" 5,\n \\"typeofrecords\\" \[\n \\"klevu product\\"\n ]\n }\n }\n ],\n \\"context\\" {\n \\"apikeys\\" \[\n \\"klevu 156925593843210765\\"\n ]\n }\n}',\n curlopt httpheader => array(\n 'content type text/plain'\n ),\n));\n\n$response = curl exec($curl);\n\ncurl close($curl);\necho $response;\n", "language" "php", "customlabel" "" }, { "id" "wcdgtssqaxfiwklk2v174", "code" "var data = \\"{\\\n \\\\\\"recordqueries\\\\\\" \[\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"productsearch\\\\\\",\\\n \\\\\\"typeofrequest\\\\\\" \\\\\\"search\\\\\\",\\\n \\\\\\"settings\\\\\\" {\\\n \\\\\\"query\\\\\\" {\\\n \\\\\\"term\\\\\\" \\\\\\"short\\\\\\"\\\n },\\\n \\\\\\"limit\\\\\\" 5,\\\n \\\\\\"typeofrecords\\\\\\" \[\\\n \\\\\\"klevu product\\\\\\"\\\n ]\\\n }\\\n }\\\n ],\\\n \\\\\\"context\\\\\\" {\\\n \\\\\\"apikeys\\\\\\" \[\\\n \\\\\\"klevu 156925593843210765\\\\\\"\\\n ]\\\n }\\\n}\\";\n\nvar xhr = new xmlhttprequest();\nxhr withcredentials = false;\n\nxhr addeventlistener(\\"readystatechange\\", function() {\n if(this readystate === 4) {\n console log(this responsetext);\n }\n});\n\nxhr open(\\"post\\", \\"https //eucs15v2 ksearchnet com/cs/v2/search\\");\nxhr setrequestheader(\\"content type\\", \\"text/plain\\");\n\nxhr send(data);", "language" "javascript", "customlabel" "" }, { "id" "npw0nije j5r9i5w4bgn0", "code" "okhttpclient client = new okhttpclient() newbuilder()\n build();\nmediatype mediatype = mediatype parse(\\"text/plain\\");\nrequestbody body = requestbody create(mediatype, \\"{\\\n \\\\\\"recordqueries\\\\\\" \[\\\n {\\\n \\\\\\"id\\\\\\" \\\\\\"productsearch\\\\\\",\\\n \\\\\\"typeofrequest\\\\\\" \\\\\\"search\\\\\\",\\\n \\\\\\"settings\\\\\\" {\\\n \\\\\\"query\\\\\\" {\\\n \\\\\\"term\\\\\\" \\\\\\"short\\\\\\"\\\n },\\\n \\\\\\"limit\\\\\\" 5,\\\n \\\\\\"typeofrecords\\\\\\" \[\\\n \\\\\\"klevu product\\\\\\"\\\n ]\\\n }\\\n }\\\n ],\\\n \\\\\\"context\\\\\\" {\\\n \\\\\\"apikeys\\\\\\" \[\\\n \\\\\\"klevu 156925593843210765\\\\\\"\\\n ]\\\n }\\\n}\\");\nrequest request = new request builder()\n url(\\"https //eucs15v2 ksearchnet com/cs/v2/search\\")\n method(\\"post\\", body)\n addheader(\\"content type\\", \\"text/plain\\")\n build();\nresponse response = client newcall(request) execute();", "language" "java", "customlabel" "" }, { "id" "0ih7niekhhfml7cry51j ", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //eucs15v2 ksearchnet com/cs/v2/search',\n 'headers' {\n 'content type' 'text/plain'\n },\n body '{\\\n \\"recordqueries\\" \[\\\n {\\\n \\"id\\" \\"productsearch\\",\\\n \\"typeofrequest\\" \\"search\\",\\\n \\"settings\\" {\\\n \\"query\\" {\\\n \\"term\\" \\"short\\"\\\n },\\\n \\"limit\\" 5,\\\n \\"typeofrecords\\" \[\\\n \\"klevu product\\"\\\n ]\\\n }\\\n }\\\n ],\\\n \\"context\\" {\\\n \\"apikeys\\" \[\\\n \\"klevu 156925593843210765\\"\\\n ]\\\n }\\\n}'\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "language" "nodejs", "customlabel" "" } ], "selectedlanguageid" "8yg33te4jzfowp5yebmjh" }, "description" "this is an example to fetch instant auto complete using apis ", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } try it here!