Skip to main content
The Polaris Rust SDK is available on crates.io as polaris-data.

Install

If your project does not already use Tokio, add it as well:
The package name is polaris-data and the crate name is polaris_data. Or add it manually to Cargo.toml:
The SDK is async-first and is designed for Tokio-based services, backfills, and trading infrastructure.

Quickstart

Use events(...) when you want standardized historical rows in an async service or backfill job.

Create a client

If you omit api_key, the client reads POLARIS_API_KEY from the environment.
The main builder is:

Core methods

Use PolarisClient for discovery and snapshot-backed historical queries. from and to accept ISO 8601 strings, chrono::DateTime<Utc>, or Unix epoch microseconds as i64 or u64. If you omit one or both bounds, the SDK infers a bounded historical range from catalog metadata, using the latest 7 days by default and applying public cutoff rules for preview datasets when no API key is present.

Discover a market before you query it

Use catalog(...) to find the exact Polaris market ID for a venue.
If you want a high-level view of supported venues and example market IDs before you query the exact pair, start with Market Coverage.

Query events

Use events(...) when you want standardized historical event rows beyond trades alone.

Query trades

trades(...) returns normalized trade events. The SDK loads standardized snapshot data locally and filters trade rows for you.

Query OHLCV bars

Use ohlcv(...) when you want interval bars instead of individual trades.
Supported intervals are 100ms, 1s, 10s, 1m, 5m, 15m, and 1h.

Query order book snapshots

Use l2_snapshots(...) when you need order book depth data for microstructure analysis.

Query funding rates

Use funding_rates(...) to analyze perpetual funding rates and carry modeling.

Query mark prices

Use mark_prices(...) for basis analysis, mark tracking, and liquidation-related research.

Query volume profiles

Use volume(...) for volume profiling and participation analysis.

Query VWAP series

Use vwap(...) for execution benchmarking and price smoothing.

Query volatility series

Use volatility(...) for risk modeling and intraperiod volatility analysis.

Query best bid/offer

Use bbo(...) for spread tracking, quote analytics, and top-of-book monitoring.

Query depth metrics

Use depth_metrics(...) for liquidity analysis and market impact estimation.

Local dataset storage

The SDK stores standardized snapshots and local cache data under the shared Polaris app-data root so the Rust SDK and other Polaris tools can reuse the same files. Default roots:
  • macOS: ~/Library/Application Support/polaris
  • Linux: $XDG_DATA_HOME/polaris or ~/.local/share/polaris
  • Windows: %APPDATA%\\polaris
Within that root, the SDK uses this layout:
Use dataset_root(...) on the builder to override the root explicitly.
  • POLARIS_ROOT overrides the shared root globally.
  • POLARIS_DATASET_DOWNLOAD_DIR is still accepted as a deprecated compatibility override.

Snapshot-first replay

For standardized historical data, replay(...), events(...), trades(...), and ohlcv(...) use a snapshot-first flow:
  1. Discover snapshot files through /snapshots.
  2. Download missing .jsonl.zst files through /download.
  3. Cache them locally under the Polaris data root.
  4. Reuse local files on subsequent reads instead of making repeat network calls.
This SDK does not call direct /events, /trades, /ohlcv, or /raw endpoints.

Gap handling

By default, snapshot-backed methods fail if the requested range is not fully covered by available standardized snapshots. Set allow_gaps: true when you want the SDK to:
  • return only covered rows
  • skip missing intervals
  • emit a log::warn! entry describing the gaps

Authentication

Public sources work without an API key. For premium sources or extended history, set your key via POLARIS_API_KEY or configure it directly on the builder:
See Authentication for the shared auth model.

Next steps

  • Read Authentication if you want the shared auth model behind the SDK.
  • Read Snapshots if your Rust workflow starts from historical files.
  • Read Trades, Events, or OHLCV for detailed method documentation.