The SDK send method enables making different request types—autocomplete, search, smart collections, recommendations, content, and feedback—through a unified interface with type-specific parameters. This provides a consistent API for accessing all platform features while handling request formatting, authentication, and response parsing automatically.
Each request type supports specific parameters like query strings, filters, sorting options, and pagination controls that enable precise control over results. This helps ensure you can implement sophisticated search and merchandising experiences while maintaining clean, maintainable code through the SDK's typed interfaces and helper methods.
Arguments:
request.type required (RequestType): The type of the request to be sent to the API. Check the type definition below for more details.request.params required (Params): The parameters that are sent to the request. Check the Types for more details on the params object.
Types:
type required (RequestType): 'autocomplete' | 'search' | 'smart-collection' | 'recommendations' | 'feedback' | 'content'. Determines the type of request sent.user.uid required (string): Unique customer id.user.sid required (string): Session id.user.email optional (string): Customer email.user.ip optional (number): Customer ip.user.ua optional (string): Customer user agent.user.lang optional (string[]): Languages.
Params.user optional (User): Current user identity info. Can be provided on initialisation or per-request.
The rest of the request.params object depends on the value of request.type. Below are listed all different variants of the Params type.
Types
Filter.name required (string): Name of filterFilter.type required (string): Type of filterFilter.values optional (FilterValue[]): Array of selected filter valuesSort.field required (string): Field to sort bySort.order required ('asc' | 'desc'): Sorting orderFilterValue.value optional (string): Selected filter valueFilterValue.from optional (string): Selected filter 'from' value (for range filters)FilterValue.to optional (string): Selected filter 'to' value (for range filters)
type: autocomplete
Params.q: optional (string): The autocomplete queryParams.suggestion_limit optional (number): Limit of search suggestionsParams.item_limit optional (number): Limit of product matches
type: search
Params.q required (string): The search queryParams.offset optional (number): Offset of product items. Used for paginationParams.limit optional (number): Number of products in resultParams.filters optional (Filter[]): Array of selected filtersParams.sort optional (Sort[]): Array of selected sorts
type: smart-collection
Params.slot required (string): Collection handleParams.offset optional (number): Offset of product items. Used for paginationParams.limit optional (number): Number of products in resultParams.filters optional (Filter[]): Array of selected filtersParams.sort optional (Sort[]): Array of selected sorts
type: recommendation
Params.type: required ('slot' | 'newest' | 'trending' | 'latest' | 'viewed' | 'bought' | 'purchasedTogether' | 'featured'): The recommendation typeThe rest of the params depend on the recommendation type.
Params.type: 'slot'Params.slot required (string): The collection handleParams.item_ids required (string): Array of product item IDsParams.offset optional (number): Offset of product items. Used in paginationParams.type: 'newest' | 'trending' | 'latest' | 'featured'Params.offset optional (number): Offset of product items. Used in paginationParams.limit optional (number): Limit of product items in response. Used in paginationParams.type: 'viewed' | 'bought'Params.offset optional (number): Offset of product items. Used in paginationParams.limit optional (number): Limit of product items in response. Used in paginationParams.item_id required (string): The product item ID.Params.type: 'purchasedTogether'Params.offset optional (number): Offset of product items. Used in paginationParams.limit optional (number): Limit of product items in response. Used in paginationParams.item_ids required (string[]): Array of product item IDs.
type: content
Params.filters optional (Filter[]): Array of selected filtersParams.sort optional (Sort[]): Array of selected sortsParams.q required (string): Search query
type: feedback
Params.event: required (EventType): The feedback event type. The event can be one of the following values:EventType: 'click-suggestion' | 'click-item' | 'redirect' | 'purchase' | 'add-to-cart' | 'update-cart' | 'view-page'
The rest of the properties on the Params type depend on which event is being sent. The different Params properties are defined below.
Types:
LineItem.item_id: required (string): Item ID of the bought item.LineItem.variant_item_id: optional (string): Variant item ID of the bought item.LineItem.unit_price: required (string): Sale price of the product.LineItem.quantity: required (string): Quantity bought.
event: click-suggestionParams.rid: required (string): The request ID preceding the clickthrough.Params.suggestion: required (string): The suggestion that is clicked.event: click-itemParams.item_id: required (string): The item ID of the clicked item.Params.variant_item_id: optional (string): The variant item ID of the clicked item.Params.rid: required (string): The request ID preceding the clickthrough.event: redirectParams.rid: optional (string): The request ID preceding the redirection.Params.suggestion: required (string): The suggestion that leads to the redirection.event: purchaseParams.order_id: required (string): The order ID.Params.currency: required (string): Currency of the purchase.Params.revenue: required (number): The total revenue.Params.line_items: required (LineItem[]): The items in cart.Params.affiliation: optional (string): Affiliation of the purchase.event: add-to-cartParams.item_id: required (string): Item ID added to cart.Params.rid: optional (string): Request ID preceding the add-to-cart.Params.quantity: optional (number): Quantity added to cart. default = 1.event: update-cartParams.line_items: required (LineItem[]): Items in cart.event: view-pageParams.url: required (string): URL of the page viewed.Params.ref: required (string): Referrer of the page.Params.width: required (number): Width of the customer's browser.Params.height: required (number): Height of the customer's browser.Params.item_id: optional (string): Item ID - only for product pages.Params.variant_item_id: optional (string): Variant Item ID - only for product pages.
Returns:
Result of requested operation, depends on type of request.
Examples of usage:
Autocomplete
var request = {
type: 'autocomplete',
params: {
q: 'autocomplete-query',
suggestion_limit: 10,
}
};
client.send(request).then(function(response) {
// handle autocomplete response
});
Search
var request = {
type: 'search',
params: {
q: 'search-query',
offset: 24,
limit: 48,
},
};
client.send(request).then(response => {
// handle search response
});
Smart Collections
var request = {
type: 'smart-collection',
params: {
slot: 'collection-name',
offset: 24,
limit: 48,
},
};
client.send(request).then(response => {
// handle smart collection response
});
Recommendations
var request = {
type: 'recommendation',
params: {
type: 'trending',
offset: 24,
limit: 48,
},
};
client.send(request).then(response => {
// handle recommendation response
});
Content Search
var request = {
type: 'content',
params: {
q: 'search-query',
offset: 24,
limit: 48,
},
};
client.send(request).then(response => {
// handle content search response
});
Feedback
var request = {
type: 'feedback',
params: {
event: 'click-item',
item_id: '1234',
rid: 'abcd1234',
},
};
client.send(request).then(response => {
// handle feedback response
});
Related Articles
Integration & Setup:
Search & Discovery:
Product Recommendations: