Get search suggestions
GET/search/v1/:project-id/suggestions
Call this endpoint to retrieve search suggestions as the user types. You can find more information about types of search suggestions in this guide.
Please make sure to attach the session-id query parameter.
Additionally, make sure to forward the client IP address via an HTTP header called HTTP_CLIENT_IP - this makes it possible to set a limit for queries per IP per hour to prevent abuse.
Request
Responses
- 200
- 404
OK
{
"searchResults": [
{
"type": "products",
"name": "Products",
"totalResults": 1,
"totalResultsVariants": 5,
"totalResultsHead": 1,
"totalResultsHeadVariants": 5,
"results": [
[
{
"identifier": "PRD-9876-RED44",
"groupId": "9876",
"sxId": 240538696,
"dataPoints": [],
"image": "www.myshop.com/product/9876-red44/img.jpg",
"name": "Laptop 9876 Red",
"images": [
{
"type": "ALTERNATIVE",
"url": "www.myshop.com/product/9876-red44/img.jpg"
}
],
"link": "www.myshop.com/product/9876-red44",
"resultSet": null,
"head": true,
"relevance": 1000000
}
]
]
},
{
"type": "queries",
"name": "Suggestions",
"totalResults": 3,
"results": [
{
"name": "laptops"
},
{
"name": "laptops acer"
},
{
"name": "laptops dell"
}
]
},
{
"type": "categories",
"name": "Categories",
"totalResults": 1,
"results": [
{
"link": "myshop.com/c/laptops",
"name": "Laptops"
}
]
},
],
"totalResults": 1,
"interpretedQuery": {
"matchSources": []
},
"showAllResults": true
}
Not found
{
"status": "failure",
"code": 404,
"message": "Sorry an error occurred. Please check the logs."
}