Skip to main content

Streaming API

Soltix supports real-time data streaming via Server-Sent Events (SSE). This allows clients to receive query results in chunks as they are processed.

Endpoints

MethodPath
GET/v1/databases/:db/collections/:col/query/stream
POST/v1/databases/:db/collections/:col/query/stream

Parameters

ParameterDefaultDescription
device_idComma-separated device IDs (required)
start_timeRFC3339 timestamp (required)
end_timeRFC3339 timestamp (required)
fieldsComma-separated field names
chunk_size1000Points per SSE chunk (range: 10–10,000)
chunk_intervalTime interval per chunk: 5m, 15m, 30m, 1h, 6h, 12h, 1d
intervalAggregation: 1m, 5m, 1h, 1d, 1mo, 1y
aggregationsumsum, avg, min, max, count
downsamplingnonenone, auto, lttb, minmax, avg, m4
downsampling_threshold0Target point count
anomaly_detectionnonenone, zscore, iqr, moving_avg, auto
anomaly_threshold3.0Anomaly sensitivity
anomaly_fieldField to detect anomalies on
legacyfalseUse legacy mode (load all then chunk)

chunk_size and chunk_interval are mutually exclusive.

Streaming Modes

gRPC Streaming (Default)

True streaming from storage nodes via gRPC — data flows as it's read from disk.

Legacy Mode (legacy=true)

Loads all data via gRPC first, then chunks at the HTTP layer. Useful for smaller datasets or when all data must be post-processed.

Time Range Limits

Streaming has relaxed limits compared to regular queries:

IntervalMax Range
Raw data30 days
1h90 days
1d1 year
1mo10 years

Usage

curl

curl -N "http://localhost:5555/v1/databases/mydb/collections/sensors/query/stream?\
device_id=sensor-001&\
start_time=2026-01-01T00:00:00Z&\
end_time=2026-01-02T00:00:00Z&\
chunk_size=500" \
-H "X-API-Key: your-api-key"

JavaScript (EventSource)

const url = new URL("http://localhost:5555/v1/databases/mydb/collections/sensors/query/stream");
url.searchParams.set("device_id", "sensor-001");
url.searchParams.set("start_time", "2026-01-01T00:00:00Z");
url.searchParams.set("end_time", "2026-01-02T00:00:00Z");

const eventSource = new EventSource(url, {
headers: { "X-API-Key": "your-api-key" }
});

eventSource.addEventListener("start", (e) => {
console.log("Stream started", JSON.parse(e.data));
});

eventSource.addEventListener("data", (e) => {
const chunk = JSON.parse(e.data);
console.log("Chunk received:", chunk);
});

eventSource.addEventListener("done", (e) => {
console.log("Stream complete", JSON.parse(e.data));
eventSource.close();
});

eventSource.addEventListener("error", (e) => {
console.error("Stream error", e);
eventSource.close();
});

SSE Event Types

EventDescription
startStream metadata (total chunks, query info)
dataData chunk with results
errorError information
doneStream complete with summary (total points, duration)

Use Cases

  • Real-time monitoring dashboards
  • Large data export with progress tracking
  • Live data visualization
  • IoT device monitoring