Appearance
Historical queries
HistoricalService returns archived fills and candles for any pair within the deployment's retention window. It is public and runs on the public listener. Pulls from the deployment's historical archive when configured. The SDKs expose it on the public spot Client (a Maker has the same methods, served through its client) as historical_fillshistorical_fillshistoricalFills and historical_candleshistorical_candleshistoricalCandles, both returning a Pager.
What's available
| RPC | Returns | Cap |
|---|---|---|
GetFills | Fills within [start, end) for a pair. | 1,000 rows per call |
GetCandles | OHLCV candles at one of seven intervals. | 10,000 rows per call |
If the deployment doesn't have the historical archive enabled, every RPC returns FAILED_PRECONDITION. Read it once at boot to feature-gate the UI.
Range semantics
startandendcarry Unix microseconds inTimestamp.micros.startis inclusive.endis exclusive. Unset ormicros = 0means "now".GetFillsreturns rows newest-first, each row aFillEvent— the same wire shape as the live fill stream.GetCandlesreturns rows oldest-first.- Maximum window is 30 days per call. Larger spans need to be paginated.
- Historical
price,size, and OHLCV values areDecimalstrings — the same wire format as the live book and fill streams. Parse with a fixed-precision type (rust_decimaldecimal.Decimalbignumber.js).
Backfill recipe
To paginate a long span (e.g. a year of 1-minute candles), chunk by the row cap:
rust
use chrono::TimeDelta;
use flint_sdk::spot::{CandleInterval, HistoricalCandlesQuery, Pair};
let interval = TimeDelta::minutes(5);
let max_rows = 10_000;
let window = interval * max_rows;
let mut cursor = start;
let mut all = Vec::new();
while cursor < end {
let window_end = (cursor + window).min(end);
let mut query = HistoricalCandlesQuery::new(Pair::new("SOL", "USDC"), CandleInterval::M5);
query.start = Some(cursor);
query.end = Some(window_end);
all.extend(client.historical_candles(query).collect(None).await?);
cursor = window_end;
}ts
import { Client, type Candle } from "@superis-labs/flint/spot";
const client = Client.mainnet();
const intervalMs = 5 * 60 * 1000;
const maxRows = 10_000;
const windowMs = maxRows * intervalMs;
let start = startMs;
const all: Candle[] = [];
while (start < endMs) {
const end = Math.min(start + windowMs, endMs);
const candles = await client
.historicalCandles("SOL/USDC", "m5", { start: new Date(start), end: new Date(end) })
.collect();
all.push(...candles);
start = end;
}python
from datetime import datetime, timedelta, timezone
from flint import spot
client = spot.Client.mainnet()
end = datetime.now(timezone.utc)
start = end - timedelta(days=365)
interval = timedelta(minutes=5)
max_rows = 10_000
window = interval * max_rows
cursor = start
candles = []
while cursor < end:
window_end = min(cursor + window, end)
pager = client.historical_candles(
"SOL/USDC", spot.CandleInterval.M5, start=cursor, end=window_end
)
candles.extend(await pager.collect())
cursor = window_endStitching with live
For a chart that shows the last 24h:
GetCandleswithstart.micros = now_us - 86_400_000_000andend.micros = now_usto pull the historical body.- Subscribe to
MarketDataService.Subscribefor the pair to drive live updates fromnowforward, computing the last candle yourself from the fill stream — or justGetCandlesagain every interval for less aggressive UIs.
The historical and live paths align on the interval boundary.
When to prefer live
HistoricalService.GetFills over a recent window is more expensive than just streaming MarketDataService.SubscribeFills and ringing your own buffer. Use the historical path for backfill or for ranges older than your in-memory retention; use the live path for anything inside the active session.
