# Search Screen

## Search Suggestions API

The Search Suggestions API is a significant endpoint that provides search suggestions to users while they interact with the search bar in the e-commerce application. This API offers real-time suggestions based on user input, helping users find relevant products quickly and efficiently.

<figure><img src="https://3686328336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd1Iq7THDAagTQzeC9rTN%2Fuploads%2F4Z13yJqB6Ib0ZDDifwV8%2Fimage.png?alt=media&#x26;token=df8f2082-55cf-4f22-ba14-72a261228acf" alt=""><figcaption><p><strong>search suggestions</strong></p></figcaption></figure>

### Endpoint

* `{{baseurl}}/api/v1/product/search/suggestions`

### **Method**

* **GET**

### **Request Parameters:**

* tag (required): The user's search query or partial keyword to generate relevant search suggestions.
* `lang_code` (optional): A two-letter language code (e.g., "en" for English, "es" for Spanish, etc.) to support language-based localization. If provided, the API returns suggestions in the specified language.

### **Request Body:**

* None

### **Authorization**

The API requires a bearer token in the request header for authentication. Users need to include their valid bearer token in the "Authorization" header of the HTTP request to access the search suggestions.

### **Response Format**

The API responds with a JSON array containing search suggestions based on the user's input. The suggestions are typically represented as strings.

```json

{
    "success": true,
    "data": [
        {
            "id": 22,
            "name": "new"
        },
        {
            "id": 23,
            "name": "nike shoe"
        }
    ],
    "message": "Success",
    "status_code": 200

```

### Features:

* The API offers real-time search suggestions to users based on their search query.
* It provides relevant product names or keywords to help users find the desired products quickly.
* The `tag` parameter allows users to receive suggestions specific to certain product categories or tags, refining their search further.
* The `lang_code` parameter allows users to receive suggestions in their preferred language for a more personalized experience.
* The API requires a valid bearer token for authorization, ensuring secure access to search suggestions.

### Usage:

The Search Suggestions API is utilized while users interact with the search bar to offer real-time suggestions based on their input. As users type characters, the API fetches relevant search suggestions, reducing the time required to complete their search and improving user satisfaction.

### Best Practices:

* Optimize the API's response time to provide near-instantaneous search suggestions.
* Ensure that the search algorithm is robust and capable of handling various search queries effectively.
* Implement proper error handling to gracefully handle scenarios where no suggestions are available.
* Use the `tag` parameter effectively to provide more targeted and relevant suggestions based on product categories or tags.
