SDK Overview
On this page
- Supported Languages
- Installation
- Rust
- Python
- TypeScript
- Go
- Quick Start
- Rust
- Python
- TypeScript
- Core Concepts
- Client
- TenantId
- StreamId
- Position
- Common Operations
- Append Events
- Read Events
- Subscribe to Events
- Connection Management
- Connection Pooling
- Reconnection
- Timeouts
- Error Handling
- Rust
- Python
- TypeScript
- Authentication
- API Key
- TLS Client Certificates
- Configuration
- Rust
- Python
- TypeScript
- Performance
- Throughput
- Batching
- Compression
- Language-Specific Features
- Rust
- Python
- TypeScript
- Testing
- Rust
- Python
- Migration
- From PostgreSQL
- Related Documentation
Client libraries for connecting to Kimberlite from various languages.
Supported Languages
| Language | Package | Documentation |
|---|---|---|
| Rust | kimberlite | API Docs |
| Python | kimberlite | API Docs |
| TypeScript | @kimberlite/client | API Docs |
| Go | github.com/kimberlitedb/kimberlite-go | API Docs |
Installation
Rust
[dependencies]
kimberlite = "1.0"
Python
TypeScript
# or
Go
Quick Start
Rust
use ;
async
Python
# Connect
=
# Append event
=
# Read events
=
TypeScript
import { Client, TenantId, StreamId } from '@kimberlite/client';
// Connect
const client = await Client.connect('localhost:3000');
// Append event
const position = await client.append(
new TenantId(1),
new StreamId(1, 100),
Buffer.from('event data')
);
// Read events
const events = await client.readStream(
new TenantId(1),
new StreamId(1, 100)
);
Core Concepts
Client
The main entry point for all SDK operations:
// Create client
let client = connect.await?;
// With authentication
let client = connect_with_auth.await?;
// With TLS
let client = connect_with_tls.await?;
TenantId
Identifies a tenant in multi-tenant deployments:
let tenant = new;
StreamId
Identifies a stream within a tenant:
let stream = new;
Position
Log position for reading/seeking:
let position = new;
let events = client.read_from_position.await?;
Common Operations
Append Events
// Single event
let position = client.append.await?;
// Batch append (more efficient)
let positions = client.append_batch.await?;
Read Events
// Read entire stream
let events = client.read_stream.await?;
// Read from position
let events = client.read_from_position.await?;
// Read with limit
let events = client.read_stream_with_limit.await?;
Subscribe to Events
// Subscribe to new events
let mut subscription = client.subscribe.await?;
while let Some = subscription.next.await
Connection Management
Connection Pooling
// Create client pool
let pool = builder
.max_connections
.connect
.await?;
// Get client from pool
let client = pool.get.await?;
client.append.await?;
Reconnection
All SDKs automatically reconnect on connection loss:
let client = builder
.reconnect_policy
.connect
.await?;
Timeouts
let client = builder
.timeout
.connect
.await?;
Error Handling
Rust
use ;
match client.append.await
Python
=
TypeScript
import { Client, KimberliteError, UnauthorizedError } from '@kimberlite/client';
try {
const position = await client.append(tenant, stream, data);
} catch (e) {
if (e instanceof UnauthorizedError) {
console.log('Authentication failed');
} else if (e instanceof KimberliteError) {
console.log(`Error: ${e.message}`);
}
}
Authentication
API Key
let client = connect_with_auth.await?;
TLS Client Certificates
use ;
let tls_config = builder
.client_cert
.ca_cert
.build?;
let client = connect_with_tls.await?;
See Security Guide for authentication setup.
Configuration
Rust
let client = builder
.timeout
.max_retries
.compression
.keepalive
.connect
.await?;
Python
=
TypeScript
const client = await Client.connect('localhost:3000', {
timeout: 30000,
maxRetries: 3,
compression: true,
keepalive: 60000
});
Performance
Throughput
| Operation | Throughput | Notes |
|---|---|---|
| Append (single) | 50k/sec | Per connection |
| Append (batch) | 500k/sec | Batches of 1000 |
| Read | 100k events/sec | Sequential read |
| Subscribe | 100k events/sec | Real-time stream |
Batching
Batch operations for higher throughput:
// ❌ Slow: Individual appends
for event in events
// ✅ Fast: Batch append
client.append_batch.await?;
Compression
Enable compression for large payloads:
let client = builder
.compression
.connect
.await?;
Compression savings:
- JSON data: ~70% reduction
- Binary data: ~50% reduction
- Already compressed: <5% reduction
Language-Specific Features
Rust
- Zero-copy: Direct access to event data without copying
- Async/await: Full async support with Tokio
- Type safety: Strong typing for tenant/stream IDs
Python
- Async support:
asynciointegration - Type hints: Full type annotation
- Context managers: Automatic connection cleanup
TypeScript
- Promise-based: Modern async/await API
- TypeScript: Full type definitions
- Streams: Node.js stream integration
Testing
All SDKs provide test helpers:
Rust
use MockClient;
async
Python
=
=
assert ==
See Testing Guide for application testing.
Migration
From PostgreSQL
Replace database client with Kimberlite client:
// Before: PostgreSQL
let pool = connect.await?;
let row = query!
.fetch_one
.await?;
// After: Kimberlite (SQL)
let client = connect.await?;
let row = client.query.await?;
See Migration Guide.
Related Documentation
- Python API - Python-specific API reference
- TypeScript API - TypeScript-specific API reference
- Rust API - Rust-specific API reference
- Go API - Go-specific API reference
- Coding Guides - Application development guides
Key Takeaway: Kimberlite SDKs provide idiomatic APIs for each language. All SDKs support append, read, and subscribe operations with automatic reconnection and connection pooling.