Skip to Content
🚀 KalamDB v0.3.0-alpha2 is out — Learn more
SDK & ClientOverview

TypeScript SDK (kalam-link)

kalam-link is the official TypeScript/JavaScript client for KalamDB. It wraps the Rust/WASM client and exposes a typed API for:

  • SQL over HTTP
  • live subscriptions over WebSocket
  • topic consume/ack flows
  • FILE column upload/download helpers

Runtime targets: modern browsers and Node.js >= 18.

Architecture in practice

The SDK is layered:

  1. WASM core (KalamClient) handles most network operations and protocol behavior.
  2. TypeScript wrapper (KalamDBClient) provides ergonomic APIs, type-safe helpers, and subscription bookkeeping.
  3. Utility modules (auth.ts, types.ts, file_ref.ts, query_helpers.ts) provide safer composable building blocks.

Minimal example

import { createClient, Auth, MessageType, ChangeType } from 'kalam-link'; const client = createClient({ url: 'http://localhost:8080', auth: Auth.basic('root', ''), }); await client.connect(); const result = await client.query('SELECT 1 AS ok'); console.log(result.results[0]); const unsubscribe = await client.subscribe('app.messages', (event) => { if (event.type === MessageType.Change && event.change_type === ChangeType.Insert) { console.log('New rows:', event.rows); } }); await unsubscribe(); await client.disconnect();

Read this section by section

Source-backed notes

  • client.query() uses WASM methods query / queryWithParams depending on params.
  • queryWithFiles() uses direct fetch/XMLHttpRequest multipart upload to /v1/api/sql.
  • login() and refreshToken() update the client auth mode to JWT internally.
  • subscribe(table, cb) is sugar for subscribeWithSql('SELECT * FROM <table>', cb).
Last updated on