Official Python client library for the Polybridge Analytics API.
Install from source:
# Clone the repository
git clone https://github.com/crowdvector/polybridge-python-client.git
cd polybridge-python-client
# Install the package
pip install .Or install in editable mode for development:
pip install -e .from polybridge import PolybridgeClient
# Initialize client with your API key
client = PolybridgeClient(api_key="your-api-key-here")
# Fetch timeseries data
result = client.fetch_timeseries(
asset="BTC",
horizons=["daily"],
market_types=["up-or-down", "above"],
hours=6,
)
# Access parsed dataframes
prob_df = result.dataframes.get("probabilities")
price_df = result.dataframes.get("prices")- High-level API: Query by asset, horizon, and market type without worrying about market IDs
- Automatic data aggregation: Handles multiple markets and intervals automatically
- Pandas integration: Returns data as pandas DataFrames for easy analysis
- Type hints: Full type annotations for better IDE support
- Error handling: Clear error messages with API error details
Browse available markets:
catalog = client.fetch_market_catalog(
assets=["BTC", "ETH"],
horizons=["daily", "weekly"],
market_types=["up-or-down"],
)Fetch historical data with probabilities, prices, and options metrics:
result = client.fetch_timeseries(
asset="BTC",
horizons=["daily", "weekly"],
market_types=["up-or-down", "above"],
hours=24,
include_prices=True,
include_options_metrics=True,
)Get specialized options data:
from datetime import datetime, timedelta
end = datetime.now(timezone.utc)
start = end - timedelta(days=7)
# Up-or-down options with metrics
up_down_data = client.fetch_up_or_down_options_timeseries(
asset="BTC",
start_ts=start.isoformat(),
end_ts=end.isoformat(),
window_days=[7, 30],
)
# Above options with probabilities
above_data = client.fetch_above_options_timeseries(
asset="BTC",
start_ts=start.isoformat(),
end_ts=end.isoformat(),
format="long", # or "wide"
)Main client class for interacting with the API.
PolybridgeClient(api_key, *, base_url=DEFAULT_BASE_URL, timeout=60, session=None)Initialize the client.
api_key(str): Your API key (required)base_url(str): API base URL (optional, defaults to production)timeout(int): Request timeout in seconds (default: 60)session(requests.Session): Custom session for connection pooling (optional)
fetch_market_catalog(*, assets=None, horizons=None, market_types=None, start_ts=None, end_ts=None)Get market catalog matching filters.
Returns a dictionary with "markets" list.
fetch_timeseries(*, asset, horizons, market_types=None, start_ts=None, end_ts=None, hours=6.0, include_prices=True, include_open_interest=True, include_options_metrics=False, prices_instrument="spot", chunk_size=10, include_probabilities=True)Fetch timeseries data for an asset.
Returns a TimeseriesResult with:
catalog: List of market entriesresponses: Raw API responses by intervaldataframes: Parsed pandas DataFrames
fetch_up_or_down_options_timeseries(*, asset, start_ts, end_ts, window_days=None, horizon="daily")Fetch up-or-down options data with metrics.
fetch_above_options_timeseries(*, asset, start_ts, end_ts, format="long", horizon="daily")Fetch above options data with probabilities.
Dataclass containing:
catalog: List[Dict[str, object]] - Market catalog entriesresponses: Dict[str, Dict[str, object]] - Raw API responsesdataframes: Dict[str, pd.DataFrame] - Parsed DataFrames
- Python 3.8+
- requests >= 2.31.0
- pandas >= 2.0.0
First, set up a virtual environment:
Using uv (recommended):
# Create virtual environment
uv venv
# Activate it
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode with all optional dependencies
uv pip install -e ".[dev,notebooks]"Using standard Python tools:
# Create virtual environment
python -m venv .venv
# Activate it
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode
pip install -e ".[dev,notebooks]"# Clone the repository
git clone https://github.com/crowdvector/polybridge-python-client.git
cd polybridge-python-client
# Run tests
pytestdev: Development tools (pytest, black, ruff, mypy)notebooks: Jupyter notebook support (jupyter, notebook, ipykernel, matplotlib)
Install specific groups:
pip install -e ".[dev]" # Just dev tools
pip install -e ".[notebooks]" # Just notebooks
pip install -e ".[dev,notebooks]" # BothMIT License - see LICENSE file for details.
For issues, questions, or feature requests, please open an issue on GitHub.
- Initial release of Polybridge Python client
- Support for market catalog, timeseries, and options endpoints
- Pandas DataFrame integration
- Full type hints and documentation