SDKs
Node.js SDK
Installation
npm install @databaset/sdkRequirements
- Node.js 18+
DATABASET_API_KEYenvironment variable
Initialize
import { Memory } from '@databaset/sdk'
const memory = new Memory()
// or: new Memory({ apiKey: 'db_...', appId: 'my-app' })memory.store()
await memory.store({
userId: string, // required
text: string, // required
appId?: string, // optional slug; falls back to key-bound app
metadata?: object,
})
// Returns: { id, userId, appId, createdAt }memory.recall()
const context = await memory.recall({
userId: string,
query: string,
appId?: string,
limit?: number, // default: 5, max: 100
minScore?: number, // default: 0.7
})
// Returns: string contextmemory.recallRaw()
const memories = await memory.recallRaw({
userId: string,
query: string,
limit?: number,
})
// Returns: [{ id, text, score, createdAt }]memory.forget()
// Delete one memory by short id or UUID
await memory.forget('mem_abc12345')
// Delete all memories for a user
await memory.forgetUser({ userId: 'user_123', appId: 'my-app' })memory.forgetBulk()
await memory.forgetBulk(['mem_abc12345', 'mem_def67890'])memory.list()
const { memories, total, page, pageSize } = await memory.list({
userId: string, // required
appId?: string,
page?: number, // default: 0
pageSize?: number, // default: 20
})Error handling
import { DatabasetError, ValidationError } from '@databaset/sdk'
try {
await memory.store({ userId, text })
} catch (err) {
if (err instanceof ValidationError) {
console.error('Invalid input:', err.message)
} else if (err instanceof DatabasetError) {
console.error('API error:', err.message, err.status)
}
}TypeScript support
Full TypeScript support is included. No @types package needed.