Python SDK for the Polaris market data API
Project description
polaris-py
Python SDK for the Polaris API, optimized for notebook workflows and trading scripts.
Install (uv)
uv sync --group dev
Useful commands:
uv run python
uv lock
Quickstart
from polaris_data import PolarisClient
with PolarisClient.new("pk_live_your_key") as client:
exchanges = client.exchanges()
assets = client.assets(exchanges[0])
trades = client.collect_all_trades(
exchange=exchanges[0],
asset=assets[0],
from_="2024-01-01T00:00:00Z",
to="2024-01-01T01:00:00Z",
limit=500,
)
print(f"Loaded {len(trades)} trades")
If api_key is omitted, the client reads POLARIS_API_KEY from the environment.
Supported input time types
Methods that take from_ and to accept:
- ISO 8601 strings (
"2024-01-01T00:00:00Z") datetime.datetimedatetime.date- Unix epoch microseconds (
int/float)
Methods
Open endpoints:
health()exchanges()assets(exchange)timerange(exchange, asset)dataset_size(exchange, asset, from_, to)catalog()dataset_preview(..., standard=False)ohlcv_preview(..., interval, limit=None, format=None)
Authenticated endpoints:
dataset_download_url(..., standard=False)trades_page(..., limit=1000, cursor=None)iter_trades(...)collect_all_trades(...)stream_events(..., standard=False)collect_events(..., standard=False)iter_ohlcv(..., interval)ohlcv(..., interval, format=None)
Error handling
from polaris_data import PolarisClient, RateLimitedError, UnauthorizedError
client = PolarisClient.anonymous()
try:
client.collect_events("binance", "BTC-USDT", "2024-01-01T00:00:00Z", "2024-01-01T01:00:00Z")
except UnauthorizedError:
print("API key is required")
except RateLimitedError as err:
print(f"Rate limited. Reset at: {err.reset_at}")
Tests
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
polaris_data-0.1.0.tar.gz
(16.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polaris_data-0.1.0.tar.gz.
File metadata
- Download URL: polaris_data-0.1.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec678bcc1c05c570b5377bc94c13d7adaa3a003c128985bc60d350c2fe3e482a
|
|
| MD5 |
631849f98d7cfbcf35a0a68693fb9d95
|
|
| BLAKE2b-256 |
fd1c23303324c0a67bf4c6bb2ac61b4731569b02d9150948c1c0ce6f707bdd79
|
File details
Details for the file polaris_data-0.1.0-py3-none-any.whl.
File metadata
- Download URL: polaris_data-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1daf7a9a01195ec970a794ba0988dd6163e1ba8197ff501136eeeb3108fb488
|
|
| MD5 |
02e1083f60bbad754a5316f16c339184
|
|
| BLAKE2b-256 |
9c07fd6c29c7b687a4c8a7758df13c1ed4550c262af2f5c06982a40baef57451
|