AACsearch
Recommendations

Trending

Items rising in views, clicks or purchases over a recent window. The right fallback for anonymous visitors and empty-result pages.

GET /recommendations/trending returns items whose engagement is rising sharpest over the trailing window. Optionally filtered by category, brand, or any indexed facet.

Request

GET /recommendations/trending?indexId=<id>&window=7d&limit=10
Authorization: Bearer <api-key>
ParamTypeRequiredNotes
indexIdstringyesSource index.
windowstringno1h, 24h, 7d, 30d. Default 24h.
limitnumberno1–50, default 10.
filterBystringnoTypesense filter_by — e.g. category:Shoes.

Response

{
  "items": [
    { "id": "sku-9001", "score": 4.2, "data": { ... } }
  ],
  "window": "24h",
  "engine": "trending"
}

score is velocity — clicks-per-impression ratio over the window divided by the same ratio in the previous window. A score of 4.2 means this item is gaining attention 4.2× faster than its baseline.

When to use

  • Anonymous homepage — No userId, no anchor item.
  • Empty results fallbackPOST /search returned 0 hits; show trending in the same category. See the no-results recipe.
  • Editorial widget — "What's hot this week."

Window choice

WindowBest for
1hLive events, breaking news, flash-sale dashboards.
24hNews sites, dynamic ecommerce, default for most surfaces.
7dLong-tail stores, B2B catalogues — smooths out daily noise.
30dBestseller rails — closer to "popular" than to "trending".

Latency

p95 ~40 ms on Pro. The trending bucket is precomputed every 5 minutes per window; API is a hash lookup.

Code path

packages/api/modules/recommendations/procedures/trending.ts.

On this page