Top items
You can use our Top items endpoint to get the list of most popular items of any type in the same output manner as with Autocomplete.
Get top items
GET https://live.luigisbox.com/v1/top_items
Required parameters
type |
Comma separated list of required types and their quantity, e.g. items:6,category:3
|
tracker_id |
Identifier of your site within Luigi's Box. You can see this identifier in every URL in the Luigi's Box app once you are logged-in. |
Optional parameters
f_type[] optional
|
Filter, where type part of the parameter name is a name of a requested type. The value itself is using key:value syntax. E.g., use f_item[]=color:green to filter hits of type item which have an attribute color with a value green .You can use several filters in one request, e.g., f_item[]=color:green together with f_brand[]=promoted:true .Filtering on top of numerical and date attributes supports ranges, using pipe as a separator, e.g., f_item[]=price:5|7 . This range can be left open from either side, e.g., f_item[]=price:6| . If a combination of filters for the same field is provided, they are applied with OR . E.g., filters f_item[]=color:green&f_item[]=color:blue will retrieve products, that have either green OR blue color. |
hit_fields optional
|
A comma separated list of attributes and product parameters. Only these fields (in addition to some default ones) will be retrieved and present in results. If not provided, all fields will be present in results. The use of this feature is recommended. Try to specify only those field that are necessary for the frontent of the autocomplete window. This can help the retrieval of the results to be faster. |
ctx[] optional
|
drives model selection, using key:value syntax e.g., ctx[]=warehouse:berlin . you can provide multiple key:value pairs, that are combined into one context definition. order of key:value pairs in request is not important. however, please note that key:value pairs must match one of the contexts which are being reported into luigi's box search analytics. see the multi-warehouse solution and context in analytics for more details. |
Request Headers
Consider sending request header of Accept-Encoding
as well with values for supported encoding methods of your HTTP client, e.g. gzip
or br, gzip, deflate
for multiple supported methods. Encodings make the response from Top items endpoint considerably smaller and thus faster to transfer.
Example request
require 'faraday'
require 'faraday_middleware'
require 'json'
connection = Faraday.new(url: 'https://live.luigisbox.com') do |conn|
conn.use FaradayMiddleware::Gzip
end
response = connection.get("/v1/top_items")
if response.success?
puts JSON.pretty_generate(JSON.parse(response.body))
else
puts "Error, HTTP status #{response.status}"
puts response.body
end
#!/bin/bash
curl -i -XGET --compressed\
"https://live.luigisbox.com/v1/top_items"\
<?php
// Using Guzzle (http://guzzle.readthedocs.io/en/latest/overview.html#installation)
require 'GuzzleHttp/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('GET', "https://live.luigisbox.com/v1/top_items", [
'headers' => [
'Accept-Encoding' => 'gzip'
]
]);
echo $res->getStatusCode();
echo $res->getBody();
// This endpoint requires no authentication
// This endpoint requires no body
The above command returns JSON structured like this. The exact content of attributes field depends on the content of your product catalog.
{
"hits": [
{
"url": "http://www.e-shop.com/products/123456",
"attributes": {
"image_link": "http://www.e-shop.com/assets/imgs/products/123456.jpg",
"description": "Description field from your product catalog",
"categories": [
"Gadgets",
"Kids"
],
"title": "Product X",
"availability_rank_text": "true",
"price": "5.52 EUR",
"condition": "new"
},
"type": "item",
"exact": true
},
{
"url": "http://www.e-shop.com/products/456789",
"attributes": {
"image_link": "http://www.e-shop.com/assets/imgs/products/456789.jpg",
"description": "Description field from your product catalog",
"categories": [
"Gadgets",
"Kids"
],
"title": "Product Y",
"availability_rank_text": "preorder",
"price": "12.14 EUR",
"condition": "new"
},
"type": "item",
"exact": true
}
]
}
Personalized top items/last searched queries
Serves personalized top items for a given user.
In case of queries
type, it returns last searched queries by the given user.
GET https://live.luigisbox.com/v1/personalized_top_items
Required parameters
type |
Comma separated list of required types and their quantity, e.g. items:6,category:3
|
tracker_id |
Identifier of your site within Luigi's Box. You can see this identifier in every URL in the Luigi's Box app once you are logged-in. |
user_id |
Identifier of the user for whom you want to get personalized top items. See User identification for more details. |
Optional parameters
ctx[] optional
|
drives model selection, using key:value syntax e.g., ctx[]=warehouse:berlin . you can provide multiple key:value pairs, that are combined into one context definition. order of key:value pairs in request is not important. however, please note that key:value pairs must match one of the contexts which are being reported into luigi's box search analytics. see the multi-warehouse solution and context in analytics for more details. |