SDK reference

Every method on PulseClient, and the config it takes.

pnpm add @thepulseapi/sdk

Session

MethodReturns
init(config)TrackResponse | nullStart a session and send the automatic signals once
getSession()SessionResponseCurrent session and inferred personas
getSessionId()stringThe current session id
resetSession()voidClear it and start fresh
onPersona(cb)voidSubscribe to persona updates

Signals and ranking

MethodReturns
track(signals)TrackResponseSend shopper signals
search(products, options?)SearchResponseRank products you pass in
rankedCatalog(options?)RankedCatalogResponseRank the catalogue already synced to PULSE
event(type, data?)EventResponseRecord a named event

search and rankedCatalog are not interchangeable. search ranks what you hand it; rankedCatalog ranks what PULSE already holds.

Exposure

Method
exposure(decisionId, items)voidRecord what was actually rendered, buffered
flushExposures()Promise<void>Send buffered exposures now

Config

apiKeyRequired

string

Publishable key, pk_live_...

organizationIdRequired

string

From the dashboard

endpointOptional

string

Override only for local development

Defaults to https://api.thepulseapi.com

autoTrackOptional

boolean

Capture device, referrer and time on init()

Defaults to true

sessionTtlMsOptional

number

Inactivity before a new session

Defaults to 1800000

anonymousIdOptional

string

Identity label only. Never reaches inference.

debugOptional

boolean

Verbose logging

Defaults to false

On this page