Configuration
SDK Reference
Complete reference for all SearchX SDK configuration options.
Initialization
The SDK is initialized by calling SearchXSDK.init() with a configuration object:
SearchXSDK.init({
app_id: "YOUR_APP_ID",
api_key: "YOUR_API_KEY",
apiPageURL: "https://admin.searchxengine.ai/api/v1",
components: {
SearchBar: { root: "search-bar" },
SearchPage: { root: "search-page" },
},
settings: { ... },
});
Top-Level Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id | string | Yes | Your unique Application ID |
api_key | string | Yes | Your public API key for search requests |
apiPageURL | string | No | Base URL for the SearchX API. Defaults to https://admin.searchxengine.ai/api/v1 |
components | object | Yes | Mount points for SDK components |
customCSSUrl | string | No | URL to a custom CSS file loaded by the SDK |
customLocaleUrl | string | No | Base URL/path for translation JSON files |
defaultLanguage | string | No | Initial language code (e.g., en, el) |
settings | object | No | Feature and UI configuration (see below) |
Components Object
The components object specifies where to mount SDK UI elements:
components: {
SearchBar: { root: "search-bar-element-id" },
SearchPage: { root: "search-page-element-id" },
}
| Property | Description |
|---|---|
SearchBar.root | DOM element ID where the search bar will be rendered |
SearchPage.root | DOM element ID where the search results page will be rendered |
Settings Object
The settings object controls feature flags and UI behavior:
| Setting | Type | Default | Description |
|---|---|---|---|
searchPageURL | string | — | URL for search results page. Use {query} placeholder (e.g., /search?q={query}) |
mobileVewPort | string | number | "900px" | Breakpoint for switching to mobile view |
productsIndex | string | Auto | Meilisearch index name. Defaults to searchx_{app_id}_products_index |
platform | string | "opencart" | Hosting platform: "opencart", "custom", or "other" |
wishlistEnabled | boolean | false | Show "Add to Wishlist" button on product cards |
showIcon | boolean | false | Show "Quick Add to Cart" icon on thumbnails |
compactPagination | boolean | false | Use compact pagination style |
primaryFacetAttribute | string | "brand" | Primary filter group: "brand" or "categories" |
showBrand | boolean | false | Display brand name on product cards |
showSizes | boolean | false | Display available sizes on product cards |
showColor | boolean | false | Display product color on product cards |
showDescription | boolean | false | Display product description on product cards |
showBothFacets | boolean | false | Show both Category and Brand facets simultaneously |
showSizeFilter | boolean | false | Show Size filter in the sidebar |
showColorFilter | boolean | false | Show Color filter in the sidebar |
defaultPlaceholder | string | — | Custom placeholder text for the search input |
cartButtonText | string | — | Custom "Add to Cart" button text |
wishlistButtonText | string | — | Custom "Add to Wishlist" button text |
topSearches | string[] | — | Popular search terms to display as suggestions |
Full Example
SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
apiPageURL: 'https://admin.searchxengine.ai/api/v1',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
customCSSUrl: '/assets/theme.css',
customLocaleUrl: '/assets/i18n',
defaultLanguage: 'en',
settings: {
searchPageURL: '/search?q={query}',
mobileVewPort: '900px',
wishlistEnabled: true,
showIcon: true,
compactPagination: true,
primaryFacetAttribute: 'categories',
showBrand: true,
showSizes: true,
showColor: true,
showDescription: false,
showBothFacets: true,
showSizeFilter: true,
showColorFilter: true,
defaultPlaceholder: 'Search for products...',
cartButtonText: 'Buy Now',
wishlistButtonText: 'Save for later',
topSearches: ['Smartphone', 'Laptop', 'Headphones'],
},
});