Navigation

Trending Queries API

Retrieve currently trending search queries using the Trending Queries API.

Overview

The Trending Queries API returns a list of search terms that are currently popular or trending among your users. This data is updated regularly and can be used to display a "Trending Searches" list to inspire users.

GET https://live.luigisbox.tech/v2/trending_queries

Request Parameters

Required parameters

Parameter Type Required Description
tracker_id string Your unique site identifier within Luigi's Box.

Optional parameters

Parameter Type Description
ctx[] string Context parameters for dynamic model selection. Format: key:value (e.g., warehouse:berlin).
Requirement: Keys/values must match contexts reported in 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 the JSON API considerably smaller and thus faster to transfer.

Example Request


curl "https://live.luigisbox.tech/v2/trending_queries?tracker_id=YOUR_TRACKER_ID" \
     -H "Accept-Encoding: gzip, deflate"

How to make a request

The following examples demonstrate how to send a request to the Trending Queries API.

To make a valid request:

  1. Endpoint: Use https://live.luigisbox.tech/v2/trending_queries.
  2. Parameters: Provide your tracker_id.
  3. Headers: Use Accept-Encoding: gzip for better performance.

For a detailed walkthrough, see Quickstart: Trending Queries Suggestions.

Example Code

# --- Ruby Example for GET /v2/trending_queries ---
# Assumes 'faraday' gem is installed (gem install faraday)

require 'faraday' require 'json'

LUIGISBOX_HOST = 'https://live.luigisbox.tech' ENDPOINT_PATH = '/v2/trending_queries' 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.headers['Accept-Encoding'] = 'gzip, deflate' end

if response.success? puts "Trending Queries: " + "#{JSON.pretty_generate(JSON.parse(response.body))}" else puts "Error: HTTP Status " + "#{response.status}, Response: #{response.body}" end

<?php
// PHP Example for GET /v2/trending_queries
// Assumes Guzzle is installed: 
// composer require guzzlehttp/guzzle

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$LUIGISBOX_HOST = 'https://live.luigisbox.tech'; $ENDPOINT_PATH = '/v2/trending_queries'; $TRACKER_ID = 'your_tracker_id';

$client = new GuzzleHttp\Client(); $response = $client->request( 'GET', "{$LUIGISBOX_HOST}{$ENDPOINT_PATH}", [ 'query' => [ 'tracker_id' => $TRACKER_ID ], 'headers' => [ 'Accept-Encoding' => 'gzip, deflate' ] ] );

if($response->getStatusCode() == 200) { echo "Trending Queries:" . 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');

// V2 Trending Queries Request const LUIGISBOX_HOST = 'https://live.luigisbox.tech'; const ENDPOINT_PATH = '/v2/trending_queries'; const TRACKER_ID = 'your_tracker_id';

axios.get(LUIGISBOX_HOST + ENDPOINT_PATH, { params: { tracker_id: TRACKER_ID }, headers: { 'Accept-Encoding': 'gzip, deflate' } }) .then(response => { console.log("Trending Queries:", 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 is a JSON array of objects, where each object represents a trending query.

Response Attributes

Field Type Description
[Root] array List of trending query objects.
title string The text of the trending query.
links array Optional. List of related links (e.g., top content).
links[].rel string The relationship type of the link (e.g., top_content).
links[].href string The absolute URL of the link.

Example Response

[
  {
    "title": "get 10% off"
  },
  {
    "title": "guitar"
  },
  {
    "title": "testing"
  },
  {
    "title": "bass guitar"
  },
  {
    "title": "kalimba"
  },
  {
    "title": "digital piano"
  },
  {
    "title": "piano"
  },
  {
    "title": "black friday"
  }
]

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"
}