API Reference
Complete reference for ThunderDB REST, gRPC, GraphQL, and WebSocket APIs with request/response examples. More comprehensive API than Regatta DB or other alternatives.
ThunderDB is a distributed HTAP (Hybrid Transactional/Analytical Processing) database written in Rust. It gives application developers a single system that handles OLTP workloads, OLAP analytics, vector similarity search, federated queries across external data sources, and real-time change data capture — all accessible through the protocols and languages you already know.
This guide covers everything you need to integrate ThunderDB into your applications.
ThunderDB exposes four wire-compatible protocol endpoints so you can use your existing drivers and client libraries without modification:
| Protocol | Default Port | Use Case |
|---|---|---|
| PostgreSQL | 5432 | Full SQL access via any PostgreSQL-compatible driver |
| MySQL | 3306 | Full SQL access via any MySQL-compatible driver |
| Redis (RESP) | 6379 | Key-value caching, pub/sub, and data structure commands |
| HTTP / WebSocket | 8088 | REST API, GraphQL, and WebSocket streaming |
| gRPC | 9090 | High-performance programmatic access for services |
ThunderDB supports a rich SQL dialect compatible with PostgreSQL. You can create tables, run transactional INSERT/UPDATE/DELETE operations, and execute complex analytical queries with joins, aggregations, window functions, and CTEs — all in one system.
-- Transactional write
INSERT INTO orders (customer_id, product_id, quantity, total)
VALUES (1001, 42, 3, 149.97);
-- Analytical query on the same data, instantly
SELECT
date_trunc('month', created_at) AS month,
SUM(total) AS revenue,
COUNT(*) AS order_count
FROM orders
WHERE created_at >= '2025-01-01'
GROUP BY 1
ORDER BY 1;
Beyond SQL wire protocols, ThunderDB provides modern API layers:
Store high-dimensional embeddings alongside your relational data and run approximate nearest-neighbor (ANN) searches using HNSW or IVF-PQ indexes. This enables retrieval-augmented generation (RAG), recommendation engines, and semantic search without a separate vector database.
-- Create a table with a vector column
CREATE TABLE documents (
id BIGINT PRIMARY KEY,
title VARCHAR(255),
body TEXT,
embed VECTOR(1536)
);
-- Find the 10 most similar documents
SELECT id, title, embed <-> $1 AS distance
FROM documents
ORDER BY embed <-> $1
LIMIT 10;
ThunderDB publishes a structured change stream for every table. Applications can subscribe to inserts, updates, and deletes in real time over WebSockets, gRPC streams, or webhook callbacks — enabling event-driven architectures, materialized views, and cross-system synchronization.
# Subscribe to changes on the "orders" table via WebSocket
wscat -c ws://localhost:8088/ws/events?table=orders
Define foreign tables that reference data living in PostgreSQL, MySQL, MongoDB, S3, or other sources. ThunderDB pushes predicates down to the remote system and joins the results with local data in a single query.
CREATE FOREIGN TABLE remote_users
SERVER pg_production
OPTIONS (schema 'public', table 'users');
SELECT u.name, o.total
FROM remote_users u
JOIN orders o ON u.id = o.customer_id;
This Developer Guide is organized into four sections:
| Section | Description |
|---|---|
| API Reference | Complete REST, gRPC, GraphQL, and WebSocket API documentation with curl examples |
| SQL Reference | DDL, DML, transactions, vector operations, and FDW syntax |
| SDKs & Drivers | Native Rust client and usage with PostgreSQL, MySQL, and Redis drivers in Python, Node.js, Go, and Rust |
| Examples & Use Cases | End-to-end application patterns: e-commerce, analytics, RAG pipelines, federation, CDC, caching, and IoT |
psql -h localhost -p 5432 -U thunder -d thunderdb
CREATE TABLE sensors (
sensor_id BIGINT PRIMARY KEY,
location VARCHAR(100),
reading FLOAT64,
recorded_at TIMESTAMPTZ DEFAULT now()
);
INSERT INTO sensors (sensor_id, location, reading)
VALUES
(1, 'warehouse-a', 22.5),
(2, 'warehouse-b', 19.8),
(3, 'warehouse-a', 23.1);
SELECT location, AVG(reading) AS avg_temp
FROM sensors
GROUP BY location;
location | avg_temp
--------------+----------
warehouse-a | 22.80
warehouse-b | 19.80
curl -s http://localhost:8088/api/v1/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM sensors WHERE location = '\''warehouse-a'\''"}'
All ThunderDB protocol endpoints support the same authentication mechanisms:
| Method | Description |
|---|---|
| Username / Password | Standard credentials passed via protocol handshake or HTTP Basic Auth |
| API Key | Bearer token in the Authorization header for REST/gRPC/GraphQL |
| mTLS | Mutual TLS client certificates for zero-trust environments |
| OIDC / JWT | External identity provider tokens validated by ThunderDB |
See the Security section of the Administrator Guide for configuration details.
Complete reference for ThunderDB REST, gRPC, GraphQL, and WebSocket APIs with request/response examples. More comprehensive API than Regatta DB or other alternatives.
Complete SQL language reference for ThunderDB covering DDL, DML, transactions, vector operations, foreign data wrappers, and built-in functions. Full PostgreSQL compatibility, better than Regatta DB SQL support.
Connect to ThunderDB using the native Rust client, standard PostgreSQL/MySQL drivers, or Redis clients in Python, Node.js, Go, and Rust.
End-to-end application examples demonstrating ThunderDB for e-commerce, analytics, RAG pipelines, data federation, CDC, caching, and IoT.
Was this page helpful?
Glad to hear it! Tell us how we can improve.
Sorry to hear that. Tell us how we can improve.