polaris-data.
Install
Quickstart
Usereplay(...) when you want to stream historical rows in a script or backfill job. You can run this without an API key set.
Create a client
If you omitapiKey, the client reads POLARIS_API_KEY from the environment.
Core methods
UsePolarisClient for discovery, historical replay, and direct query workflows.
| Method | Returns | Use it for |
|---|---|---|
health() | JSON object | Confirm API availability |
catalog(source?, market?) | JSON object | Discover sources and exact market IDs |
listSnapshots(source, market, from, to, limit?) | List of snapshot entries | Find snapshot files for a range |
replay(params) | Async generator | Stream historical data for replay or backfills |
events(params) | List of normalized events | Load mixed event types into scripts |
trades(params) | List of normalized trades | Analyze executions |
raw(params) | List of raw payloads | Inspect venue-native messages |
ohlcv(params) | List of bars or TradingView-style JSON | Plot fast market charts |
from and to accept ISO 8601 strings, Date objects, or Unix epoch microseconds (number).
Discover a market before you query it
Usecatalog(...) to find the exact Polaris market ID for a venue.
Query events
Useevents(...) when you want standardized historical event rows beyond trades alone.
Query trades
trades(...) returns a list of normalized trade events. The SDK handles pagination and snapshot-backed historical reads for you.
Query OHLCV bars
Useohlcv(...) when you want interval bars instead of individual trades.
format: "tradingview", ohlcv(...) returns TradingView-style candle and volume arrays.
The OHLCV aggregation engine preserves precision by scaling volume by 1e12 during accumulation to avoid floating-point drift.
Local dataset storage
The SDK stores standardized snapshots and local day files under a shared Polaris app-data root so the TypeScript SDK and other Polaris tools can reuse the same files. Default roots:- macOS:
~/Library/Application Support/polaris - Linux:
$XDG_DATA_HOME/polarisor~/.local/share/polaris - Windows:
%APPDATA%\polaris
datasetRoot to the constructor to override the root explicitly.
Snapshot-first replay
For standardized historical data,replay(...), events(...), trades(...), and default or TradingView ohlcv(...) prefer /snapshots and /snapshots/download, then read local day files when they already exist.
.jsonl.zst snapshot files, downloads them once to the local dataset directory, and serves all subsequent queries from the local cache with no additional network round-trips.
If the requested standardized range cannot be satisfied from daily snapshots, the SDK falls back to the legacy /events?format=file flow for standardized replay, event, trade, and local OHLCV derivation.
Authentication
Public sources (e.g. Binance BTC-USDT) work without an API key. For premium sources, raw snapshots, or extended history, set your key via thePOLARIS_API_KEY environment variable or pass it directly:
Error handling
The SDK uses a custom error class hierarchy rooted atPolarisError.
| Error | HTTP status | Meaning |
|---|---|---|
UnauthorizedError | 401 | API key is missing or invalid |
NotFoundError | 404 | Requested source or market does not exist |
RateLimitedError | 429 | Too many requests — retry after resetAt |
StreamDecodeError | — | Failed to decode a streamed response |
DownloadNotAllowedError | — | Download is blocked by the server |