client.l2_snapshots() when you need order book snapshots for market microstructure analysis. This method returns standardized Level 2 order book data with bids and asks at multiple price levels.
Method signature
Parameters
| Parameter | Type | Required | Notes |
|---|---|---|---|
| source | str | Yes | Source ID |
| market | str | Yes | Normalized market or instrument ID |
| from_ | str/datetime/date/int | Yes | Inclusive start time (ISO 8601, datetime, date, or epoch microseconds) |
| to | str/datetime/date/int | Yes | Exclusive end time (same formats as from_) |
| limit | int | No | Page size (default: 1000) |
POLARIS_API_KEY environment variable or pass api_key to PolarisClient().
Return value
List of normalized order book snapshot dictionaries.Example response
Fields
L2 snapshots use the standard event envelope withtype: "orderbook" and the following order book-specific fields under data:
data.bids: array of bid levels, each withpriceandquantitydata.asks: array of ask levels, each withpriceandquantity
timestamp is the snapshot time in UTC microseconds since the Unix epoch.
Example
How it works
client.l2_snapshots() uses snapshot-first replay: it queries the /snapshots endpoint for historical data and reads from local cached files when available. The SDK handles pagination and data normalization automatically.
For more details on snapshot-based queries, see Snapshots.
Related documentation
- Depth metrics for derived liquidity metrics
- BBO if you only need top-of-book quotes
- Events if you need order book updates mixed with other event types
- Authentication