Search
The Search API can be used to display predictive search results for queries.
All Ajax API requests should use locale-aware URLs to give visitors a consistent experience.
Search products by keyword
GET /{locale}/api/search
The following example requests the predictive products for a specific keyword:
GET /{locale}/api/search?keyword={query}&page={page}&limit={limit}
Example request
fetch(window.SHOPLAZZA.routes.root + '/api/search?keyword=hu&page=0&limit=4')
.then((response) => response.json())
.then((data) => {
// do something...
});
Request parameters
The search query.
The base-0 page number of results.
Limits the number of results.
Response
- Schema
- Example
data object
The response payload.
How long the result can be cached, in seconds.
Filters available for the results.
Whether more records are available.
Search keyword used for the query.
Maximum number of records returned per page.
Current page number.
List of products.
Sort options available for the results.
Total number of products matched.
Result message returned with the response.
Request result flag; success or 0 means the request succeeded.
{
"data": {
"cache_seconds": 86400,
"filters": [],
"has_more": 0,
"keyword": "hu",
"limit": 4,
"page": 1,
"products": [],
"scm": "search.v39.101.102.103.104",
"sort": [],
"sorts": [],
"ssp": "",
"total": 0
},
"msg": "请求成功",
"state": 0
}