File size: 8,780 Bytes
eebf5c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
---
title: Crypto API Monitor
emoji: π
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.14.0
app_file: app_gradio.py
pinned: false
license: mit
---
# π Cryptocurrency API Monitor
> **Production-ready real-time health monitoring for 162+ cryptocurrency API endpoints**
A comprehensive monitoring dashboard that tracks the health, uptime, and performance of cryptocurrency APIs including block explorers, market data providers, RPC nodes, news sources, and more.
## π Features
### Core Capabilities
- **Real-Time Monitoring**: Async health checks for 162+ API endpoints
- **Multi-Tier Classification**: Critical (Tier 1), Important (Tier 2), and Others (Tier 3)
- **Persistent Storage**: SQLite database for historical metrics and incident tracking
- **Auto-Refresh**: Configurable background scheduler (1-60 minute intervals)
- **Category Organization**: Block Explorers, Market Data, RPC Nodes, News, Sentiment, etc.
- **Export Functionality**: Download status reports as CSV
### 5-Tab Interface
#### π Tab 1: Real-Time Dashboard
- Live status grid with color-coded health badges (π’π‘π΄)
- Summary cards: Total APIs, Online %, Critical Issues, Avg Response Time
- Advanced filtering: By category, status, or tier
- One-click CSV export
- Response time tracking per provider
#### π Tab 2: Category View
- Accordion-style category breakdown
- Availability percentage per category
- Visual progress bars
- Average response time per category
- Interactive Plotly charts with dual-axis (availability + response time)
#### π Tab 3: Health History
- Uptime percentage trends (last 1-168 hours)
- Response time evolution charts
- Incident log with timestamps and severity
- Per-provider detailed history
- Automatic data retention (24-hour rolling window)
#### π§ Tab 4: Test Endpoint
- Interactive endpoint testing
- Custom endpoint override support
- CORS proxy toggle
- Example queries for each provider
- Formatted JSON responses
- Troubleshooting hints for common errors (403, 429, timeout)
#### βοΈ Tab 5: Configuration
- Refresh interval slider (1-60 minutes)
- Cache management controls
- Configuration statistics overview
- API key management instructions
- Scheduler status display
### Advanced Features
- **Async Architecture**: Concurrent health checks with semaphore-based rate limiting
- **Exponential Backoff**: Automatic retry logic for failed checks
- **Staggered Requests**: 0.1s delay between checks to respect rate limits
- **Caching**: 1-minute response cache to reduce API load
- **Incident Detection**: Automatic incident creation for Tier 1 outages
- **Alert System**: Database-backed alerting for critical issues
- **Data Aggregation**: Hourly response time rollups
- **Auto-Cleanup**: 7-day data retention policy
## π Quick Start
### Local Development
```bash
# Clone repository
git clone https://github.com/nimazasinich/crypto-dt-source.git
cd crypto-dt-source
# Install dependencies
pip install -r requirements.txt
# Run the application
python app_gradio.py
```
Visit `http://localhost:7860` to access the dashboard.
### Hugging Face Spaces Deployment
1. **Create a new Space** on Hugging Face
2. **Link this GitHub repository** (Settings > Linked repositories)
3. **Set SDK to Gradio** in Space settings
4. **Configure app_file**: `app_gradio.py`
5. **Add API keys** as Space secrets (Settings > Repository secrets):
- `ETHERSCAN_KEY`
- `BSCSCAN_KEY`
- `TRONSCAN_KEY`
- `CMC_KEY` (CoinMarketCap)
- `CRYPTOCOMPARE_KEY`
- `NEWSAPI_KEY`
6. **Push to main branch** - Auto-deploy triggers!
## π¦ Project Structure
```
crypto-dt-source/
βββ app_gradio.py # Main Gradio application
βββ config.py # Configuration & JSON loader
βββ monitor.py # Async health check engine
βββ database.py # SQLite persistence layer
βββ scheduler.py # Background job scheduler
βββ requirements.txt # Python dependencies
βββ ultimate_crypto_pipeline_2025_NZasinich.json # API registry
βββ all_apis_merged_2025.json # Merged API resources
βββ data/ # SQLite database & exports
β βββ health_metrics.db
βββ README_HF_SPACES.md # This file
```
## π§ Configuration
### Environment Variables
All API keys are loaded from environment variables:
```bash
ETHERSCAN_KEY=your_key_here
BSCSCAN_KEY=your_key_here
TRONSCAN_KEY=your_key_here
CMC_KEY=your_coinmarketcap_key
CRYPTOCOMPARE_KEY=your_key_here
NEWSAPI_KEY=your_key_here
```
### Scheduler Settings
Default: 5-minute intervals
Configurable: 1-60 minutes via UI slider
### Database
- **Storage**: SQLite (`data/health_metrics.db`)
- **Tables**: status_log, response_times, incidents, alerts, configuration
- **Retention**: 7 days (configurable)
- **Fallback**: In-memory if persistent storage unavailable
## π API Resources Monitored
### Categories
1. **Block Explorer** (25+ APIs)
- Etherscan, BscScan, TronScan, Blockscout, Blockchair, etc.
2. **Market Data** (15+ APIs)
- CoinGecko, CoinMarketCap, CryptoCompare, Coinpaprika, etc.
3. **RPC Nodes** (10+ providers)
- Infura, Alchemy, Ankr, PublicNode, QuickNode, etc.
4. **News** (5+ sources)
- CryptoPanic, CryptoControl, NewsAPI, etc.
5. **Sentiment** (5+ APIs)
- Alternative.me Fear & Greed, LunarCrush, Santiment, etc.
6. **Whale Tracking** (5+ services)
- Whale Alert, ClankApp, BitQuery, Arkham, etc.
7. **On-Chain Analytics** (10+ APIs)
- The Graph, Glassnode, Dune, Covalent, Moralis, etc.
8. **CORS Proxies** (5+ proxies)
- AllOrigins, CORS.sh, Corsfix, ThingProxy, etc.
## π¨ Visual Design
- **Theme**: Dark mode with crypto-inspired gradients
- **Color Scheme**: Purple/Blue primary, semantic status colors
- **Status Badges**:
- π’ Green: Online (200-299 status)
- π‘ Yellow: Degraded (400-499 status)
- π΄ Red: Offline (timeout or 500+ status)
- βͺ Gray: Unknown (not yet checked)
- **Charts**: Interactive Plotly with zoom, pan, hover details
- **Responsive**: Mobile-friendly grid layout
## π API Access
### Gradio Client (Python)
```python
from gradio_client import Client
client = Client("YOUR_USERNAME/crypto-api-monitor")
result = client.predict(api_name="/status")
print(result)
```
### Direct Embedding
```html
<iframe
src="https://YOUR_USERNAME-crypto-api-monitor.hf.space"
width="100%"
height="800px"
frameborder="0"
></iframe>
```
### REST API (via Gradio)
```bash
# Get current status
curl https://YOUR_USERNAME-crypto-api-monitor.hf.space/api/status
# Get category data
curl https://YOUR_USERNAME-crypto-api-monitor.hf.space/api/category/Market%20Data
```
## π Performance
- **Concurrent Checks**: Up to 10 simultaneous API calls
- **Timeout**: 10 seconds per endpoint
- **Cache TTL**: 60 seconds
- **Stagger Delay**: 0.1 seconds between requests
- **Database**: Sub-millisecond query performance
- **UI Rendering**: <1 second for 162 providers
## π‘οΈ Error Handling
- **Graceful Degradation**: UI loads even if APIs fail
- **Connection Timeout**: 10s timeout per endpoint
- **Retry Logic**: 3 attempts with exponential backoff
- **User Notifications**: Toast messages for errors
- **Logging**: Comprehensive stdout logging for HF Spaces
- **Fallback Resources**: Minimal hardcoded set if JSON fails
## π Security
- **API Keys**: Stored as HF Spaces secrets, never in code
- **Input Validation**: Pydantic models for all inputs
- **SQL Injection**: Parameterized queries only
- **Rate Limiting**: Respects API provider limits
- **No Secrets in Logs**: Masked keys in error messages
## π€ Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## π License
MIT License - See LICENSE file for details
## π€ Author
**Nima Zasinich** (@NZasinich)
- GitHub: [@nimazasinich](https://github.com/nimazasinich)
- Country: Estonia (EE)
- Project: Ultimate Free Crypto Data Pipeline 2025
## π Acknowledgments
- Built with [Gradio](https://gradio.app/) by Hugging Face
- Monitoring 162+ free and public crypto APIs
- Inspired by the crypto developer community's need for reliable data sources
## π Links
- **Live Demo**: [Hugging Face Space](https://huggingface.co/spaces/YOUR_USERNAME/crypto-api-monitor)
- **GitHub Repo**: [crypto-dt-source](https://github.com/nimazasinich/crypto-dt-source)
- **Issues**: [Report bugs](https://github.com/nimazasinich/crypto-dt-source/issues)
---
**Built with β€οΈ for the crypto dev community**
|