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
Get recommendations
id, object, item_id, rank, score, and an embedded item object with the metadata you stored. The response also includes a request_id for event attribution.
Search
Usesearch when the user supplies a free-text query and you want ranked catalog items back through the Core API data plane:
https://api.neuronsearchlab.com/v1/search, not the console Platform API. Search responses use the same item shape as recommendations and include query, request_id, data, and recommendations.
Search-to-click loop
For search-backed surfaces, treat search and events as one attribution loop:- Run
searchwith the user’s query and optional context. - Render results from
dataorrecommendations. - Capture
request_idfrom the search response. - Send that
requestIdback with the click, view, or purchase event.
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
1
Buffer events
Events are buffered with a timestamp that maps to
occurred_at in the API.2
Flush on window or batch size
The buffer flushes when the collate window elapses (default 3s) or the buffer reaches
maxBatchSize.3
Flush during page unload
On page unload (
beforeunload, pagehide), remaining events are flushed automatically.4
Retry failed sends
Failed sends are retried with exponential backoff.
Request ID propagation
WhenpropagateRecommendationRequestId is enabled (the default), the SDK captures the request_id from getRecommendations() or search() and automatically attaches it to subsequent trackEvent() calls. This links events back to the result set that produced them.
Manage catalog items
Create an item
description field is used to generate embeddings for similarity matching. NSL generates item.id; persist that integer alongside your source record.
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.

