Public search

This endpoint acts basically the same as the /search/ endpoint. The only difference is that the public endpoint does not require HMAC with an API key.
That means, they are publicly available. Because of that, we limit the fields returned in the responses. To achieve this, customers can define a whitelist of fields that should be returned.

Executes a search request without HMAC or an API key. Suitable for use directly from storefronts. Response fields are limited to those whitelisted in the Makaira admin under Public Fields.

Request

POST /search/public

Headers

HeaderValue
Content-Typeapplication/json
X-Makaira-InstanceYour Makaira instance identifier

Request Body

FieldTypeRequiredDescription
isSearchbooleanYesSet to true for full-text search (e.g. autosuggest), false for listing pages (e.g. category or manufacturer pages).
searchPhrasestringYesThe search term. Use an empty string for listing-page requests.
enableAggregationsbooleanYesSet to true to include filter aggregations in the response.
aggregationsobjectYesActive filter selections. Pass an empty object or array when no filters are applied.
sortingobjectYesSorting configuration. Pass an empty object or array to use default relevance sort. Example: {"price": "asc"}.
countintegerYesNumber of items to return per page.
offsetintegerYesPagination offset (0-based).
constraintsobjectYesQuery constraints. See table below.
apiVersionstringNoAPI version string (e.g. 2018.6).
enableHookbooleanNoSet to false to bypass configured search query hooks. Defaults to true.

Constraints

ConstraintTypeRequiredDescription
query.shop_idstringYesFilters results to a specific shop. Only relevant in multi-shop setups.
query.languagestringYesLanguage identifier for the search index (e.g. de, en).
query.use_stockstringNoWhen set to "true", excludes out-of-stock products.
query.variant_countintegerNoMaximum number of variants to return per product. Must be an integer ≥ 1. Values exceeding the server-configured maximum are clamped to that maximum. Omitting this field returns up to the server-configured maximum. Invalid values (non-integer, zero, or negative) return a 400 Bad Request error.
query.variant_sortingobjectNoSort variants within each product group by a specific field. Example: {"price": "asc"}.
query.use_child_attribute_sortingbooleanNoWhen true, sorts product groups by the aggregated value of a specific variant attribute. Use together with query.attribute_id, query.attribute_type, query.attribute_sort_order, and query.attribute_aggregation_mode.
query.attribute_idstringNoThe ID of the attribute to sort by. Required when query.use_child_attribute_sorting is true.
query.attribute_typestringNoThe attribute type (e.g. attributeInt, attributeStr, attributeFloat). Required when query.use_child_attribute_sorting is true.
query.attribute_sort_orderstringNoSort direction: asc or desc. Defaults to desc. Used with query.use_child_attribute_sorting.
query.attribute_aggregation_modestringNoAggregation mode across variant values: max, min, avg, or sum. Defaults to max. Used with query.use_child_attribute_sorting.
oi.user.agentstringNoUser agent string. Required for personalization.
oi.user.ipstringNoUser IP address. Required for personalization.

Example Request

{
  "searchPhrase": "kite",
  "constraints": {
    "query.shop_id": 1,
    "query.language": "de",
    "query.use_stock": true
  },
  "enableAggregations": true,
  "isSearch": true,
  "aggregations": [],
  "sorting": [],
  "count": 50,
  "offset": 0,
  "apiVersion": "2018.6"
}

Example Request — Variant sorting by price

Returns products with their variants sorted by price ascending:

{
  "searchPhrase": "kite",
  "constraints": {
    "query.shop_id": 1,
    "query.language": "de",
    "query.variant_sorting": {
      "price": "asc"
    }
  },
  "enableAggregations": true,
  "isSearch": true,
  "aggregations": [],
  "sorting": [],
  "count": 50,
  "offset": 0
}

Example Request — Attribute-based product group sorting

Sorts product groups by the minimum price of their variants using attribute-based sorting:

{
  "searchPhrase": "jacket",
  "constraints": {
    "query.shop_id": 1,
    "query.language": "de",
    "query.use_child_attribute_sorting": true,
    "query.attribute_id": "attribute-price-id",
    "query.attribute_type": "attributeFloat",
    "query.attribute_sort_order": "asc",
    "query.attribute_aggregation_mode": "min"
  },
  "enableAggregations": true,
  "isSearch": true,
  "aggregations": [],
  "sorting": [],
  "count": 50,
  "offset": 0
}

Response

Returns a JSON object with result buckets for each document type. Only fields whitelisted in the Makaira admin under Public Fields are included.

Response Body

FieldTypeDescription
productobjectProduct search results. Contains items, count, total, and aggregations.
categoryobjectCategory results. Contains items, count, and total.
manufacturerobjectManufacturer results. Contains items, count, and total.
suggestionobjectAutosuggest results. Contains items, count, and total.

Each result bucket item has:

FieldTypeDescription
idstringDocument ID.
fieldsobjectDocument fields as allowed by the Public Fields whitelist.
Body Params
boolean
required

Set this to true when the request is an actual search request (e.g. autosuggest) and to false when you want to perform a request for products on a category or manufacturer page.

string
required

The term to search for.

boolean
required

Set this to true when you want aggregations to be included in the response, otherwhise false.

aggregations
object
required

List of selected values to filter for.

sorting
object
required
string
required

Number of products to be returned in the response.

string
required

The offset to start returning products from. In combination with the "count" property this is used for paginating the search results.

constraints
object
required
string
boolean

If set to false, the search query hook will be disabled. Default value is true(if not specify)

Headers
string
required

Makaira Instance ID

Response

Language
Credentials
Bearer
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json