Eureka Search API
  • 02 May 2024
  • 10 Minutes to read

    Eureka Search API


      Article Summary

      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

      GET https://{domain_name}/api/web/search

      Your title goes here
      We suggest you to use the domain ineureka.api.useinsider.com due to security convenience.

      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.

      Your title goes here
      For requests with a total length, which is length of the entire URL, exceeding 2048 characters, a POST request must be sent to the base URL (https://{domain_name}/api/web/search). Although the specification of the HTTP protocol does not specify any maximum length, practical limits are imposed by web browsers and server software. In order to meet these limits and avoid problems, we put the length limitation as a precaution. GET requests may return faster responses, but we highly suggest you consider this when the payload length increases up to 2000+ characters.

      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

      ParameterDescriptionData TypeRequired
      qQuery String that will be searchedStringYes
      pThis is your partner ID. Navigate to InOne > InOne Settings > Account Preferences to copy your partner ID.StringYes
      lLocale is required to get partner products in the current language of the website. E.g. en_US, en_GBStringYes
      cThe 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,  AUDStringNo
      psNumber 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.IntegerNo
      pfThe searched products starting index from the given page number will be displayed. The default value is pf=0.IntegerNo
      aFilter the products with the following pattern: a={field}~{value}List of StringNo
      stSorting type of the searched products. It only takes one of the predefined sorting types. The default value is st=Relevancy.StringNo
      uUser 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.StringNo
      oiThe searched products will be displayed as only item ids.BooleanNo
      qsApplied strategies of the search query. It only takes an encoded string that is auto-generated by the first query in the response.StringNo
      Your title goes here
      The query q parameter should contain at least 2 characters and at most 280 characters. Otherwise, validation exception will be thrown.
      Your title goes here
      The qs parameter should not be included in the initial request made by the end user for a query. You can find it in the response body after the first result return. However, it needs to be added in subsequent requests when applying the facet filter for the same query. Otherwise, the request is accepted as a new query and the search results may differ.

      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.

      ParameterSorting Type
      stRelevancy
      stPriceAsc
      stPriceDesc
      stMostPopularFirst
      stBestRatedFirst
      stMostRatedFirst
      stNewestFirst
      stMostFavoriteFirst
      stMostDiscountedFirst

      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 StyleData Type
      PriceNumeric
      RatingNumeric
      RangeNumeric
      SliderNumeric
      CheckboxesString
      ListString
      ToggleBoolean

      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

      ParameterDefinition
      statusIt 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.
      dataIt is the object where items, sortings, aggregations, navigations, and noResultPageText are kept as a result of a given query.
      data.itemsThis field holds the list of properties for the returned items.
      data.items.itemIdIt 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_cardThis 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.itemVariantsThis 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.aggregationsThis field holds a list of different aggregations.
      data.aggregations.nameThis field holds the aggregation name.
      data.aggregations.labelThis field holds the aggregation label (which shows the name of the aggregation to the end user).
      data.aggregations.styleThis field holds the aggregation style. Possible values:
      Checkboxes, Toggle, Rating, Range, Slider, List, None
      data.aggregations.itemsThis field holds a list of item fields for the specified aggregation.
      data.aggregations.items.nameThis field holds the aggregation item name.
      data.aggregations.items.labelThis field holds the aggregation item label.
      data.aggregations.items.minThis field holds the minimum value of the aggregation item.
      data.aggregations.items.maxThis field holds the maximum value of the aggregation item.
      data.aggregations.items.selectedIt is a boolean field that indicates whether the aggregation item is selected.
      data.aggregations.items.documentCountThis field holds the total number of documents of the aggregation item.
      data.aggregations.suffixUnitThis 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.prefixUnitThis field holds the prefix unit for the facet values as a string.
      data.aggregations.sequenceThis field holds the sequence of the aggregation for showing the aggregations to the end-user in the correct order.
      data.aggregations.itemOrderTypeThis field holds the item order type of the aggregation. Possible values: KeyAsc, KeyDesc, CountDesc, CountAsc, None
      data.navigationThis dictionary shows information such as pagination and total item count.
      data.navigation.totalPagesThis field shows how many pages are returned for a given query.
      data.navigation.currentPageThis field specifies which page the returned result is.
      data.navigation.totalItemsThis field shows how many items are returned for a given query.
      data.navigation.itemPerPageIt is the field that shows how many items are on a page.
      data.noResultPageTextIf a query does not return any results, this field is used for the empty result page. E.g. No Results
      data.sortingsIt is the list where the details about sorting are kept.
      data.sortings.typeIt is the field where the sorting type is located. Possible sorting types: Relevancy, PriceAsc, PriceDesc, MostPopularFirst, BestRatedFirst, MostRatedFirst,
      NewestFirst, MostFavoriteFirst, MostDiscountedFirst
      data.sortings.labelIt is the label of sorting which is displayed to the end user.
      data.sortings.selectedIt is a boolean field that indicates whether the relevant sorting is selected.
      data.appliedSearchStrategyThis field holds the encoded string of applied search strategies.
      data.brandsThis 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.categoriesThis 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.defaultSortingTypeIt is the field where the sorting type of the recommended items is located. It is null when there is no active sorting found.
      redirectionRedirections can be set from the InOne panel. If the given query is matched with a redirection rule this field shows the details.
      redirection.redirectToThis field holds the URL for the redirection rule.
      redirection.redirectionTextThis field holds the redirection text for the redirection banner.
      errorWhen there is a business exception (501), this field is filled with code and message fields.
      validationsWhen 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
      MessageDefinitionHTTP Code
      AggregationStyleNotFoundAggregation style must be provided in the partner config.400
      AggregationConfigNotFoundAggregation configs must be provided in the partner config.400
      SortingConfigNotFoundSorting configs must be provided in the partner config400
      SortingFieldNotFoundThe sorting field must be provided in the partner config.400
      UnsuccessfulSearchResultThe search results cannot be collected as expected.400
      InvalidPriceAggregationStyleThe incorrect style for price aggregation is provided in the partner config.400
      PartnerConfigNotFoundPartner config cannot be gathered from the cache.400
      AggregationResultNotFoundUnexpected aggregation results were received according to aggregation configs.400
      RecommendationApiBrandFieldNameNotFoundName for the brand field which is used by Recommendation API cannot be found in the partner config.400
      LocalizationLanguageSettingsNotFoundLocalization language settings are not defined.400
      QueryStrategyIsNotValidThe query strategy parameter passed is not valid, and must be taken from the initial response.400
      • Validation Exceptions
      MessageDefinitionHTTP Code
      PartnerIdNotFoundp parameter is not provided in the request.400
      LocaleNotFoundl parameter is not provided in the request.400
      LocaleInvalidFormatThe wrong locale format is provided in the request.400
      CurrencyNotFoundc parameter is not provided in the request.400
      CurrencyInvalidFormatThe wrong currency format is provided in the request.400
      QueryNotFoundq parameter is not provided in the request.400
      QueryInvalidFormatThe wrong query format is provided in the request. 400
      QueryInvalidLengthThe query must contain the number of characters between 2 and 280.200
      PaginationFromInvalidValueThe wrong pf value is provided in the request.400
      PaginationSizeInvalidValueThe wrong ps value is provided in the request.400
      PaginationMaxHitSizeExceededPagination is greater than the allowed maximum size.400
      AggregationNameNotFoundAggregation name must be provided in the request.400
      AggregationItemsNotFoundAggregation items must be provided in the request.400
      AppliedSearchStrategiesAreRepeatedApplies strategies must be unique.400

      Was this article helpful?

      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses