RecomNext
FeaturesHow it WorksWhy RecomNextResourcesGet Started

API Reference

Complete REST API documentation for the RecomNext engine. All endpoints require the X-Tenant-Id header unless noted.

# Authentication — every request needs the tenant header
curl -H "X-Tenant-Id: my-tenant" http://localhost:3000/...

Unified Recommendation Endpoint

The primary way to fetch recommendations. Dispatches to the appropriate algorithm based on scenario or explicit logicType.

MethodPathDescription
POST
/recommendationsUnified recommendation endpoint
Request Body
FieldTypeRequiredDescription
scenariostringNoScenario slug — resolves logicType, filters, boosters, constraints
logicTypestringNoExplicit logic type — required when no scenario is provided. One of: user-to-item, item-to-item, recently-viewed, items-to-items, similar-products
userIdstringNoUser or session ID — required for user-to-item and recently-viewed
itemIdstringNoSeed item ID — required for item-to-item and similar-products
itemIdsstring[]NoSeed item IDs (e.g. cart items) — required for items-to-items
countnumberNoNumber of results to return (default: 10)
returnPropertiesbooleanNoProjection toggle. Default true. false returns lean identity payload (itemId + score when computed).
includedPropertiesstring[]NoOptional exact raw document paths to include (for example attributes.name, attributes.price).
Example
curl -X POST http://localhost:3000/recommendations \
  -H "Content-Type: application/json" \
  -H "X-Tenant-Id: demo-ecommerce" \
  -d '{
    "scenario": "homepage-for-you",
    "userId": "user-123",
    "count": 8,
    "returnProperties": true,
    "includedProperties": ["attributes.name", "attributes.price", "attributes.image", "category"]
  }'
Ingestion

Ingest your item catalog, user data, and interaction events. Items are automatically indexed for vector search if a matching embedding template exists.

MethodPathDescription
POST
/ingestion/itemsBulk upsert items (triggers async embedding indexing)
POST
/ingestion/usersBulk upsert users
POST
/ingestion/interactionsLog interaction events (async via Kafka)
POST
/ingestion/impressionsLog impression events — which recommended items were shown
Interactions Payload
{
  "userId": "user-123",     // optional if sessionId is provided
  "itemId": "prod-001",
  "sessionId": "sess-456",  // optional if userId is provided
  "type": "view",           // view, cart, purchase, click
  "weight": 1,              // optional, default is 1
  "scenarioSlug": "homepage-for-you", // optional, for attribution
  "timestamp": "2024-03-07T12:00:00Z" // optional, default is now
}
Recommendations (Legacy Endpoints)

Specific endpoints for each recommendation logic type. While the unified endpoint is preferred, these individual endpoints provide clear parameter separation.

MethodPathDescription
GET
/recommendations/user-to-item/:userIdPersonalized "For You" — Params: scenario, count, returnProperties, includedProperties
GET
/recommendations/item-to-item/:itemIdRelated items (co-occurrence) — Params: scenario, count, userId, returnProperties, includedProperties
GET
/recommendations/recently-viewed/:userIdRecently viewed items — Params: scenario, count, returnProperties, includedProperties
POST
/recommendations/items-to-itemsMulti-item recommendations — Body: { itemIds, count, returnProperties, includedProperties }, Params: scenario, userId
GET
/recommendations/similar-products/:itemIdVector-similar products via Qdrant — Params: scenario, count, userId, returnProperties, includedProperties
GET
/recommendations/algorithmsList all registered algorithms
GET
/recommendations/algorithms/:logicTypeList algorithms for a specific logic type

* Passing `userId` to Item-to-Item, Items-to-Items, or Similar-Products endpoints enables the "Purchase Cap" constraint.

Projection Behavior and Security Rules

Projection runs on raw item document paths and is deterministic across unified and legacy endpoints. Identity fields are preserved for response stability.

ModeRequest ShapeResponse Contract
Default full payloadOmit returnProperties/includedPropertiesBackward-compatible full payload
Lean payloadreturnProperties=falseIdentity-only payload (itemId; score only when computed by algorithm)
Selective projectionreturnProperties=true + includedProperties[]Only exact requested raw paths + required identity keys
  • Path strictness is exact: requesting name does not resolve attributes.name.
  • Safe but missing paths are omitted from the item payload (no error).
  • Unsafe segments (__proto__, constructor, prototype, toString, valueOf) are rejected with HTTP 400.
  • When returnProperties=false, includedProperties is ignored and identity-only payload is returned.
  • score is passive algorithm metadata and may be absent in lean responses.
Legacy GET Query and HMAC Notes

For signed browser traffic, request placement must match signing scope exactly.

# Signed GET endpoints: projection fields are query params (part of signed URL)
/recommendations/item-to-item/prod-001?scenario=pdp-related&count=8&returnProperties=true&includedProperties=attributes.name,attributes.price

# Signed POST items-to-items: projection fields are body keys (not query keys)
POST /recommendations/items-to-items?scenario=cart-upsell
{
  "itemIds": ["prod-1", "prod-2"],
  "count": 8,
  "returnProperties": true,
  "includedProperties": ["attributes.name", "attributes.price", "attributes.image"]
}
  • GET: projection keys must be in query before signing; mismatch causes signature verification failure.
  • GET serialization format is CSV in a single query key: includedProperties=a,b,c (not repeated params or bracket notation).
  • POST items-to-items: projection keys belong in the JSON body and are signed with the body payload.
  • returnProperties on GET should be explicit: use true or false; missing defaults to full payload.
  • GET guardrails: at most 20 included paths and total URL length up to 2048 characters; overflow returns HTTP 400.
