Published package: @surrealdb/spectron — a typed REST client for the Spectron end-user API. It uses platform fetch, ships no runtime dependencies, and aligns with Spectron’s OpenAPI specification.
npm: The client is published under the
@surrealdbscope (@surrealdb/spectron), so no third party can squat the namespace. The bare namespectronon npm is unrelated.
Installation
Node.js 18+ or a modern bundler for browser use.
Client construction
The client is async-only (all methods return Promises). It is pinned to one context and calls /api/v1/{context}/….
| Option | Default | Description |
|---|---|---|
context | required | Context id. |
endpoint | required | Spectron host URL. |
apiKey | required | Bearer token. |
timeout | 30000 | Milliseconds per request. |
maxRetries | 3 | Retries for GETs and idempotent writes. |
Scope
On the wire, scope is a ScopeSet: an ordered array of slash-path strings (for example ["org/acme/user/alice"]). Register paths before first use — see Contexts and scope.
The TypeScript client accepts a path string or an array of paths — both serialise to the wire ScopeSet.
Remember and recall
remember and rememberMany attach an Idempotency-Key header for safe retries within a 30-second window.
Documents and chat
Other verbs and namespaces
Top-level: forget, consolidate, reflect, elaborate, state, profile, inspect, audit, fsck, health.
Namespaces: client.documents (including keywords), client.sessions, client.entities, client.scopes, client.principals, client.traces, client.lifecycle.
→ Full tables: JavaScript SDK reference