A comprehensive Python toolkit for fetching real-time and historical price data from PYTH Network oracles.
- ✅ Real-time Price Data - Fetch latest prices with confidence intervals
- ✅ Historical Data - Get price history with customizable time ranges
- ✅ Minute-level Precision - Up to 1440 data points per 24 hours
- ✅ Multiple Time Granularities - Hour, 5-min, or minute intervals
- ✅ 100% Success Rate - Robust error handling and retry logic
- ✅ Easy to Use - Simple command-line interface
- 📊 Data Export - Save results to JSON for further analysis
# Clone the repository
git clone https://github.com/YOUR_USERNAME/pyth-oracle-toolkit.git
cd pyth-oracle-toolkit
# Install dependencies
pip install -r requirements.txt
# Get real-time price
python get_realtime_price.py
# Get 24-hour lowest price
python get_24h_lowest.py <your_feed_id>
# Get minute-level data
python get_minute_data.py 24| Script | Description | Usage |
|---|---|---|
get_realtime_price.py |
Fetch latest price data | python get_realtime_price.py |
get_24h_lowest.py |
Find 24h lowest price | python get_24h_lowest.py [feed_id] |
get_historical_price.py |
Query historical data | python get_historical_price.py --days 7 |
get_minute_data.py |
Minute-level data (1440 points/24h) | python get_minute_data.py 24 |
fetch_price_feed_info.py |
Query price feed information | python fetch_price_feed_info.py |
JLP/USD 24小时最低价: $5.1570
发生时间: 2025-10-10 22:28:31
📊 数据点数: 1440/1440 (100.0% 成功率)
🔴 最高价: $5.8222
🟢 最低价: $5.1570
📈 平均价: $5.4889
📊 价格波动: $0.6652 (12.90%)
Hermes continuously monitors Pyth Network for price updates and serves them via REST API.
Endpoint: https://hermes.pyth.network
Benchmarks provides historical price data queries for any time point.
Endpoint: https://benchmarks.pyth.network
- Solana Account Address: Used on Solana blockchain (Base58 format)
- Example:
2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw
- Example:
- Price Feed ID: Used in Hermes/Benchmarks API (64-char hex string)
- Example:
0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
- Example:
Find your Price Feed ID at: https://www.pyth.network/price-feeds
| Asset | Price Feed ID |
|---|---|
| BTC/USD | e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43 |
| ETH/USD | ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace |
| SOL/USD | ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d |
| JLP/USD | c811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a |
- 📖 Quick Start Guide - Get started in 30 seconds
- 📚 Complete Guide (中文) - Detailed Chinese documentation
- 📊 Examples & API Reference - Code examples and API details
PYTH returns prices with an exponent field:
price: 383538126869
expo: -8
Actual Price = 383538126869 × 10^(-8) = 3835.38 USD
- Python 3.7+
- requests
- python-dateutil
- base58
- Hermes and Benchmarks APIs are free to use
- Implement appropriate rate limiting to avoid throttling
- Use larger time granularities (e.g., 5-min instead of 1-min) for long historical queries
- Pyth Network: https://www.pyth.network
- Price Feeds Browser: https://www.pyth.network/price-feeds
- Official Docs: https://docs.pyth.network
- Hermes API Docs: https://hermes.pyth.network/docs
- GitHub: https://github.com/pyth-network/pyth-crosschain
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
This tool is for educational and research purposes. Always verify data accuracy and implement proper error handling for production use.