Skip to content

REST API Reference

REST API Reference

Complete API documentation for HeliosDB Nano


Base URL

http://localhost:6543/api/v1

Authentication

All API requests require a Bearer token:

Terminal window
curl -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
http://localhost:6543/api/v1/...

See Authentication Guide for token management.


API Endpoints Overview

Core Database

EndpointMethodDescription
/queryPOSTExecute SQL queries
/branchesGETList database branches
/branchesPOSTCreate new branch
/branches/:nameDELETEDelete branch
/branches/:name/mergePOSTMerge branch

REST/CRUD (Supabase-Compatible)

EndpointMethodDescription
/rest/v1/:tableGETSelect rows
/rest/v1/:tablePOSTInsert rows
/rest/v1/:tablePATCHUpdate rows
/rest/v1/:tableDELETEDelete rows

AI/ML Features

EndpointMethodDescription
/vectors/searchPOSTVector similarity search
/vectors/upsertPOSTInsert/update vectors
/documents/chunkPOSTChunk documents
/documents/embedPOSTGenerate embeddings

Schema Management

EndpointMethodDescription
/schema/inferPOSTInfer schema from JSON
/schema/infer/batchPOSTBatch schema inference
/schema/validatePOSTValidate DDL
/schema/comparePOSTCompare schemas
/schema/optimizePOSTSuggest optimizations

Chat/Completions (OpenAI-Compatible)

EndpointMethodDescription
/chat/completionsPOSTChat completion
/embeddingsPOSTGenerate embeddings

Agent Memory

EndpointMethodDescription
/agents/sessionsGETList sessions
/agents/sessionsPOSTCreate session
/agents/sessions/:idGETGet session
/agents/sessions/:id/messagesPOSTAdd message
/agents/sessions/:id/summarizePOSTSummarize session

Query Endpoint

Execute SQL

Terminal window
POST /api/v1/query

Request:

{
"sql": "SELECT * FROM users WHERE age > 21 ORDER BY name",
"params": [],
"timeout_ms": 30000
}

Response:

{
"success": true,
"data": {
"columns": ["id", "name", "age", "email"],
"rows": [
[1, "Alice", 25, "alice@example.com"],
[2, "Bob", 30, "bob@example.com"]
],
"row_count": 2,
"execution_time_ms": 5
}
}

Parameterized Queries

Terminal window
POST /api/v1/query
{
"sql": "SELECT * FROM users WHERE email = $1",
"params": ["alice@example.com"]
}

Batch Queries

Terminal window
POST /api/v1/query/batch
{
"queries": [
{"sql": "SELECT COUNT(*) FROM users"},
{"sql": "SELECT COUNT(*) FROM orders"},
{"sql": "SELECT SUM(amount) FROM orders"}
]
}

REST/CRUD Endpoints

Select (GET)

Terminal window
# Basic select
GET /rest/v1/users?select=id,name,email
# With filters
GET /rest/v1/users?select=*&age=gt.21&name=ilike.*alice*
# With ordering
GET /rest/v1/users?select=*&order=created_at.desc
# With pagination
GET /rest/v1/users?select=*&limit=10&offset=20
# With embedding
GET /rest/v1/posts?select=*,author:users(name,email)

Filter Operators:

OperatorDescriptionExample
eqEqualstatus=eq.active
neqNot equalstatus=neq.deleted
gtGreater thanage=gt.21
gteGreater than or equalage=gte.21
ltLess thanprice=lt.100
lteLess than or equalprice=lte.100
likeLIKE patternname=like.*smith*
ilikeCase-insensitive LIKEname=ilike.*SMITH*
inIn liststatus=in.(active,pending)
isIS NULL/NOT NULLdeleted_at=is.null

Insert (POST)

Terminal window
POST /rest/v1/users
Content-Type: application/json
{
"name": "Alice",
"email": "alice@example.com",
"age": 25
}

Bulk Insert:

[
{"name": "Alice", "email": "alice@example.com"},
{"name": "Bob", "email": "bob@example.com"}
]

With RETURNING:

Terminal window
POST /rest/v1/users?select=id,created_at
Prefer: return=representation

Update (PATCH)

