Get top items
Retrieve most popular items of any type.
https://live.luigisbox.com/v1/top_items
Request Parameters
Required parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tracker_id |
string | ✓ | Your site identifier. |
type |
string | ✓ | Object types and counts (e.g., item:10). |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
f_type[] |
string | Filter results. |
hit_fields |
string | Fields to retrieve. |
ctx[] |
string | Context parameters. |
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 the JSON API considerably smaller and thus faster to transfer.
Example Request
curl "https://live.luigisbox.com/v1/top_items?tracker_id=YOUR_TRACKER_ID&type=item:10" \
-H "Accept-Encoding: gzip, deflate"
How to make a request
The following examples demonstrate how to send a request to the Top Items API V1.
To make a valid request:
- Endpoint: Use
https://live.luigisbox.com/v1/top_items. - Parameters: Provide your
tracker_idand thetypeof items to retrieve (e.g.,item:10).
For a complete guide on implementation strategies, see Quickstart: Implementing Top Items Suggestions.
Example Code
# --- Ruby Example for GET /v1/top_items ---
# Assumes 'faraday' gem is installed
require 'faraday'
require 'json'
LUIGISBOX_HOST = 'https://live.luigisbox.com'
ENDPOINT_PATH = '/v1/top_items'
TRACKER_ID = 'your_tracker_id'
connection = Faraday.new(url: LUIGISBOX_HOST)
response = connection.get(ENDPOINT_PATH) do |req|
req.params['tracker_id'] = TRACKER_ID
req.params['type'] = 'item:10'
end
puts response.body if response.success?
<?php
// PHP Example for GET /v1/top_items
// Assumes Guzzle is installed
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$LUIGISBOX_HOST = 'https://live.luigisbox.com';
$ENDPOINT_PATH = '/v1/top_items';
$TRACKER_ID = 'your_tracker_id';
$client = new GuzzleHttp\Client();
$response = $client->request('GET', "{$LUIGISBOX_HOST}{$ENDPOINT_PATH}", [
'query' => ['tracker_id' => $TRACKER_ID, 'type' => 'item:10']
]);
if($response->getStatusCode() == 200) {
echo $response->getBody();
}
const axios = require('axios');
// V1 Top Items Request
const LUIGISBOX_HOST = 'https://live.luigisbox.com';
const ENDPOINT_PATH = '/v1/top_items';
const TRACKER_ID = 'your_tracker_id';
axios.get(LUIGISBOX_HOST + ENDPOINT_PATH, {
params: { tracker_id: TRACKER_ID, type: 'item:10' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
Response Structure
Response Attributes
| Field | Type | Description |
|---|---|---|
hits |
array | List of result objects. |
Example Response
{
"hits": [
{
"url": "http://www.e-shop.com/products/123456",
"attributes": {
"title": "Product X",
"price": "5.52 EUR"
},
"type": "item",
"exact": true
}
]
}
Get Personalized Top Items
Serves specific recommendations based on user history.
https://live.luigisbox.com/v1/personalized_top_items
Request Parameters (Personalized)
Required parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tracker_id |
string | ✓ | Your site identifier. |
user_id |
string | ✓ | User ID to personalize for. |
type |
string | ✓ | Object types and counts. |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
ctx[] |
string | Context parameters. |
Example Request
curl "https://live.luigisbox.com/v1/personalized_top_items?tracker_id=YOUR_TRACKER_ID&user_id=UID&type=item:10" \
-H "Accept-Encoding: gzip, deflate"
How to make a personalized request
Include the user_id parameter to get personalized results.
Example Code
# --- Ruby Example for GET /v1/personalized_top_items ---
# Assumes 'faraday' gem is installed
require 'faraday'
require 'json'
LUIGISBOX_HOST = 'https://live.luigisbox.com'
ENDPOINT_PATH = '/v1/personalized_top_items'
TRACKER_ID = 'your_tracker_id'
connection = Faraday.new(url: LUIGISBOX_HOST)
response = connection.get(ENDPOINT_PATH) do |req|
req.params['tracker_id'] = TRACKER_ID
req.params['user_id'] = 'UID'
req.params['type'] = 'item:10'
end
puts response.body if response.success?
<?php
// PHP Example for GET /v1/personalized_top_items
// Assumes Guzzle is installed
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$LUIGISBOX_HOST = 'https://live.luigisbox.com';
$ENDPOINT_PATH = '/v1/personalized_top_items';
$TRACKER_ID = 'your_tracker_id';
$client = new GuzzleHttp\Client();
$response = $client->request('GET', "{$LUIGISBOX_HOST}{$ENDPOINT_PATH}", [
'query' => ['tracker_id' => $TRACKER_ID, 'user_id' => 'UID', 'type' => 'item:10']
]);
if($response->getStatusCode() == 200) {
echo $response->getBody();
}
const axios = require('axios');
// V1 Personalized Top Items Request
const LUIGISBOX_HOST = 'https://live.luigisbox.com';
const ENDPOINT_PATH = '/v1/personalized_top_items';
const TRACKER_ID = 'your_tracker_id';
axios.get(LUIGISBOX_HOST + ENDPOINT_PATH, {
params: { tracker_id: TRACKER_ID, user_id: 'UID', type: 'item:10' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
Error Handling
The API uses standard HTTP status codes to indicate success or failure.
| HTTP Status | Description |
|---|---|
| 200 OK | The request was successful and results are returned. |
| 400 Bad Request | The request was malformed (e.g., missing tracker_id). |
| 504 Gateway Timeout | The request took too long to process. Retrying might succeed. |
Example Error
{
"type": "malformed_input",
"reason": "incorrect parameters provided"
}