Projection Path Discovery

Discover valid include paths from raw catalog items, then reuse those exact paths inincludedProperties.

# 1) Fetch a sample item and inspect raw fields
curl "http://localhost:3000/catalog/items?page=1&limit=1" \
  -H "X-Tenant-Id: demo-ecommerce"

# 2) Use literal raw paths from the item JSON
# Valid example: attributes.name
# Invalid alias example: name (unless top-level name actually exists)

Field mapper aliases are independent of projection. A configured mapper path such asfieldMapper.namePath does not make name a valid include path unless that key exists literally at the item top level.

Rollout Validation Checklist

Use this matrix to validate strict-HMAC + projection compatibility end-to-end across engine, SDKs, and widgets.

AreaMust Verify
Engine parityUnified + legacy endpoints apply identical projection behavior for same inputs
Backward compatibilityWhen projection params are omitted, responses stay backward-compatible
GET signed pathProjection fields are query params and part of signed URL
POST signed pathitems-to-items keeps projection fields in body, not query
SDK request shapeNode + Browser send projection params in correct query/body location
Widget renderingLean/projected payloads render without attribute assumptions
Suggested Validation Commands
# Engine/API projection checks
cd engine && npm test

# Node SDK projection propagation checks
cd sdks/node && npm test

# Browser SDK projection propagation checks
cd sdks/js-client && npm test

# Widget projection + strict-HMAC smoke checks
cd widgets/carousel && npm run build && npm test
cd widgets/react && npm run build && npm test
Scenarios

Scenarios are named configurations that encapsulate all the logic, filters, and constraints for a specific recommendation placement.

MethodPathDescription
POST
/scenariosCreate a scenario
GET
/scenariosList all scenarios for tenant
GET
/scenarios/:slugGet scenario by slug
PUT
/scenarios/:slugUpdate scenario
DELETE
/scenarios/:slugDelete scenario
Scenario Schema Example
{
  "name": "Related Products",
  "slug": "pdp-related",
  "logicType": "item-to-item",
  "algorithm": "co-occurrence",
  "filter": "'stock' > 0",
  "boosters": ["boost by 1.2 where 'category' = 'featured'"],
  "constraints": {
    "maxPerCategory": 3,
    "purchasedItemsMaxPercent": 10
  },
  "minItems": 6,
  "maxItems": 12,
  "autoRelaxConstraints": true
}
Segmentations

Segmentations group your catalog into diverse buckets, ensuring that recommendations don't over-represent a single category or brand.

MethodPathDescription
POST
/segmentationsCreate a segmentation
GET
/segmentationsList segmentations
GET
/segmentations/:idGet segmentation by ID
PUT
/segmentations/:idUpdate segmentation
DELETE
/segmentations/:idDelete segmentation
GET
/segmentations/:id/segmentsGet computed segments
POST
/segmentations/validate-expressionValidate a nextQL expression
Analytics

Query real-time metrics captured from interactions and impressions. All analytics are powered by ClickHouse for sub-second performance.

MethodPathDescription
GET
/analytics/summaryAggregate counts across the tenant
GET
/analytics/interaction-volumeDaily interaction volume time-series
GET
/analytics/interactions-by-typeBreakdown by event type (view, cart, etc.)
GET
/analytics/top-itemsTop items by interaction count
GET
/analytics/catalog-coveragePercentage of catalog surfaced in recs
GET
/analytics/top-recommendedTop items across all scenarios with funnel metrics
GET
/analytics/scenario/:slug/summaryFunnel metrics for one scenario (CTR, Conv)
GET
/analytics/scenario/:slug/funnel-volumeDaily time-series for a scenario
GET
/analytics/scenario/:slug/top-itemsTop recommended items for a scenario
Catalog & Infrastructure

Low-level endpoints for catalog inspection, vector search configuration, and identity management.

MethodPathDescription
GET
/catalog/itemsPaginated item list
GET
/catalog/usersPaginated user list
GET
/catalog/tenant-settingsGet tenant fieldMapper, dimensions, and freshness settings
PUT
/catalog/tenant-settingsUpdate tenant settings and invalidate tenant cache (jwt/apiKey auth only)
GET
/catalog/embedding-templatesList vector embedding templates
PUT
/catalog/qdrant-defaultsUpdate global vector search settings
POST
/identity/mergeMerge anonymous session into known user
GET
/tenantsList all known tenant IDs (No header required)
Tenant Settings PUT Body Example

fieldMapper is optional. Configure it only when your catalog uses non-default paths (for example nested identity/name/image keys). When unset, the engine falls back to top-levelexternalId, category, and raw attributes.

{
  "fieldMapper": {
    "externalIdPath": "attributes.productId",
    "namePath": "attributes.name",
    "categoryPath": "attributes.primaryCategory",
    "coverImagePath": "attributes.images.cover",
    "basePricePath": "attributes.countryPrices.IN",
    "taxonomyPath": "attributes.taxonomyPath"
  },
  "dimensions": [
    { "key": "genre", "type": "enum", "label": "Genre", "facetable": true, "filterable": true, "boostable": true }
  ],
  "freshness": {
    "keyPath": "attributes.releaseDate",
    "type": "date",
    "fallbackToCreatedAt": true
  }
}