| # Crypto Data Source API (Dual Mode) | |
| **Updated:** 2025-11-11T20:56:45.223511Z | |
| This backend is designed to support **both** frontend shapes you used: | |
| - Classic `/api/*` endpoints (status/providers/categories/charts/logs/failures/freshness/config/keys/custom/add). | |
| - Alternate aliases and extras that some UIs expect: `/health`, `/info`, `/api/rate-limits`, `/api/alerts`, `/api/logs?type=...`, | |
| plus synthetic **Hugging Face** helpers under `/api/hf/*`. | |
| ## Files | |
| - `app.py` β FastAPI application (single file, no `frontend/` folder needed). Place your `index.html` next to it if you want static SPA routing. | |
| - `requirements.txt` β minimal, conflict-free pins tested for HF Spaces. | |
| ## Run (local) | |
| ```bash | |
| pip install -r requirements.txt | |
| uvicorn app:app --host 0.0.0.0 --port 7860 | |
| ``` | |
| ## Endpoints | |
| - `/` β serves `index.html` if present; else JSON hint | |
| - `/ws/live` β live events (`live_metrics`, `status_update`, `provider_status_change`, `new_alert`) | |
| - `/health` β alias of `/api/health` | |
| - `/info` β status-like payload | |
| - `/api/health` | |
| - `/api/status` | |
| - `/api/providers` | |
| - `/api/categories` | |
| - `/api/charts/health-history?hours=24` | |
| - `/api/charts/compliance?days=7` | |
| - `/api/freshness` | |
| - `/api/logs` (optional `?type=connection|error`) | |
| - `/api/failures` (alias exposed also at `/api/alerts`) | |
| - `/api/rate-limits` | |
| - `/api/config/keys` | |
| - `/api/custom/add` (POST query params: `name`, `url`, `category`, optional `test_field`) | |
| - `/api/markets`, `/api/ticker/{symbol}` (via ccxt) | |
| - `/api/hf/health`, `/api/hf/refresh` (POST), `/api/hf/registry?type=models|datasets`, `/api/hf/search?q=&kind=`, `/api/hf/run-sentiment` (POST JSON: `{"text": "..."}`) | |
| All non-critical data are **synthetic** to keep it lightweight on Spaces. | |