/** * Configuration Helper Modal - Updated with All Services * Shows users how to configure and use all backend services * * Services Include: * - Market Data (8+ providers) * - News (9+ sources) * - Sentiment Analysis (4+ providers) * - On-Chain Analytics (4+ providers) * - DeFi Data (3+ providers) * - Technical Analysis * - AI Models * - Block Explorers */ export class ConfigHelperModal { constructor() { this.modal = null; this.services = this.getServicesConfig(); } getServicesConfig() { const baseUrl = window.location.origin; return [ // ===== QUICK DISCOVERY ===== { name: 'Discovery & Health', category: 'Getting Started', description: 'Verify the server is online and discover all available endpoints', endpoints: [ { method: 'GET', path: '/api/health', desc: 'Health check' }, { method: 'GET', path: '/api/status', desc: 'System status' }, { method: 'GET', path: '/api/routers', desc: 'Loaded routers status' }, { method: 'GET', path: '/api/endpoints', desc: 'Full endpoints list (grouped)' }, { method: 'GET', path: '/docs', desc: 'Swagger UI documentation' } ], example: `// Health check fetch('${baseUrl}/api/health') .then(res => res.json()) .then(console.log); // Get full endpoints list fetch('${baseUrl}/api/endpoints') .then(res => res.json()) .then(data => console.log('Total:', data.total_endpoints));` }, // ===== UNIFIED SERVICE API ===== { name: 'Unified Service API', category: 'Core Services', description: 'Single entry point for all cryptocurrency data needs', endpoints: [ { method: 'GET', path: '/api/service/rate?pair=BTC/USDT', desc: 'Get exchange rate' }, { method: 'GET', path: '/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT', desc: 'Multiple rates' }, { method: 'GET', path: '/api/service/history?symbol=BTC&interval=60&limit=200', desc: 'Historical OHLC (minutes interval)' }, { method: 'GET', path: '/api/service/market-status', desc: 'Market overview' }, { method: 'GET', path: '/api/service/top?n=10', desc: 'Top cryptocurrencies' }, { method: 'GET', path: '/api/service/sentiment?symbol=BTC', desc: 'Get sentiment' }, { method: 'GET', path: '/api/service/whales?chain=ethereum&min_amount_usd=1000000', desc: 'Whale transactions (service)' }, { method: 'GET', path: '/api/service/onchain?address=0x...&chain=ethereum', desc: 'On-chain data (service)' }, { method: 'POST', path: '/api/service/query', desc: 'Universal query endpoint' } ], example: `// Get BTC price fetch('${baseUrl}/api/service/rate?pair=BTC/USDT') .then(res => res.json()) .then(data => console.log('BTC Price:', data.data.price)); // Get multiple prices fetch('${baseUrl}/api/service/rate/batch?pairs=BTC/USDT,ETH/USDT,BNB/USDT') .then(res => res.json()) .then(data => data.data.forEach(r => console.log(r.pair + ': $' + r.price)));` }, // ===== MARKET DATA ===== { name: 'Market Data API', category: 'Market Data', description: 'Real-time prices, OHLC/OHLCV, and market statistics', endpoints: [ { method: 'GET', path: '/api/market?limit=100', desc: 'Market data with prices' }, { method: 'GET', path: '/api/coins/top?limit=50', desc: 'Top coins by market cap' }, { method: 'GET', path: '/api/trending', desc: 'Trending cryptocurrencies' }, { method: 'GET', path: '/api/market/ohlc?symbol=BTC&timeframe=1h', desc: 'OHLC (multi-source, recommended)' }, { method: 'GET', path: '/api/ohlcv?symbol=BTC&timeframe=1h&limit=100', desc: 'OHLCV (query-style)' }, { method: 'GET', path: '/api/klines?symbol=BTCUSDT&interval=1h&limit=100', desc: 'Klines alias (Binance style)' }, { method: 'GET', path: '/api/historical?symbol=BTC&days=30', desc: 'Daily historical candles (alias)' } ], example: `// Get OHLCV data for charting fetch('${baseUrl}/api/ohlcv?symbol=BTC&timeframe=1h&limit=100') .then(res => res.json()) .then(data => { console.log('OHLCV data:', data.data); // Each candle: { timestamp, open, high, low, close, volume } });` }, // ===== NEWS ===== { name: 'News Aggregator API', category: 'News & Media', description: 'Crypto news from 9+ sources including RSS feeds', endpoints: [ { method: 'GET', path: '/api/news/latest?limit=20', desc: 'Latest crypto news' }, { method: 'GET', path: '/api/news?limit=20', desc: 'Alias for latest (compat)' } ], example: `// Get latest news fetch('${baseUrl}/api/news/latest?limit=10') .then(res => res.json()) .then(data => { data.articles.forEach(article => { console.log(article.title, '-', article.source); }); });` }, // ===== SENTIMENT ===== { name: 'Sentiment Analysis API', category: 'Sentiment', description: 'Fear & Greed Index, social sentiment, and AI-powered analysis', endpoints: [ { method: 'GET', path: '/api/sentiment/global', desc: 'Global market sentiment' }, { method: 'GET', path: '/api/fear-greed', desc: 'Fear & Greed Index (alias)' }, { method: 'GET', path: '/api/sentiment/asset/{symbol}', desc: 'Asset-specific sentiment' }, { method: 'POST', path: '/api/sentiment/analyze', desc: 'Analyze custom text' } ], example: `// Get Fear & Greed Index fetch('${baseUrl}/api/fear-greed') .then(res => res.json()) .then(data => { console.log('Fear & Greed:', data.value, '-', data.classification); }); // Analyze text sentiment fetch('${baseUrl}/api/sentiment/analyze', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: 'Bitcoin is going to the moon!', mode: 'crypto' }) }) .then(res => res.json()) .then(data => console.log('Sentiment:', data.sentiment, data.score));` }, // ===== ON-CHAIN ANALYTICS ===== { name: 'On-Chain Analytics API', category: 'Analytics', description: 'Blockchain data, whale tracking, and network statistics', endpoints: [ { method: 'GET', path: '/api/service/whales?chain=ethereum&min_amount_usd=1000000&limit=20', desc: 'Whale transactions (service)' }, { method: 'GET', path: '/api/service/onchain?address=0x...&chain=ethereum', desc: 'On-chain snapshot (service)' } ], example: `// Get whale transactions fetch('${baseUrl}/api/service/whales?chain=ethereum&min_amount_usd=1000000&limit=20') .then(res => res.json()) .then(data => console.log(data));` }, // ===== TECHNICAL ANALYSIS ===== { name: 'Technical Analysis API', category: 'Analysis Services', description: '5 analysis modes: Quick TA, Fundamental, On-Chain, Risk, Comprehensive', endpoints: [ { method: 'POST', path: '/api/technical/ta-quick', desc: 'Quick technical analysis' }, { method: 'POST', path: '/api/technical/fa-eval', desc: 'Fundamental evaluation' }, { method: 'POST', path: '/api/technical/onchain-health', desc: 'On-chain network health' }, { method: 'POST', path: '/api/technical/risk-assessment', desc: 'Risk & volatility assessment' }, { method: 'POST', path: '/api/technical/comprehensive', desc: 'Comprehensive analysis' } ], example: `// Quick Technical Analysis const ohlcv = await fetch('${baseUrl}/api/ohlcv?symbol=BTC&timeframe=4h&limit=200') .then(r => r.json()).then(d => d.data); fetch('${baseUrl}/api/technical/ta-quick', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol: 'BTC', timeframe: '4h', ohlcv: ohlcv }) }) .then(res => res.json()) .then(data => { console.log('Trend:', data.trend); console.log('RSI:', data.rsi); console.log('Entry Range:', data.entry_range); });` }, // ===== INDICATORS ===== { name: 'Indicator Services API', category: 'Analysis Services', description: 'Technical indicators (RSI, MACD, SMA/EMA, BB, ATR, StochRSI) + comprehensive signals', endpoints: [ { method: 'GET', path: '/api/indicators/services', desc: 'List available indicator services' }, { method: 'GET', path: '/api/indicators/rsi?symbol=BTC&timeframe=1h&period=14', desc: 'RSI' }, { method: 'GET', path: '/api/indicators/macd?symbol=BTC&timeframe=1h', desc: 'MACD' }, { method: 'GET', path: '/api/indicators/comprehensive?symbol=BTC&timeframe=1h', desc: 'Comprehensive indicator analysis' } ], example: `// List indicator services fetch('${baseUrl}/api/indicators/services') .then(r => r.json()) .then(console.log); // RSI fetch('${baseUrl}/api/indicators/rsi?symbol=BTC&timeframe=1h&period=14') .then(r => r.json()) .then(console.log);` }, // ===== AI MODELS ===== { name: 'AI Models API', category: 'AI Services', description: 'HuggingFace AI models for sentiment, analysis, and predictions', endpoints: [ { method: 'GET', path: '/api/models/status', desc: 'Models status' }, { method: 'GET', path: '/api/models/list', desc: 'List all models' }, { method: 'GET', path: '/api/models/summary', desc: 'Models grouped by category (frontend-ready)' }, { method: 'GET', path: '/api/models/health', desc: 'Model health check' }, { method: 'POST', path: '/api/models/reinitialize', desc: 'Reinitialize models (UI button)' }, { method: 'POST', path: '/api/ai/decision', desc: 'AI trading decision' } ], example: `// Get AI trading decision fetch('${baseUrl}/api/ai/decision', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol: 'BTC', horizon: 'swing', risk_tolerance: 'moderate' }) }) .then(res => res.json()) .then(data => { console.log('Decision:', data.decision); console.log('Confidence:', data.confidence); console.log('Signals:', data.signals); });` }, // ===== DEFI DATA ===== { name: 'DeFi Data API', category: 'DeFi Services', description: 'DefiLlama public endpoints (no API key): TVL, protocols, yields', endpoints: [ { method: 'GET', path: '/api/defi/tvl', desc: 'Total Value Locked' }, { method: 'GET', path: '/api/defi/protocols?limit=20', desc: 'Top DeFi protocols' }, { method: 'GET', path: '/api/defi/yields?limit=20', desc: 'DeFi yield pools' } ], example: `// Get DeFi TVL data fetch('${baseUrl}/api/defi/protocols?limit=10') .then(res => res.json()) .then(data => { (data.protocols || []).forEach(p => { console.log(p.name, '- TVL:', p.tvl); }); });` }, // ===== TRADING & BACKTESTING ===== { name: 'Trading & Backtesting API', category: 'Trading', description: 'Historical backtests and strategy runs (uses exchange/data fallbacks)', endpoints: [ { method: 'GET', path: '/api/trading/backtest/historical/BTCUSDT?timeframe=1h&days=30', desc: 'Historical candles for backtest' }, { method: 'GET', path: '/api/trading/backtest/run/BTCUSDT?strategy=sma_crossover&days=30&initial_capital=10000', desc: 'Run a backtest strategy' } ], example: `// Run SMA crossover backtest fetch('${baseUrl}/api/trading/backtest/run/BTCUSDT?strategy=sma_crossover&days=30&initial_capital=10000') .then(r => r.json()) .then(console.log);` }, // ===== RESOURCES & MONITORING ===== { name: 'Resources & Monitoring API', category: 'System Services', description: 'API resources, providers status, and system health', endpoints: [ { method: 'GET', path: '/api/resources/stats', desc: 'Resources statistics' }, { method: 'GET', path: '/api/resources/apis', desc: 'All APIs list' }, { method: 'GET', path: '/api/resources/summary', desc: 'Resources summary' }, { method: 'GET', path: '/api/providers', desc: 'Data providers list' }, { method: 'GET', path: '/api/status', desc: 'System status' }, { method: 'GET', path: '/api/health', desc: 'Health check' } ], example: `// Check system health fetch('${baseUrl}/api/health') .then(res => res.json()) .then(data => { console.log('Status:', data.status); console.log('Providers:', data.providers); }); // Get resources stats fetch('${baseUrl}/api/resources/stats') .then(res => res.json()) .then(data => { console.log('Total APIs:', data.total_functional); console.log('Success Rate:', data.success_rate + '%'); });` }, // ===== SUPPORT / DEBUG ===== { name: 'Support & Debug API', category: 'System Services', description: 'Client-accessible support files and real endpoint list', endpoints: [ { method: 'GET', path: '/api/support/realendpoints', desc: 'Endpoints list (JSON)' }, { method: 'GET', path: '/api/support/realendpoints?format=txt', desc: 'Endpoints list (TXT)' }, { method: 'GET', path: '/realendpoint.txt', desc: 'Download endpoints list (TXT)' }, { method: 'GET', path: '/api/support/fualt?tail=200', desc: 'Tail of fault log (JSON)' }, { method: 'GET', path: '/fualt.txt', desc: 'Download full fault log (TXT)' } ], example: `// Fetch tail of fualt.txt fetch('${baseUrl}/api/support/fualt?tail=200') .then(r => r.json()) .then(data => console.log(data.content));` } ]; } show() { if (this.modal) { this.modal.style.display = 'flex'; return; } this.modal = this.createModal(); document.body.appendChild(this.modal); } hide() { if (this.modal) { this.modal.style.display = 'none'; } } createModal() { const modal = document.createElement('div'); modal.className = 'config-helper-modal'; modal.innerHTML = `
Use this guide to integrate quickly. Every endpoint listed below exists in the server and is safe to copy.
${window.location.origin}
curl -s '${window.location.origin}/api/health' | jq .
fetch('${window.location.origin}/api/market?limit=10')
.then(r => r.json())
.then(console.log);
import requests
print(requests.get('${window.location.origin}/api/market?limit=10', timeout=10).json())
export HF_TOKEN='YOUR_TOKEN_HERE'
${service.description}
${ep.path}
${ep.desc}
${this.escapeHtml(service.example)}