Terminal window
PATCH /rest/v1/users?id=eq.1
Content-Type: application/json
{
"name": "Alice Updated",
"updated_at": "2024-01-15T00:00:00Z"
}

Delete (DELETE)

Terminal window
DELETE /rest/v1/users?id=eq.1

Upsert

Terminal window
POST /rest/v1/users
Prefer: resolution=merge-duplicates
{
"id": 1,
"name": "Alice",
"email": "alice_new@example.com"
}

Terminal window
POST /api/v1/vectors/search
{
"table": "documents",
"column": "embedding",
"query_vector": [0.1, 0.2, 0.3, ...],
"limit": 10,
"metric": "cosine",
"filter": {
"category": "technology"
}
}

Response:

{
"success": true,
"data": {
"results": [
{
"id": "doc-123",
"content": "Introduction to machine learning...",
"distance": 0.123,
"metadata": {"category": "technology"}
}
]
}
}

Vector Upsert

Terminal window
POST /api/v1/vectors/upsert
{
"table": "documents",
"vectors": [
{
"id": "doc-001",
"embedding": [0.1, 0.2, 0.3, ...],
"metadata": {
"content": "Hello world",
"category": "greeting"
}
}
]
}

Schema Inference

See detailed Schema Generation Guide.

Quick Example

Terminal window
POST /api/v1/schema/infer
{
"samples": [
{"id": 1, "name": "Product A", "price": 29.99},
{"id": 2, "name": "Product B", "price": null}
],
"table_name": "products"
}

Response:

{
"success": true,
"data": {
"table_name": "products",
"columns": [
{"name": "id", "sql_type": "INTEGER", "nullable": false},
{"name": "name", "sql_type": "VARCHAR(18)", "nullable": false},
{"name": "price", "sql_type": "NUMERIC", "nullable": true}
],
"ddl": "CREATE TABLE products (\n id INTEGER NOT NULL,\n name VARCHAR(18) NOT NULL,\n price NUMERIC,\n PRIMARY KEY (id)\n);",
"confidence": 0.85
}
}

Database Branching

List Branches

Terminal window
GET /api/v1/branches

Response:

{
"success": true,
"data": {
"branches": [
{"name": "main", "created_at": "2024-01-01T00:00:00Z", "is_current": true},
{"name": "feature-x", "created_at": "2024-01-10T00:00:00Z", "parent": "main"}
]
}
}

Create Branch

Terminal window
POST /api/v1/branches
{
"name": "feature-testing",
"parent": "main"
}

Switch Branch

Terminal window
POST /api/v1/branches/feature-testing/use

Merge Branch

Terminal window
POST /api/v1/branches/feature-testing/merge
{
"target": "main",
"strategy": "three-way"
}

Agent Memory API

Create Session

Terminal window
POST /api/v1/agents/sessions
{
"agent_id": "assistant-v1",
"metadata": {
"user_id": "user-123",
"conversation_type": "support"
}
}

Add Message

Terminal window
POST /api/v1/agents/sessions/:session_id/messages
{
"role": "user",
"content": "How do I reset my password?",
"metadata": {"timestamp": "2024-01-15T10:00:00Z"}
}

Get Session with Messages

Terminal window
GET /api/v1/agents/sessions/:session_id?include=messages

Summarize Session

Terminal window
POST /api/v1/agents/sessions/:session_id/summarize
{
"target_tokens": 500
}

Error Handling

Error Response Format

{
"success": false,
"error": {
"code": "INVALID_QUERY",
"message": "Syntax error near 'SELEC'",
"details": {
"line": 1,
"column": 1
}
}
}

Common Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid token
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
INVALID_QUERY400SQL syntax error
RATE_LIMITED429Too many requests
INTERNAL_ERROR500Server error

Rate Limiting

PlanRequests/SecondBurst
Free1020
Starter100200
Pro1,0002,000
EnterpriseUnlimitedUnlimited

Rate Limit Headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1702640000

OpenAPI Specification

Full OpenAPI 3.0 spec available at:

GET /api/v1/openapi.json
GET /api/v1/openapi.yaml

Interactive documentation:

GET /api/v1/docs

Next Steps