Guide

4min

The @klevu/core reference section will list all the available functions, enums, etc., for the library, but we wanted to call out a few of the most common and important ones here.

klevuFetch

As mentioned in the Quickstart queries to Klevu are made with the klevuFetch function. Inside KlevuFetch you can provide any amount of Query Functions as parameters. Within the query functions you call, you are also able to pass any number of Modifier Functions.

For example within our React example, on the search landing page we pass in a search query function along with two modifier functions.

JS
TypeScript


In the above example we pass in the search and suggestions query functions to klevuFetch. In the search query function we then pass in the search term, options (id, limit, sorting, type of search, etc), and two modifier functions (listFilters and applyFilterWithManager).

Continue to the next section to learn more about Query Functions and Modifier Functions.

Result Object

Once you've made your queries through klevuFetch, a single response object is returned. Because you are able to request more than one search, each search should have an ID. These IDs can then be used to reference the results of each search using either queriesById or suggestionsById

In the above code example, the result variable is the result object.

Once you have the query you want to work with, you will find many helpful functions available to such as generating click handlers to send analytics back to Klevu, or requesting more records/data when using a limit.

KlevuKMCSettings Utility Function

Every Klevu account comes with a feature-rich admin panel called KMC (Klevu Merchant Center). In order to fetch many of the settings found in KMC, you call KlevuKMCSettings() asynchronously as shown below.

JS
JSON Response


As you can see, not only do you get the majority of settings, you also get access to Promotional Banners, URL Redirects and more.

Updated 21 Jun 2024
Did this page help you?