# Autocomplete

## Autocomplete API

The Autocomplete API returns suggestions for the autocompleter, as the user types the query in the search bar. It is suggested to wait at least 300ms between keystrokes before calling the API.&#x20;

<mark style="color:green;">`POST`</mark> `https://api.neuralens.ai/search/autocomplete`

Autocomplete API can return lists of query suggestions, and products that match the query. Use appropriate `limit` values as per use case.

### Request Headers

| Header                     | Value                       |
| -------------------------- | --------------------------- |
| X-Neuralens-API-Key        | Bearer YOUR\_API\_KEY\_HERE |
| X-Neuralens-Application-ID | YOUR\_APPLICATION\_ID       |

### Request Params

<table><thead><tr><th width="138">Param</th><th>Value</th></tr></thead><tbody><tr><td>partition</td><td>Partition field's value (required in case partitioning is done)</td></tr></tbody></table>

Let's say `partition` is enabled on field "continent", then when sending request for the continent "asia", partition will be `asia`

### Request Body

```json
{
    "query": "appl",
    "limit": {
        "text": 10,
        "products": 10
    },
    "fields": ["id","title","images","productUrl"],
    "analytics": {
        "userId": "87023"
    }
}
```

`query` The text typed by the user

`limit` *text* limit and *products* limits are the number of text results and product results required in response. One of these is required.

`fields` Fields required in response

`analytics` For personalization and performance tuning

### Response

```json
{
    "qid": "4fcb0b58-e040-4aa0-96cf-859692f77f53",
    "results": {
        "text": [
            {
                "title": "Apple",
                "images": ["https://cdn.example.com/123"],
            },
            ...
        ],
        "products": [
            {
                "id": "AD176",
                "type": "product",
                "title": "Apple - Fuji",
                "images": ["https://cdn.example.com/123", "https://cdn.example.com/789"],
                "productUrl": "https://example.com/product/AD176"
            },
            ...
        ]
    }
}
```
