Overview
The V1 Autocomplete endpoint is the legacy API for search-as-you-type functionality. While still supported, we recommend using V2 for new integrations to access the latest features and performance improvements.
https://live.luigisbox.com/autocomplete
Request Parameters
Required parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tracker_id |
string | ✓ | Your unique site identifier. |
q |
string | ✓ | The search query. |
type |
string | ✓ | Requested object types and counts. |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
user_id |
string | User identifier for personalization. |
f_type[] |
string | Filters. |
sort_type |
string | Sorts results. Example: sort_item=price:asc. |
prefer[] |
string | Boosts specific items. |
hit_fields |
string | Fields to return. |
context |
string | Arbitrary context string for analytics. |
ctx[] |
string | Context parameters for model selection. |
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/autocomplete?tracker_id=YOUR_TRACKER_ID&q=text&type=item:6" </span>
-H "Accept-Encoding: gzip, deflate"
How to make a request
The following examples demonstrate how to send a request to the Autocomplete API using various languages.
To make a valid request:
- Endpoint: Use
https://live.luigisbox.com/autocomplete. - Parameters: Include your
tracker_id, the user's search queryq, and the desiredtypeof results (e.g.,item:6). - Encoding: URL-encode your query parameters.
- Headers: Use
Accept-Encoding: gzipfor better performance.
For a detailed step-by-step integration guide, see Quickstart: Getting query suggestions via the Autocomplete API.
Example Code
# --- Ruby Example for GET /autocomplete ---
# Assumes 'faraday' gem is installed (gem install faraday)
require 'faraday'
require 'json'
LUIGISBOX_HOST = 'https://live.luigisbox.com'
ENDPOINT_PATH = '/autocomplete'
TRACKER_ID = 'your_tracker_id'
connection = Faraday.new(url: LUIGISBOX_HOST) do |conn|
conn.use FaradayMiddleware::Gzip
end
response = connection.get(ENDPOINT_PATH) do |req|
req.params['tracker_id'] = TRACKER_ID
req.params['q'] = 'text'
req.params['type'] = 'item:6'
req.headers['Accept-Encoding'] = 'gzip, deflate'
end
if response.success?
puts "Autocomplete results: " +
"#{JSON.pretty_generate(JSON.parse(response.body))}"
else
puts "Error: HTTP Status " +
"#{response.status}, Response: #{response.body}"
end
<?php
// PHP Example for GET /autocomplete
// Assumes Guzzle is installed:
// composer require guzzlehttp/guzzle
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$LUIGISBOX_HOST = 'https://live.luigisbox.com';
$ENDPOINT_PATH = '/autocomplete';
$TRACKER_ID = 'your_tracker_id';
$client = new GuzzleHttp\Client();
$response = $client->request(
'GET',
"{$LUIGISBOX_HOST}{$ENDPOINT_PATH}",
[
'query' => [
'tracker_id' => $TRACKER_ID,
'q' => 'text',
'type' => 'item:6'
],
'headers' => [
'Accept-Encoding' => 'gzip, deflate'
]
]
);
if($response->getStatusCode() == 200) {
echo "Autocomplete results:" . PHP_EOL;
echo json_encode(json_decode($response->getBody()), JSON_PRETTY_PRINT);
} else {
echo "Error: HTTP Status " .
$response->getStatusCode() .
"\nResponse: " . $response->getBody();
}
const axios = require('axios');
// V1 Autocomplete Request
const LUIGISBOX_HOST = 'https://live.luigisbox.com';
const ENDPOINT_PATH = '/autocomplete';
const TRACKER_ID = 'your_tracker_id';
axios.get(LUIGISBOX_HOST + ENDPOINT_PATH, {
params: {
tracker_id: TRACKER_ID,
q: 'text',
type: 'item:6'
},
headers: {
'Accept-Encoding': 'gzip, deflate'
}
})
.then(response => {
console.log("Autocomplete results:",
JSON.stringify(response.data, null, 2));
})
.catch(error => {
if (error.response) {
console.error("Error: HTTP Status " + error.response.status +
", Response: " + JSON.stringify(error.response.data));
} else {
console.error("Exception:", error.message);
}
});
Response Structure
The response contains the list of suggestions.
Response Attributes
| Field | Type | Description |
|---|---|---|
exact_match_hits_count |
integer | Count of exact matches. |
partial_match_hits_count |
integer | Count of partial matches. |
hits |
array | The list of suggestion objects. |
suggested_url |
string | Redirect URL if a rule triggers one. |
Example Response
{
"exact_match_hits_count": 6,
"partial_match_hits_count": 0,
"partial_match_terms": [],
"hits": [
{
"url": "http://www.e-shop.com/products/123456",
"attributes": {
"image_link": "http://www.e-shop.com/assets/imgs/products/123456.jpg",
"title": "Product X",
"price": "5.52 EUR"
},
"type": "item",
"identity": "123456"
}
],
"suggested_url": "http://www.e-shop.com/redirect"
}
Error Handling
Standard HTTP status codes.
| HTTP Status | Description |
|---|---|
| 400 Bad Request | missing arguments or malformed request. |
Example Error
{
"type": "error",
"message": "Invalid request"
}