polaris-data.
Install
uv, install it into a project with:
Quickstart
Usereplay(...) when you want to stream historical rows in a notebook, script, or backfill job. You can run this without an API key set, and from_ and to are optional. If you omit them, the SDK uses the most recent available window up to the last 7 days of data, or the public cutoff date for preview datasets.
Create a client
If you omitapi_key, the client reads POLARIS_API_KEY from the environment.
Core methods
UsePolarisClient for discovery, historical replay, and direct query workflows.
Historical row methods return single-pass generators. Iterate directly for bounded memory, or wrap a call in
list(...) when you need indexing or repeated access. Close a partially consumed generator with rows.close(). BBO also accepts interval="100ms", "1s", "10s", "1m", "5m", "15m", or "1h" to emit the last quote from each non-empty UTC-aligned bucket.
Arrow batches and DataFrames
trades, funding_rates, mark_prices, bbo, and depth_metrics accept
three output modes. The default "iterator" preserves the existing row
dictionaries. "batches" yields bounded pyarrow.RecordBatch objects, while
"dataframe" eagerly returns one Pandas DataFrame.
extra.<name>. Because
those keys are dynamic, trade and point queries scan the resolved local files
once to infer a stable schema and reopen the same files for batch emission.
Trade batches and DataFrames include stable nullable maker and taker string
columns. BBO and depth metrics have fixed schemas and remain single-pass.
from_ and to accept ISO 8601 strings, datetime, date, or Unix epoch milliseconds. They are optional on replay(...), events(...), trades(...), option_tickers(...), perpetual_tickers(...), raw(...), and ohlcv(...). If you omit either boundary, the SDK fills the request from the most recent available window up to the last 7 days of data, or the public cutoff date for preview datasets.
For historical event queries, standard=True is the default on replay(...). Pass standard=False when you explicitly want raw schema payloads through replay.
For exact execution replay, request output="batches" and
materialize_orderbooks=False. These batches retain every standardized event
in stored capture order and include stable replay, file, and row ordinals.
Nullable legacy timestamp and v2 collector/exchange columns use millisecond
Arrow timestamps. Typed columns include nullable order_id, side, and
is_snapshot. With raw order-book updates,
event_json preserves the complete source event and unknown payloads; with
materialization enabled it contains the resulting complete-book event. Raw
standard=False replay remains iterator-only.
Iterator dictionaries preserve their stored envelope. Check
"collector_timestamp" in event to identify v2; use that value for SDK time
and treat exchange_timestamp as nullable venue provenance. See
Event envelope.
Orderbooks are reconstructed by default across stream, replay, events, and
l2_snapshots. orderbook replaces the complete state, orderbook_delta
updates listed prices, and quantity zero deletes a price. State is cleared after
gaps and reconnects; deltas are skipped until another snapshot arrives. Use
l2_updates(...) for raw snapshots and deltas, then feed selected updates into
the exported OrderbookBuilder for application-managed flows.
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. Omit from_ and to to query the recent default window, or pass them explicitly when you need a fixed range.
Query trades
trades(...) returns an iterator of normalized trade events. The SDK handles snapshot-backed historical reads for you. from_ and to are optional, so you can start with the recent default window and only add explicit boundaries when you need a specific range.
Query intents and RFQs
intents(...) returns typed RFQ, quote, executable-intent, and settlement
observations in stored order. Use market="intents" and correlate rows by their
captured rfq_id or intent_id.
Query option tickers
Useoption_tickers(...) with an underlying market such as BTC. Omit
instrument to iterate over the whole option chain, or provide an exact
venue-native contract to filter the results.
source, the normalized underlying market,
and the non-empty exact instrument separate. See
Option tickers for the payload fields and realtime
filtering behavior.
Query perpetual tickers
Useperpetual_tickers(...) to iterate over partial venue-published market
state for a perpetual market.
PerpetualTickerData, LegacyPerpetualTickerEvent,
PerpetualTickerEventV2, and their PerpetualTickerEvent union. Decimal values
remain strings, and omitted fields are not carried forward. Generic events,
replay, and realtime stream methods include these events automatically. See
Perpetual tickers for all payload fields and
validation rules.
Query OHLCV bars
Useohlcv(...) when you want interval bars instead of individual trades. from_ and to are optional here as well.
format="tradingview", ohlcv(...) returns TradingView-style candle and volume arrays.
Query order book snapshots
Usel2_snapshots(...) when you need order book depth data for microstructure analysis.
l2_updates(...) and materialize books only
when your application needs them:
update() changes native state without constructing a complete Python
dictionary. snapshot() creates sorted levels only when requested. Use
apply() when you need the previous update-and-materialize behavior.
Query funding rates
Usefunding_rates(...) to analyze perpetual funding rates and carry modeling.
Query mark prices
Usemark_prices(...) for basis analysis, mark tracking, and liquidation-related research.
Query volume profiles
Usevolume(...) for volume profiling and participation analysis.
Query VWAP series
Usevwap(...) for execution benchmarking and price smoothing.
Query volatility series
Usevolatility(...) for risk modeling and intraperiod volatility analysis.
Query best bid/offer
Usebbo(...) for spread tracking, quote analytics, and top-of-book monitoring.
Set changes_only=True when the consumer only needs actual top-of-book changes;
the default continues to emit after every valid two-sided book update.
Query depth metrics
Usedepth_metrics(...) for liquidity analysis and market impact estimation.
Local dataset storage
The SDK stores standardized snapshots and local day files under a shared Polaris app-data root so the Python SDK and CLI can reuse the same files. Default roots:- macOS:
~/Library/Application Support/polaris - Linux:
$XDG_DATA_HOME/polarisor~/.local/share/polaris - Windows:
%APPDATA%\polaris
dataset_root=... to PolarisClient(...) to override the root explicitly.
POLARIS_ROOToverrides the shared root globally.POLARIS_DATASET_DOWNLOAD_DIRis still accepted as a deprecated compatibility override.
Snapshot-first replay
Standardized historical methods—includingreplay(...), events(...),
trades(...), option_tickers(...), perpetual_tickers(...), and default or
TradingView ohlcv(...)—prefer /snapshots and /download, then read local day
files when they already exist. See Snapshots for the
full flow.
Authentication
Public sources (e.g. Hyperliquid BTC) 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
Notebook workflow
If you want a notebook that discovers a market, loads a DataFrame, and plots a chart, start with Jupyter Notebook.Next steps
- Read Jupyter Notebook if you want notebook-ready workflows with pandas and matplotlib.
- Read Catalog before you hardcode source and market IDs.
- Read Quickstart if you want the shared auth model behind the SDK.
- Read Snapshots if your Python workflow starts from historical files.
- Read Trades, Perpetual tickers, Events, or OHLCV for detailed method documentation.