- 02 May 2024
- 10 Minutes to read
Eureka Search API
- Updated on 02 May 2024
- 10 Minutes to read
Overview
Eureka’s API (Search API) lets you quickly and smoothly implement our search engine within your website(s), or mobile application(s). Insider's powerful search engine powers millions of queries every month, and is capable of delivering relevant results in under 150-400 ms regardless of the location.
The first step is to send your data in the correct format to Insider. Eureka will return the results in JSON. The response will include products that match the search criteria, available facet options to further refine the results and any configured merchandising content.
Requirements for Search API
- Insider product catalog integration methods (XML, Catalog API and Clickstream) should be created for product details.
- Data collection should be activated by Insider team.
- Eureka should be activated by Insider team.
- The facets & filters, synonyms, URL redirections should be defined on Insider's InOne panel.
Endpoint
You can use two domains to use the Search API:
- eureka.api.useinsider.com
- ineureka.api.useinsider.com
When the request is sent in this way, an authentication exception is thrown for security reasons. Therefore, when sending the request, you need to set the X-AUTH-TOKEN field in the header with the token shared with you and send the request.
The only difference between GET and POST requests is that the values sent as URL parameters in GET requests must be sent as JSON body in POST requests as you can see below:
{
"q": "SEARCH_QUERY",
"p": "PARTNER_ID",
"l": "LOCALE",
"c": "CURRENCY"
}
Bear in mind that when the request is sent, an authentication exception is thrown for security reasons. In order to avoid this, you need to set the X-AUTH-TOKEN field in the header with the token while sending the request.
Request Parameters
Parameter | Description | Data Type | Required |
---|---|---|---|
q | Query String that will be searched | String | Yes |
p | This is your partner ID. Navigate to InOne > InOne Settings > Account Preferences to copy your partner ID. | String | Yes |
l | Locale is required to get partner products in the current language of the website. E.g. en_US, en_GB | String | Yes |
c | The searched products will be displayed in the given currency (The current currency that has been selected by the end user on your website). E.g. USD, AUD | String | No |
ps | Number of products will return in the response. For example, if phone is searched with ps=5, then the API will bring the most relevant 5 phones to the current page. The default value is ps=6. | Integer | No |
pf | The searched products starting index from the given page number will be displayed. The default value is pf=0. | Integer | No |
a | Filter the products with the following pattern: a={field}~{value} | List of String | No |
st | Sorting type of the searched products. It only takes one of the predefined sorting types. The default value is st=Relevancy. | String | No |
u | User ID. It can be found on localstorage by the key name spUID. spUID is a stringified object and it contains data and expire properties. User Id should be sent if the personalized search is active. | String | No |
oi | The searched products will be displayed as only item ids. | Boolean | No |
qs | Applied strategies of the search query. It only takes an encoded string that is auto-generated by the first query in the response. | String | No |
Sorting
The st parameter in the request can only have one value from the predefined sorting types. Using these types, the sorting algorithm for the searched products is selected. Depending on your data, the sorting types can be active or inactive, you can view these settings on the InOne panel.
Parameter | Sorting Type |
---|---|
st | Relevancy |
st | PriceAsc |
st | PriceDesc |
st | MostPopularFirst |
st | BestRatedFirst |
st | MostRatedFirst |
st | NewestFirst |
st | MostFavoriteFirst |
st | MostDiscountedFirst |
Filters
Search results can be filtered using fields in filter settings defined in faceting on the Insider's InOne panel.
Sample Filter Result Regarding the Filter Config
Sample filter request:
&a=category~Skin~Body Lotions&a=price~5~10
In the result of this filter request, you can see the matched facets in the related result section as below:
{
"itemProperties": {
"item_card": {
"price": {
"EUR": 7.75,
...
},
"category": [
"Skin",
"Body Lotions",
...
],
"in_stock": 1,
...
},
...
},
...
}
The field values that you can use for facet filtering is provided under data.aggregations in the result.
[
{
"name": "price",
"label": "Price",
"style": "Slider",
"items": [
{
"name": "0~5",
"min": 0.0,
"max": 5.0
},
{
"name": "5~10",
"min": 5.0,
"max": 10.0
},
...
],
"sequence": 1,
"itemOrderType": "KeyAsc"
},
{
"name": "category",
"label": "Category",
"style": "List",
"items": [
{
"name": "Skin",
"selected": true,
"documentCount": 66
},
{
"name": "Body Lotion",
"selected": true,
"documentCount": 61
},
...
],
"sequence": 2,
"itemOrderType": "CountDesc"
},
{
"name": "in_stock",
"label": "In Stock",
"style": "Checkboxes",
"items": [
{
"name": "1",
"selected": false,
"documentCount": 12
},
...
],
"sequence": 3,
"itemOrderType": "CountDesc"
},
...
]
"a" parameter should be passed to the request as a query string when the request method is GET, or it should be passed as a list of strings when the request method is POST. The "a" can take multiple fields and each must be stated separately. Also, the field can take multiple values separated by a tilda (~). Field values should be different and if there is more than one value, they should be written by separating them according to the filter pattern.
?a={field}~{value}&a={field}~{value}
{"a": ["{field}~{value}", "{field}~{value}"]}
Filter Style | Data Type |
---|---|
Price | Numeric |
Rating | Numeric |
Range | Numeric |
Slider | Numeric |
Checkboxes | String |
List | String |
Toggle | Boolean |
For the filters with numeric data types such as Slider style, there should be only two values min and max.
{field}~{minValue}~{maxValue}
Sample Filter Parameters
&a=brand~Mybrand
&a=category~Birds~Cats~Dogs
&a=price~50~100
&a=brand~Mybrand&a=price~50~100
Sample Responses
API Responses
Parameter | Definition |
---|---|
status | It is the field that shows the result of the search. This field can be: - Success: Search API response is valid. - SuccessFallback: If Search API returns an empty item list, Eureka Search API - sends a request to Recommendation API and returns the items. - Error: Unexpected internal server errors. - Invalid: Eureka Search API returns a Validation Exception. The request is invalid. - BusinessException: Eureka Search API returns a Business Exception. Details are shared in Validation Exceptions section. |
data | It is the object where items, sortings, aggregations, navigations, and noResultPageText are kept as a result of a given query. |
data.items | This field holds the list of properties for the returned items. |
data.items.itemId | It shows the item ID. * In case there are variants of the item, the ID refers to the item to be displayed in search results. The item details are kept under data.items.itemProperties in addition to that all the variants including the item displayed are also stored in data.items.itemVariants |
data.items.itemProperties.item_card | This field holds all of the fields such as original_price, product_attributes (includes list of fields such as review_count, product_brand etc.). * It includes price and original_price fields. These two fields are the same if there is no discount on this product. However, if there is a discount, price field is equal to discounted price. * These fields may vary depending on your account. |
data.items.itemVariants | This field holds all of the variants of an item. The first element of the list is the item to be displayed in search results. The format of data.items.itemVariants items is the same as the data.items.itemProperties.item_card. * Variants are options of the same item that have different properties. For instance, yellow and red color options of the same t-shirt might be variants of the t-shirt. * Use of variants may be active or passive depending on your account. |
data.aggregations | This field holds a list of different aggregations. |
data.aggregations.name | This field holds the aggregation name. |
data.aggregations.label | This field holds the aggregation label (which shows the name of the aggregation to the end user). |
data.aggregations.style | This field holds the aggregation style. Possible values: Checkboxes, Toggle, Rating, Range, Slider, List, None |
data.aggregations.items | This field holds a list of item fields for the specified aggregation. |
data.aggregations.items.name | This field holds the aggregation item name. |
data.aggregations.items.label | This field holds the aggregation item label. |
data.aggregations.items.min | This field holds the minimum value of the aggregation item. |
data.aggregations.items.max | This field holds the maximum value of the aggregation item. |
data.aggregations.items.selected | It is a boolean field that indicates whether the aggregation item is selected. |
data.aggregations.items.documentCount | This field holds the total number of documents of the aggregation item. |
data.aggregations.suffixUnit | This field holds the suffix unit for the facet values as a string. For instance, for perfume_size facets, ml is the suffixUnit (50ml - 100ml) |
data.aggregations.prefixUnit | This field holds the prefix unit for the facet values as a string. |
data.aggregations.sequence | This field holds the sequence of the aggregation for showing the aggregations to the end-user in the correct order. |
data.aggregations.itemOrderType | This field holds the item order type of the aggregation. Possible values: KeyAsc, KeyDesc, CountDesc, CountAsc, None |
data.navigation | This dictionary shows information such as pagination and total item count. |
data.navigation.totalPages | This field shows how many pages are returned for a given query. |
data.navigation.currentPage | This field specifies which page the returned result is. |
data.navigation.totalItems | This field shows how many items are returned for a given query. |
data.navigation.itemPerPage | It is the field that shows how many items are on a page. |
data.noResultPageText | If a query does not return any results, this field is used for the empty result page. E.g. No Results |
data.sortings | It is the list where the details about sorting are kept. |
data.sortings.type | It is the field where the sorting type is located. Possible sorting types: Relevancy, PriceAsc, PriceDesc, MostPopularFirst, BestRatedFirst, MostRatedFirst, NewestFirst, MostFavoriteFirst, MostDiscountedFirst |
data.sortings.label | It is the label of sorting which is displayed to the end user. |
data.sortings.selected | It is a boolean field that indicates whether the relevant sorting is selected. |
data.appliedSearchStrategy | This field holds the encoded string of applied search strategies. |
data.brands | This field holds the list of recommended brands for the given user if there are any. *This field is only available when the response status is SuccessFallback. |
data.categories | This field holds the list of recommended categories for the given user if there are any. *This field is only available when the response status is SuccessFallback. |
data.defaultSortingType | It is the field where the sorting type of the recommended items is located. It is null when there is no active sorting found. |
redirection | Redirections can be set from the InOne panel. If the given query is matched with a redirection rule this field shows the details. |
redirection.redirectTo | This field holds the URL for the redirection rule. |
redirection.redirectionText | This field holds the redirection text for the redirection banner. |
error | When there is a business exception (501), this field is filled with code and message fields. |
validations | When the request is incorrect (400 Bad Request), this field is filled with an array of type and message fields. |
200 Search
{
"status": "Success",
"data": {
"items": [...],
"aggregations": [...],
"navigation": {...},
"noResultPageText": "...",
"sortings": [...]
},
"redirection": null,
"partnerResources": {...},
"error": null,
"validations": null,
"appliedSearchStrategy": "..."
}
200 Recommendation
{
"status": "SuccessFallback",
"data": {
"items": [...],
"brands": [...],
"categories": [...],
"noResultPageText": "...",
"defaultSortingType": null
},
"redirection": null,
"partnerResources": {...},
"error": null,
"validations": null,
"appliedSearchStrategy": "..."
}
400 Validation Exception
{
"status": "Invalid",
"data": null,
"redirection": null,
"partnerResources": null,
"error": null,
"validations": [
{
"type": "...",
"message": "..."
}
],
"appliedSearchStrategy": null
}
400 Business Exception
{
"status": "BusinessException",
"data": null,
"redirection": null,
"partnerResources": null,
"error": {
"code": "...",
"message": "..."
},
"validations": null,
"appliedSearchStrategy": null
}
500 Internal Server Error
{
"status": "Error",
"data": null,
"redirection": null,
"partnerResources": null,
"error": {
"code": "500 INTERNAL_SERVER_ERROR",
"message": "..."
},
"validations": null,
"appliedSearchStrategy": null
}
Fail Records Messages
- Business Exceptions
Message | Definition | HTTP Code |
---|---|---|
AggregationStyleNotFound | Aggregation style must be provided in the partner config. | 400 |
AggregationConfigNotFound | Aggregation configs must be provided in the partner config. | 400 |
SortingConfigNotFound | Sorting configs must be provided in the partner config | 400 |
SortingFieldNotFound | The sorting field must be provided in the partner config. | 400 |
UnsuccessfulSearchResult | The search results cannot be collected as expected. | 400 |
InvalidPriceAggregationStyle | The incorrect style for price aggregation is provided in the partner config. | 400 |
PartnerConfigNotFound | Partner config cannot be gathered from the cache. | 400 |
AggregationResultNotFound | Unexpected aggregation results were received according to aggregation configs. | 400 |
RecommendationApiBrandFieldNameNotFound | Name for the brand field which is used by Recommendation API cannot be found in the partner config. | 400 |
LocalizationLanguageSettingsNotFound | Localization language settings are not defined. | 400 |
QueryStrategyIsNotValid | The query strategy parameter passed is not valid, and must be taken from the initial response. | 400 |
- Validation Exceptions
Message | Definition | HTTP Code |
---|---|---|
PartnerIdNotFound | p parameter is not provided in the request. | 400 |
LocaleNotFound | l parameter is not provided in the request. | 400 |
LocaleInvalidFormat | The wrong locale format is provided in the request. | 400 |
CurrencyNotFound | c parameter is not provided in the request. | 400 |
CurrencyInvalidFormat | The wrong currency format is provided in the request. | 400 |
QueryNotFound | q parameter is not provided in the request. | 400 |
QueryInvalidFormat | The wrong query format is provided in the request. | 400 |
QueryInvalidLength | The query must contain the number of characters between 2 and 280. | 200 |
PaginationFromInvalidValue | The wrong pf value is provided in the request. | 400 |
PaginationSizeInvalidValue | The wrong ps value is provided in the request. | 400 |
PaginationMaxHitSizeExceeded | Pagination is greater than the allowed maximum size. | 400 |
AggregationNameNotFound | Aggregation name must be provided in the request. | 400 |
AggregationItemsNotFound | Aggregation items must be provided in the request. | 400 |
AppliedSearchStrategiesAreRepeated | Applies strategies must be unique. | 400 |