# Search API

> Current Froomle documentation · [View canonical page](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html)

Getting search results and completions from the Froomle platform is done through the search API. The search results and completions in the API will only contain items which are stored in the specified environment. In addition to requesting search results and completions, the search API also supports fetching previously computed search results.

<a id="_specifications"></a>

## Specifications

<a id="_search_api_search_search"></a>

### POST /{environment}/searches/requests

<a id="_description"></a>

#### Description

Request search results scoped to a specific environment.

<a id="_parameters"></a>

#### Parameters

| Type | Name | Description | Schema |
| --- | --- | --- | --- |
| **Path** | **environment**<br>_required_ | The environment for which the request is made. | string |
| **Body** | **body**<br>_required_ | Search payload. | [SearchRequest](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_searchrequest) |

<a id="_responses"></a>

#### Responses

| HTTP Code | Description | Schema |
| --- | --- | --- |
| **200** | OK | [SearchResults](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_searchresults) |

<a id="_consumes"></a>

#### Consumes

-   `application/json`
    

<a id="_produces"></a>

#### Produces

-   `application/json`
    

* * *

<a id="_search_api_search_more_extended"></a>

### GET /{environment}/searches/lists

<a id="_description_2"></a>

#### Description

Query cached search results from a previously computed list.

<a id="_parameters_2"></a>

#### Parameters

| Type | Name | Description | Schema |
| --- | --- | --- | --- |
| **Path** | **environment**<br>_required_ | The environment for which the list request is made. | string |
| **Query** | **list\_key**<br>_required_ | Identifier of the cached list returned by an earlier search. | string |
| **Query** | **offset**<br>_required_ | Rank of the first item to include (1-based). | integer |
| **Query** | **limit**<br>_required_ | Number of items to return. | integer |

<a id="_responses_2"></a>

#### Responses

| HTTP Code | Description | Schema |
| --- | --- | --- |
| **200** | OK | [SearchResults](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_searchresults) |
| **404** | List key not found or expired. | No Content |

<a id="_produces_2"></a>

#### Produces

-   `application/json`
    

* * *

<a id="_search_api_search_complete"></a>

### GET /{environment}/searches/completions

<a id="_description_3"></a>

#### Description

Request completions for a partially entered query.

<a id="_parameters_3"></a>

#### Parameters

| Type | Name | Description | Schema |
| --- | --- | --- | --- |
| **Path** | **environment**<br>_required_ | The environment for which the request is made. | string |
| **Query** | **q**<br>_required_ | The query term to complete. | string |
| **Query** | **user\_id**<br>_optional_ | Identifier of the logged-in user. | string |
| **Query** | **device\_id**<br>_optional_ | Identifier for an anonymous user or device. | string |
| **Query** | **request\_id**<br>_optional_ | Client-supplied identifier for correlating requests. | string |
| **Query** | **page\_type**<br>_optional_ | Contextual page type for the query. | string |

<a id="_responses_3"></a>

#### Responses

| HTTP Code | Description | Schema |
| --- | --- | --- |
| **200** | OK | [Completion](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_completion) |

<a id="_produces_3"></a>

#### Produces

-   `application/json`
    

* * *

<a id="_search_api_search_advanced_complete_multi_env"></a>

### POST /{environment}/searches/completions

<a id="_description_4"></a>

#### Description

Request completions with the advanced payload that supports multi-environment setups.

<a id="_parameters_4"></a>

#### Parameters

| Type | Name | Description | Schema |
| --- | --- | --- | --- |
| **Path** | **environment**<br>_required_ | The environment for which the request is made. | string |
| **Body** | **body**<br>_required_ | Completion payload. | [CompletionRequest](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_completionrequest) |

<a id="_responses_4"></a>

#### Responses

| HTTP Code | Description | Schema |
| --- | --- | --- |
| **200** | OK | [Completion](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_completion) |

<a id="_consumes_2"></a>

#### Consumes

-   `application/json`
    

<a id="_produces_4"></a>

#### Produces

-   `application/json`
    

* * *

<a id="_definitions"></a>

## Definitions

<a id="_search_item"></a>

### Item

One content item returned by the Search API.

| Name | Description | Schema |
| --- | --- | --- |
| **information\_field**<br>_required_ | Optional metadata field configured per customer. | string |
| **item\_id**<br>_required_ | Identifier of the item in your catalog. | string |
| **type**<br>_required_ | Document type of the returned object. | string |

* * *

<a id="_searchrequest"></a>

### SearchRequest

Specification of a search request body.

| Name | Description | Schema |
| --- | --- | --- |
| **autocorrect**<br>_optional_ | Whether the query should be autocorrected (default: `true`). | boolean |
| **filter\_by**<br>_optional_ | Filters that limit which items can appear. | [Filter](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_filter) |
| **group\_by**<br>_optional_ | Fields used to split results into multiple lists (default: `[]`). | < string > array |
| **limit**<br>_optional_ | Number of items returned per list (default: `4`). | integer |
| **list\_size**<br>_optional_ | Number of items cached per list for later retrieval (default: `100`). | integer |
| **num\_lists**<br>_optional_ | Number of lists requested (default: `4`). | integer |
| **q**<br>_required_ | The search query typed by the user. | string |
| **page\_type**<br>_required_ | Page or surface for which the request is made. | string |
| **channel**<br>_optional_ | Channel identifier (e.g., web, iOS, Android). | string |
| **user\_id**<br>_optional_ | Logged-in user identifier. | string |
| **device\_id**<br>_required_ | Identifier for anonymous users or devices. | string |
| **histories**<br>_optional_ | Behavioral histories that improve personalization. | [Histories](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_histories) |

* * *

<a id="_searchresults"></a>

### SearchResults

Response returned by the search endpoints.

| Name | Description | Schema |
| --- | --- | --- |
| **auto\_suggest**<br>_optional_ | Alternative query if autocorrect was triggered. | string |
| **lists**<br>_required_ | Grouped search results. | < [List](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_list) > array |
| **num\_lists**<br>_required_ | Number of lists that were requested. | integer |
| **perfect\_match**<br>_optional_ | Exact match for the query, if available. | [Item](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_item) |
| **request\_id**<br>_required_ | Identifier of the request to log alongside events. | string |
| **user\_group**<br>_optional_ | Experiment group the user belongs to. | string |

* * *

<a id="_completionrequest"></a>

### CompletionRequest

Body accepted by the advanced completions endpoint.

| Name | Description | Schema |
| --- | --- | --- |
| **fuzziness**<br>_optional_ | Maximum edit distance when matching queries (default: `0`). | integer |
| **filter\_by**<br>_optional_ | Filters applied before generating completions. | [Filter](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_filter) |
| **q**<br>_optional_ | Partial query string. | string |
| **user\_id**<br>_optional_ | User identifier. | string |
| **device\_id**<br>_optional_ | Device identifier. | string |
| **histories**<br>_optional_ | Interaction histories used to personalize results. | [Histories](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_histories) |

* * *

<a id="_completion"></a>

### Completion

Payload returned by the completions endpoints.

| Name | Description | Schema |
| --- | --- | --- |
| **completions**<br>_required_ | List of suggested terms. | < [Item](https://docs.froomle.com/froomle-doc-main/v2/api_reference/search/index.html#_search_item) > array |
| **request\_id**<br>_required_ | Identifier of the completion request. | integer |
| **user\_group**<br>_optional_ | Experiment group the user belongs to. | string |
