Guide
Smart Search
Overview
8 min
klevu apiv2 is the latest version of our api for integrating smart search into your applications for lightning fast search as , record search results js api key & endpoint you must have a klevu search account to use the klevu api please access the 'shop info' tab of your klevu merchant centre to retrieve the following credentials js api key (readonly key) for querying indexed data e g klevu 156925593843210765 apiv2 cloud search url for end point e g eucs15v2 ksearchnet com if you have multiple stores with klevu, please note it is likely that each of them will have totally different js api keys and subdomains assigned search url when retrieving data for search, category merchandising or recommendations, klevu apiv2 utilizes a single endpoint https //{{apiv2 cloud search url}}/cs/v2/search please replace apiv2 cloud search url with your own value, which you can find in the prerequisites above for example, if your url is 'eucs15v2 ksearchnet com' then the correct value is https //eucs15v2 ksearchnet com/cs/v2/search the inclusion of 'v2' is important without it you will experience degraded performance since your api requests will not be utilizing our content delivery network (cdn) get vs post the apiv2 endpoint url accepts requests in json format and also responds with json requests can be made using either get or post, however we recommend post because our requests are routed through cloudflare cdn, which has a limit on the size of the payload, we are accepting request payloads up to 8kb request object every request to apiv2 comprises a structured json payload a request object the request object is a top level object that comprises a mandatory context and one or both of the suggestions and recordqueries objects each http request can contain multiple search queries the context object is for specifying your js api key the suggestions object is for requesting suggestions or typeahead results the recordqueries object is for requesting entities such as products or cms pages please note that despite apikeys being an array, currently we only support a single api key per request a skeleton of the request object looks like this json request { "request" { "context" { "apikeys" \[" "] }, "suggestions" \[ { suggestions query 1 }, { suggestions query 2 } ], "recordqueries" \[ { record query 1 }, { record query 2 } ] } } response object when a query is fired, depending on the query objects included in the request, i e suggestions and/or record queries, the klevu search engine returns a response object containing data for each of these query types, suggestionresults and queryresults the meta object contains information on the query related parameters, for example the time taken, the total number of results found, etc the skeleton of the response object looks like this json response { "meta" { }, "suggestionresults" \[ { result of suggestions query 1 }, { result of suggestions query 2 } ], "queryresults" \[ { result of record query 1 }, { result of record query 2 } ], } understanding the response parameters 231,513,248 false true unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type