Skip to Content
Overview

Rust SDK

kalam-client is the official KalamDB client for Rust. It wraps the shared link-common implementation with a Tokio-native API for services, CLIs, and background workers.

Status: Beta — the API may still change between releases.

ResourceLink
crates.iokalam-client 
API referencedocs.rs/kalam-client 
Sourcegithub.com/kalamdb/KalamDB 

Current version: 0.5.2-rc.2 · MSRV: Rust 1.92+

What you can do

kalam-client focuses on the core app and worker workflows:

  • Execute SQL over HTTP (execute_query, execute_with_files)
  • Upload and download FILE column attachments (FileRef, BoundFileRef, download_bound_file)
  • Open materialized live rows over WebSocket (live, live_with_config)
  • Consume low-level subscription frames (live_events, live_events_with_config)
  • Authenticate with JWT, basic login bootstrap, system-user auth, or dynamic providers (AuthProvider, login, refresh_access_token)
  • Observe connection lifecycle (EventHandlers)
  • Inspect active subscriptions (subscriptions)
  • Control the shared WebSocket explicitly (connect, disconnect, is_connected)
  • Poll and commit topic records when the consumer feature is enabled (client.consumer())

Optional feature-gated helpers:

  • health_check() with the healthcheck feature
  • check_setup_status() / server_setup() with the setup feature
  • cluster_health_check() with the cluster feature

Installation

BASH
cargo add kalam-clientcargo add tokio --features macros,rt-multi-thread
TOML
[dependencies]kalam-client = "0.5"tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Enable optional capabilities as needed:

TOML
# Topic workerskalam-client = { version = "0.5", features = ["native-sdk", "consumer"] } # Multipart SQL file uploadskalam-client = { version = "0.5", features = ["native-sdk", "file-uploads"] }
FeatureDescription
native-sdk (default)Tokio runtime, HTTP SQL, auth flows, live subscriptions
consumerTopicConsumer, ConsumerBuilder, poll/commit APIs
file-uploadsexecute_with_files multipart uploads and FILE downloads
healthcheckCached health_check() helper
setupcheck_setup_status() and server_setup()
clustercluster_health_check()
native-fullAll native features (CLI-oriented bundle)

Quick start

RUST
use std::time::Duration;use kalam_client::{AuthProvider, KalamLinkClient}; #[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> {    let client = KalamLinkClient::builder()        .base_url("http://localhost:2900")        .auth(AuthProvider::basic_auth("admin".into(), "kalamdb123".into()))        .timeout(Duration::from_secs(30))        .build()?;     let response = client        .execute_query("SELECT CURRENT_USER()", None, None, None)        .await?;     if response.success() {        println!("rows: {:?}", response.rows_as_maps());    }     client.disconnect().await;    Ok(())}

Runnable examples: Examples.

For live() and live_events(), keep SQL strict: SELECT ... FROM ... WHERE .... Do not put ORDER BY or LIMIT in live subscription SQL.

  1. Setup & Quick Start
  2. Authentication
  3. Auth-Aware Client
  4. Querying & DML
  5. FILE Columns & Uploads
  6. Realtime Subscriptions
  7. Client Lifecycle
  8. Types & Models
  9. Cell Values (KalamCellValue)
  10. Server Setup & Diagnostics Boundary
  11. Transport & Endpoints
  12. Examples

Examples

Runnable crates ship under link/sdks/rust/examples/:

ExampleDocs
Quickstart — first SQL queryQuickstart
File Attachments — FILE upload and downloadFile Attachments
Live Inbox — live() subscriptionsLive Inbox
Topic Consumer — poll and commit offsetsTopic Consumer

See Examples overview for run commands and prerequisites.

Why live() first

Most UIs want the latest reconciled row list, not raw insert/update/delete frames.

  • live() / live_with_config() — materialized rows (recommended default)
  • live_events() / live_events_with_config() — low-level protocol events

Use SubscriptionOptions::with_last_rows() to rewind recent history. Use LiveRowsConfig { limit: Some(n), .. } to cap the materialized set the client keeps.

Builder options

MethodDescription
base_url(...)Required KalamDB server URL
auth(...) / jwt_token(...) / auth_provider(...)Static or dynamic credentials
timeout(...)HTTP request timeout (default 30s)
max_retries(...)Retries for idempotent HTTP queries (default 3)
connection_options(...)WebSocket lazy connect, compression, keepalive
timeouts(...)Fine-grained receive/send timeouts
event_handlers(...)Connect/disconnect/error hooks
auth_refresher(...)Custom TOKEN_EXPIRED recovery callback

Notes

  • base_url(...) is required on every builder.
  • Basic auth is exchanged for JWT before protected SQL or WebSocket work.
  • HTTP queries work without connect(). Call connect() before live subscriptions.
  • Default ConnectionOptions uses ws_lazy_connect: true — the socket opens on the first subscription.
  • Close live streams and consumers with close() during shutdown.
Last updated on