Client library for Aperiodic aggregate market data API - OHLCV and more
Project description
Aperiodic Data Client
Python client library for the Aperiodic aggregate market data API. Access pre-computed OHLCV candlestick data and other market aggregates with parallel downloads for optimal performance.
Installation
pip install aperiodic
Or install from source:
git clone https://github.com/aperiodic-io/aperiodic-client.git
cd aperiodic-io
pip install -e .
Symbology
All symbol identifiers follow the Atlas unified symbology — a standardised, exchange-agnostic naming scheme. Use Atlas to look up or convert symbol names before passing them to any function in this client.
Refer to the Atlas repository for the full symbol catalogue and conversion utilities.
Quick Start
from datetime import date
from aperiodic import get_metric
# Fetch hourly OHLCV data for BTC
df = get_metric(
api_key="your-api-key",
timestamp="true",
interval="1h",
exchange="binance-futures",
symbol="perpetual-BTC-USDT:USDT",
start_date=date(2024, 1, 1),
end_date=date(2024, 3, 31),
)
print(df.head())
Features
- Parallel Downloads: Files are downloaded concurrently for fast data retrieval
- Per-File Retry: Each file download has independent retry with exponential backoff
- Date Range Support: Fetch data spanning multiple months in a single call
- Progress Bar: Visual progress indication with tqdm
- Type Hints: Full type annotations for IDE support
- Async Support: Both sync and async APIs available
- Jupyter Compatible: Works seamlessly in Jupyter notebooks
API Reference
get_metric
Fetch historical OHLCV (Open, High, Low, Close, Volume) data.
def get_metric(
api_key: str,
timestamp: Literal["exchange", "true"],
interval: Literal["1m", "5m", "15m", "30m", "1h", "4h", "1d"],
exchange: Literal["binance-futures", "binance"],
symbol: str,
start_date: date,
end_date: date,
show_progress: bool = True,
max_concurrent: int = 10,
) -> pl.DataFrame
Parameters:
| Parameter | Type | Description |
|---|---|---|
api_key |
str |
Your Aperiodic API key |
timestamp |
"exchange" | "true" |
Timestamp source - "exchange" for exchange-reported time, "true" for actual arrival time |
interval |
str |
Aggregation interval ("1m", "5m", "15m", "30m", "1h", "4h", "1d") |
exchange |
str |
Source exchange ("binance-futures", "binance") |
symbol |
str |
Trading pair symbol in Atlas unified symbology (e.g., "perpetual-BTC-USDT:USDT") |
start_date |
date |
Start date for the data range |
end_date |
date |
End date for the data range (inclusive) |
base_url |
str |
API base URL (optional) |
show_progress |
bool |
Show download progress bar (default: True) |
max_concurrent |
int |
Maximum concurrent downloads (default: 10) |
Returns:
pl.DataFrame with columns:
timestamp: Unix timestamp in millisecondsdatetime: Parsed datetime (added by client)open: Opening pricehigh: Highest pricelow: Lowest priceclose: Closing pricevolume: Trading volume
get_metric_async
Async version of get_metric. Use this when you're already in an async context.
import asyncio
from aperiodic import get_metric_async
async def main():
df = await get_metric_async(
api_key="your-api-key",
timestamp="true",
interval="1h",
exchange="binance-futures",
symbol="btcusdt",
start_date=date(2024, 1, 1),
end_date=date(2024, 3, 31),
)
return df
df = asyncio.run(main())
get_symbols
Get the list of available symbols for an exchange.
from aperiodic import get_symbols
symbols = get_symbols(
api_key="your-api-key",
exchange="binance-futures",
)
print(f"Found {len(symbols)} symbols")
print(symbols[:10]) # First 10 symbols
Parameters:
| Parameter | Type | Description |
|---|---|---|
api_key |
str |
Your Aperiodic API key |
exchange |
str |
Source exchange ("binance-futures", "binance") |
bucket |
str |
Data bucket (default: "ohlcv") |
base_url |
str |
API base URL (optional) |
Returns:
list[str] - List of available symbol names (lowercase)
Error Handling
from aperiodic import get_metric, APIError, DownloadError
try:
df = get_metric(...)
except APIError as e:
print(f"API error {e.status_code}: {e.message}")
if e.details:
print(f"Details: {e.details}")
except DownloadError as e:
print(f"Failed to download {e.year}-{e.month:02d}: {e.original_error}")
Data Storage
Data is stored using Hive partitioning in Parquet format:
{timestamp}/{interval}/exchange={exchange}/symbol={symbol}/year={year}/month={month}.parquet
The client handles all the complexity of fetching multiple monthly files and combining them into a single DataFrame.
Package Structure
The client is organized into modules for different data types:
aperiodic/
├── ohlcv/ # OHLCV candlestick data
│ └── historical.py # Historical data retrieval
├── general/ # General utilities
│ └── symbols.py # Symbol listing
├── client.py # Shared utilities and base functionality
├── config.py # Configuration constants
└── types.py # Type definitions
You can import directly from the package or from submodules:
# Direct import (recommended)
from aperiodic import get_metric, get_symbols
# Or import from submodules
from aperiodic.ohlcv import get_metric
from aperiodic.general import get_symbols
Requirements
- Python 3.11+
- httpx
- polars
- tqdm
- nest_asyncio (for Jupyter support)
License
MIT License - see LICENSE file for details.
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
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 aperiodic-3.1.0.tar.gz.
File metadata
- Download URL: aperiodic-3.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.11.14 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1101e9a1e1cbf868ebd2f594f6e834270574a2a9edd17fafc94d27e5f8970bfa
|
|
| MD5 |
942737e1f13583416b86c593ee73e9ed
|
|
| BLAKE2b-256 |
1406e1f0f6d6f9aaaf6faa049205356f267108beea2329a3f35c321a78717acf
|
File details
Details for the file aperiodic-3.1.0-py3-none-any.whl.
File metadata
- Download URL: aperiodic-3.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.11.14 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4818926112309dd243f64d3aa553e88d0e5eb4f0317c85661056974d82969b55
|
|
| MD5 |
04503b224291e8fb2a7219379dee4cb0
|
|
| BLAKE2b-256 |
96bd956f8b1840c635a6f1f5a68c1dc79c342af4823552cee07449855bbd71d0
|