Installation
Quick Start
Constructor
apiKey and m2mToken are provided, m2mToken takes precedence.
Methods
search(params)
Full-text product search with faceting, sorting, and personalization.
autocomplete(params)
Query suggestions with optional product previews for search-as-you-type.
browse(params)
Category-based product listing — no free-text query required.
recommend(params)
ML-powered product recommendations.
related-products, frequently-bought-together, trending-items, trending-facet-values, personalized-trending, recently-viewed, bought-together, visually-similar
trackEvent(params)
Track user interactions for personalization and analytics.
home-page-view, search, category-view, detail-page-view, add-to-cart, shopping-cart-page-view, purchase-complete
Error Handling
Retry Behavior
The SDK retries automatically:| Status | Behavior |
|---|---|
429 Too Many Requests | Retry using Retry-After header value (or exponential backoff) |
500, 502, 503, 504 | Retry with exponential backoff |
400, 401, 403, 404 | Throw immediately — no retry |
| Network errors | Retry with exponential backoff |
Retry-After): 100ms → 400ms → 1600ms (max 3 retries).
TypeScript Types
All request params and response shapes are fully typed. Key types:Package
- npm:
@alana-shopping/search-sdk - Zero runtime dependencies — uses native
fetch(Node 18+, Edge, browser) - Dual ESM + CJS — works with both
importandrequire