--- title: "Eureka SDK Fetch Methods" slug: "eureka-sdk-fetch-methods" description: "Documents Eureka SDK fetch methods under Insider.eureka.fetch: search, productListing, suggestion, popularSearch, recentSearch, and clearRecentSearch." tags: ["eureka campaign", "create eureka campaign"] updated: 2026-03-27T15:19:05Z published: 2026-03-27T15:19:05Z canonical: "academy.insiderone.com/eureka-sdk-fetch-methods" --- > ## Documentation Index > Fetch the complete documentation index at: https://academy.insiderone.com/llms.txt > Use this file to discover all available pages before exploring further. # Eureka SDK Fetch Methods All Eureka SDK methods for fetching items are accessible under Insider.eureka.fetch namespace: Use the campaign/builder identifier from the eureka:sdk:campaign:ready event as campId. > [!NOTE] > Every time a user changes **sorting**, applies or removes **filters (facets)**, or navigates to a different page **(pagination)**, the relevant fetch method must be called again with the updated parameters to retrieve the new results. ## Search Method Use this method to fetch data for the search popup or the search listing page. Call this method again whenever the user changes the sorting, applies/removes filters, or navigates to a different page. - **Method**: Insider.eureka.fetch.search(campId, query, options) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | | query | String | Yes | Search text entered by the user | | options | Object | No | Optional settings (see below) | - **Options** | Field | Type | Description | | --- | --- | --- | | pagination | Object | Pagination settings | | pagination.from | Number | Starting index of results. Minimum: 0. Default: 0 | | pagination.size | Number | Number of results to return. Minimum: 1. Default: 10 | | sorting | String | Sorting method (e.g. 'Relevancy', 'PriceAsc', 'PriceDesc', 'NewestFirst') | | facets | Array | Filter conditions. Each facet must have field (string) and values (array). Example: [{ field: 'brand_en', values: ['BrandA', 'BrandB'] }] | **Example:** ```javascript Insider.eureka.fetch.search(999999, 'queryA', {    pagination: { from: 0, size: 10 },    sorting: 'Relevancy',    facets: [{ field: 'price_en', values: ['500', '2000'] }] }).then(function (response) {    // Use response.data.items to display search results }).catch(function (error) {    // Handle error }); ``` ## Product Listing Use this method to fetch data for category listing pages, brand listing pages, or all products. Call this method again whenever the user changes the sorting, applies/removes filters, or navigates to a different page. - **Method:** Insider.eureka.fetch.productListing(campId, collectionType, listingPageName, options) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | | collectionType | String | Yes | One of: 'Category', 'Brand', 'AllProducts' | | listingPageName | String | Yes (except AllProducts) | Category or brand hierarchy using ~ as a separator. Example: 'categoryA~categoryB'. Can be empty for AllProducts. | | options | Object | No | Optional settings (see below) | - **Options:** | Field | Type | Description | | --- | --- | --- | | pagination | Object | Pagination settings | | pagination.from | Number | Starting index of results. Minimum: 0. Default: 0 | | pagination.size | Number | Number of results to return. Minimum: 1. Default: 25 | | sorting | String | Sorting method (e.g. 'Relevancy', 'PriceAsc') | | facets | Array | Filter conditions. Example: [{ field: 'color_en', values: ['Red', 'Blue'] }] | **Example - Category listing:** ```javascript Insider.eureka.fetch.productListing(470, 'Category', 'categoryA~categoryB', {    pagination: { from: 0, size: 25 },    sorting: 'Relevancy' }).then(function (response) {    // Use response to display category listing page }); ``` **Example - Brand listing:** ```javascript Insider.eureka.fetch.productListing(470, 'Brand', 'BrandName', {}).then(function (response) {    // Use response to display brand listing page }); ``` **Example - All products:** ```javascript Insider.eureka.fetch.productListing(470, 'AllProducts', '', {}).then(function (response) {    // Use response to display listing page }); ``` > [!NOTE] > The listingPageName parameter uses tilde (~) as a hierarchy separator. For example: 'categoryA~categoryB~categoryC'. ## Suggestion Use this method to fetch search suggestions (autocomplete) as the user types. - **Method:** Insider.eureka.fetch.suggestion(campId, query) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | | query | String | Yes | Partial or complete search text entered by the user | **Example:** ```javascript Insider.eureka.fetch.suggestion(999999, 'queryA').then(function (response) {    // Display suggestion list from response }); ``` ## Popular Search Use this method to fetch trending/popular search terms. - **Method:** Insider.eureka.fetch.popularSearch(campId) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | **Example:** ```javascript Insider.eureka.fetch.popularSearch(999999).then(function (response) {    // Display popular search terms from response }); ``` ## Recent Search Use this method to fetch the current user's recent search history. - **Method:** Insider.eureka.fetch.recentSearch(campId) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | **Example:** ```javascript Insider.eureka.fetch.recentSearch(999999).then(function (response) {    // Display recent searches from response }); ``` ## Clear Recent Search Use this method to clear the user's recent search history. You can clear a specific search or all searches. - **Method:** Insider.eureka.fetch.clearRecentSearch(campId, queryId) | Parameter | Type | Required | Description | | --- | --- | --- | --- | | campId | Number or String | Yes | Campaign/builder ID | | queryId | Number or String | No | ID of a specific search to clear. If omitted, **all** recent searches are cleared. | **Example - Clear all recent searches:** ```javascript Insider.eureka.fetch.clearRecentSearch(999999).then(function () {    // All recent searches cleared }); ``` **Example - Clear a specific search:** ```javascript Insider.eureka.fetch.clearRecentSearch(999999, 'queryId-123').then(function () {    // Specific search cleared }); ``` ## Validations Each fetch method validates its parameters before making the request. If validation fails, the method immediately returns Promise.reject(). | Method | Fails when | | --- | --- | | fetch.search / fetch.suggestion | campId is not a number or string, or query is not a non-empty string | | fetch.productListing | campId is invalid; collectionType is not 'Category', 'Brand', or 'AllProducts'; for Category or Brand, listingPageName is not a non-empty string | | fetch.popularSearch / fetch.recentSearch | campId is not a number or string | | fetch.clearRecentSearch | campId is invalid; if provided, queryId is not a number or string | > [!NOTE] > Always handle errors using .catch() to prevent unhandled promise rejections. ```javascript Insider.eureka.fetch.search(999999, 'queryA')    .then(function (response) { /* success */ })    .catch(function (error) { /* handle error */ }); ```