memaxdocs
TypeScript SDK

TypeScript SDK

The memax-sdk client library for TypeScript. Build custom integrations and agents with full Memax API access.

The memax-sdk package is the canonical TypeScript client for the Memax API. Use it to build custom agents, integrations, and workflows.

Installation

npm install memax-sdk
pnpm add memax-sdk
yarn add memax-sdk
bun add memax-sdk

Quick start

import { MemaxClient } from "memax-sdk";

const memax = new MemaxClient({
  apiKey: process.env.MEMAX_API_KEY!,
});

// Recall relevant context
const results = await memax.recall("how does auth work?");
for (const result of results) {
  console.log(result.title, result.relevance);
}

// Push new knowledge
await memax.push({
  content: "We chose PostgreSQL for strong consistency guarantees",
  title: "Database Decision",
  category: "decisions",
  boundary: "team",
});

// Search with filters
const memories = await memax.search({
  category: "reference",
  tags: ["auth"],
  limit: 10,
});

Configuration

const memax = new MemaxClient({
  // Required
  apiKey: "mk_...",

  // Optional
  baseUrl: "https://api.memaxlabs.com",  // default
  hubId: "hub_abc123",                     // default hub for operations
  timeout: 30000,                          // request timeout in ms
});

Methods

recall(query, options?)

Semantic search for relevant memories.

const results = await memax.recall("deployment process", {
  limit: 5,
  hint: "preparing for a production deploy",
  projectContext: {
    repo: "github.com/org/app",
    branch: "main",
  },
});

push(options)

Store new knowledge.

await memax.push({
  content: "Meeting notes from sprint planning...",
  title: "Sprint 42 Planning",
  category: "daily",
  tags: ["sprint", "planning"],
  boundary: "team",
  hubReason: "team needs visibility into sprint decisions",
});

search(options?)

Browse memories with structured filters.

const memories = await memax.search({
  category: "decisions",
  tags: ["architecture"],
  sort: "newest",
  limit: 20,
});

get(id)

Retrieve a specific memory.

const memory = await memax.get("mem_a1b2c3d4");

delete(id)

Delete a memory.

await memax.delete("mem_a1b2c3d4");

topics(options?)

List knowledge topics.

const topics = await memax.topics({ hubId: "hub_abc123" });

The SDK handles authentication, retries, and error handling. All methods return typed responses matching the REST API.

Error handling

import { MemaxClient, MemaxError } from "memax-sdk";

try {
  await memax.recall("query");
} catch (error) {
  if (error instanceof MemaxError) {
    console.error(error.code, error.message);
    // e.g., "auth_error", "Invalid API key"
  }
}