pandas-style client for the Pyth Pro Router (Pyth Lazer) REST + WebSocket API
Project description
pyth-pandas
pandas-style client for the Pyth Pro Router (Pyth Lazer) REST + WebSocket API
Every list endpoint returns a pandas.DataFrame, every dict endpoint returns
a TypedDict, and every shape is enforced by a pandera schema. Sync + async,
plus optional WebSocket, Streamlit explorer, and FastMCP server extras.
This client targets Pyth Pro Router API v1.0.0 (per the published OpenAPI
spec). The package version (0.1.0) is independent of the upstream API
version — see the API_VERSION / SUPPORTED_API_VERSIONS class attributes
on PythPandas.
Install
uv pip install pyth-pandas # core
uv pip install "pyth-pandas[ws]" # + WebSocket
uv pip install "pyth-pandas[explorer]" # + Streamlit dashboard
uv pip install "pyth-pandas[mcp]" # + FastMCP server
uv pip install "pyth-pandas[dev]" # + test/lint toolchain
Quickstart
from pyth_pandas import PythPandas
with PythPandas() as client:
df = client.fetch_latest_prices(
symbols=["Crypto.BTC/USD", "Crypto.ETH/USD"],
properties=["price", "confidence", "exponent", "publisherCount"],
formats=[],
)
df["humanPrice"] = df["price"] * 10 ** df["exponent"]
print(df[["priceFeedId", "humanPrice", "publisherCount"]])
The DataFrame has one row per feed. The on-chain payloads (when
requested via formats=["evm", ...]) and the update timestamp are
attached on df.attrs. For the raw JsonUpdate dict, use
fetch_latest_prices_raw(...).
Async
import asyncio
from pyth_pandas import AsyncPythPandas
async def main():
async with AsyncPythPandas() as client:
df = await client.fetch_latest_prices(
symbols=["Crypto.BTC/USD"],
properties=["price", "exponent"],
formats=[],
)
print(df)
asyncio.run(main())
Authentication
Pyth Pro requires a bearer access token. Set it via env var (recommended) or
constructor arg. Copy the shipped .env.example to .env and fill in your
key — examples and tests load it via python-dotenv:
cp .env.example .env
$EDITOR .env # set PYTH_API_KEY=...
Or set it in your shell:
export PYTH_API_KEY=...
Or pass it directly:
PythPandas(api_key="...")
Endpoints
| Method | HTTP | Returns |
|---|---|---|
fetch_latest_prices(...) |
POST /v1/latest_price |
DataFrame[ParsedFeedSchema] |
fetch_latest_prices_raw(...) |
POST /v1/latest_price |
JsonUpdate (TypedDict) |
fetch_prices(timestamp=..., ...) |
POST /v1/price |
DataFrame[ParsedFeedSchema] |
fetch_prices_raw(...) |
POST /v1/price |
JsonUpdate |
reduce_price(payload=..., price_feed_ids=...) |
POST /v1/reduce_price |
DataFrame[ParsedFeedSchema] |
reduce_price_raw(...) |
POST /v1/reduce_price |
JsonUpdate |
get_guardian_set_upgrade() |
GET /v1/guardian_set_upgrade |
SignedGuardianSetUpgrade | None |
WebSocket: PythWebSocket / AsyncPythWebSocket (extra: ws) → connects
to wss://pyth-lazer.dourolabs.app/v1/stream.
Compatibility
| pyth-pandas | Pyth Pro Router API |
|---|---|
| 0.1.x | 1.0.0 |
Error handling
from pyth_pandas import PythAuthError, PythRateLimitError, PythAPIError
try:
df = client.fetch_latest_prices(symbols=["Crypto.BTC/USD"], properties=["price"])
except PythAuthError:
... # 401/403 or missing PYTH_API_KEY
except PythRateLimitError:
... # 429
except PythAPIError as e:
print(e.status_code, e.url, e.detail)
Development
uv pip install -e ".[dev,ws,explorer,mcp]"
uv run pytest tests/test_unit.py tests/test_async_unit.py -v
uv run ruff check pyth_pandas tests
uv run mypy pyth_pandas
CI runs the same checks on every push and PR via .github/workflows/ci.yml
across Python 3.11, 3.12, 3.13.
Releasing
Releases are cut by pushing a v* tag. .github/workflows/release.yml:
- Runs ruff + mypy + mocked pytest, then live integration tests against the real upstream API. If the test job fails, build / publish / release are all skipped.
- Builds sdist + wheel via
uv build. - Publishes to PyPI via trusted publishing.
- Creates a GitHub release.
One-time setup:
- Reserve
pyth-pandason PyPI. - At https://pypi.org/manage/account/publishing/, add a pending publisher:
- Project:
pyth-pandas - Owner: your GitHub user/org
- Repo:
pyth-pandas - Workflow:
release.yml - Environment:
pypi
- Project:
- Create the
pypienvironment in GitHub repo settings. - Add
PYTH_API_KEYas an environment secret on thepypienvironment so live integration tests can run before publishing. - Enable GitHub Pages with source = "GitHub Actions" so
docs.ymlcan deploy the Sphinx site.
To force a release if the test infra is broken:
gh workflow run release.yml -f tag=v0.1.1 -f skip_tests=true
License
Apache-2.0
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 pyth_pandas-0.1.1.tar.gz.
File metadata
- Download URL: pyth_pandas-0.1.1.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aac4ec143915aabd9257aafd79added292a88c74f5ac279957430e4a5d00b824
|
|
| MD5 |
1b69db51e78c70969753b9920c83363a
|
|
| BLAKE2b-256 |
edc1b70001e1d14eabe09993708988d3e088d2c1eeb3acaaa6d2ba6ef3be0da5
|
Provenance
The following attestation bundles were made for pyth_pandas-0.1.1.tar.gz:
Publisher:
release.yml on sigma-quantiphi/pyth-pandas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyth_pandas-0.1.1.tar.gz -
Subject digest:
aac4ec143915aabd9257aafd79added292a88c74f5ac279957430e4a5d00b824 - Sigstore transparency entry: 1294360018
- Sigstore integration time:
-
Permalink:
sigma-quantiphi/pyth-pandas@f867bc97f675d77a7052923c361407e505dc9a71 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/sigma-quantiphi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f867bc97f675d77a7052923c361407e505dc9a71 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyth_pandas-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyth_pandas-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
595935f21a089a8834b60c0bcfed92b39f7c2984853bf343b7e29b6cc2cd8fab
|
|
| MD5 |
aaaf195c52f8f18b6fe9f8d1fcb0a7f1
|
|
| BLAKE2b-256 |
9fb026d47114cb8275d9604fca64e8ee6d5c2a280f0f5f715975e4250112903f
|
Provenance
The following attestation bundles were made for pyth_pandas-0.1.1-py3-none-any.whl:
Publisher:
release.yml on sigma-quantiphi/pyth-pandas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyth_pandas-0.1.1-py3-none-any.whl -
Subject digest:
595935f21a089a8834b60c0bcfed92b39f7c2984853bf343b7e29b6cc2cd8fab - Sigstore transparency entry: 1294360053
- Sigstore integration time:
-
Permalink:
sigma-quantiphi/pyth-pandas@f867bc97f675d77a7052923c361407e505dc9a71 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/sigma-quantiphi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f867bc97f675d77a7052923c361407e505dc9a71 -
Trigger Event:
push
-
Statement type: