The SDK is a lightweight TypeScript client with built-in event batching, automatic retries, and structured logging for the NeuronSearchLab API.Need PHP instead? View the PHP SDK guide or install it from Packagist.
Installation
Initialize the client
The SDK uses a Bearer token for authentication. Obtain an access token by exchanging your SDK credentials and pass it when creating the client:Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | API base URL |
accessToken | string | required | Bearer token from /auth/token |
timeoutMs | number | 10000 | HTTP request timeout in ms |
maxRetries | number | 2 | Retry count on 429/5xx/timeouts |
collateWindowSeconds | number | 3 | Buffer events for this many seconds before flushing |
maxBatchSize | number | 200 | Flush immediately when buffer reaches this size |
maxBufferedEvents | number | 5000 | Drop oldest events beyond this limit |
propagateRecommendationRequestId | boolean | true | Auto-attach request_id from recommendations to subsequent events |
autoSessionId | boolean | true | Auto-generate a session UUID |
Get recommendations
entity_id, name, description, score, and any metadata you stored with the item. The response also includes a request_id for event attribution.
Auto-generated sections
UsegetAutoRecommendations for paginated, auto-titled recommendation sections — ideal for infinite-scroll feeds:
Track events
Events provide the feedback loop that powers personalization. The SDK buffers events in memory and flushes them in batches for efficiency.How batching works
- Events are buffered with a
client_tstimestamp. - The buffer flushes when the collate window elapses (default 3s) or the buffer reaches
maxBatchSize. - On page unload (
beforeunload,pagehide), remaining events are flushed automatically. - Failed sends are retried with exponential backoff.
Request ID propagation
WhenpropagateRecommendationRequestId is enabled (the default), the SDK captures the request_id from getRecommendations() and automatically attaches it to subsequent trackEvent() calls. This links events back to the recommendation request that produced them.
Manage catalog items
Upsert an item
description field is used to generate embeddings for similarity matching.
Update an item
Delete items
Error handling
The SDK exports two error classes:maxRetries times.
Logging
Configure structured logging for debugging and observability:TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL.
You can also provide a custom transport to send logs to your own logging infrastructure:
Session management
The SDK auto-generates a session UUID on initialization (whenautoSessionId is true). All events include the session ID automatically. You can override or read it:
Next steps
- View the PHP SDK guide if you are integrating from Laravel or another PHP service.
- View the API documentation for the underlying REST endpoints.
- Set up the MCP integration to use NeuronSearchLab from AI assistants like Claude.
- Reach out to contact@neuronsearchlab.com if you need help.

