Skip to main content
The Polaris Python SDK is available on PyPI as polaris-data.

Install

If you use uv, install it into a project with:
Or install it into the active environment with:

Quickstart

Use replay(...) 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 omit api_key, the client reads POLARIS_API_KEY from the environment.
The main constructor is:

Core methods

Use PolarisClient for discovery, historical replay, and direct query workflows. from_ and to accept ISO 8601 strings, datetime, date, or Unix epoch microseconds. They are optional on replay(...), events(...), trades(...), 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.

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. Omit from_ and to to query the recent default window, or pass them explicitly when you need a fixed range.

Query trades

trades(...) returns a list of normalized trade events. The SDK handles pagination and 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 OHLCV bars

Use ohlcv(...) when you want interval bars instead of individual trades. from_ and to are optional here as well.
If you pass format="tradingview", ohlcv(...) returns TradingView-style candle and volume arrays.

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 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/polaris or ~/.local/share/polaris
  • Windows: %APPDATA%\polaris
Within that root, the SDK uses this layout:
Pass dataset_root=... to PolarisClient(...) 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 default or TradingView ohlcv(...) prefer /snapshots and /snapshots/download, then read local day files when they already exist. This applies whether you pass an explicit range or rely on the default recent window.
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 the POLARIS_API_KEY environment variable or pass it directly:
See Authentication for the full auth model.

Error handling

Notebook workflow

If you want a notebook that discovers a market, loads a DataFrame, and plots a chart, start with Example Notebooks.

Next steps

  • Read Example Notebooks if you want notebook-ready workflows with pandas and matplotlib.
  • Read Catalog before you hardcode source and market IDs.
  • Read Authentication if you want the shared auth model behind the SDK.
  • Read Snapshots if your Python workflow starts from historical files.
  • Read Trades, Events, or OHLCV for detailed method documentation.