File size: 7,005 Bytes
8b7b267 ca2386d 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 19eb917 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 fd96bce 8b7b267 ca2386d 8b7b267 19eb917 8b7b267 72ac106 8b7b267 |
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 |
/**
* Configuration for API endpoints
* This file provides exports for the old api-client.js
* @version 2025-12-04
*/
// API Keys
export const API_KEYS = {
// Never hardcode secrets in client-side code.
ETHERSCAN: '',
ETHERSCAN_BACKUP: '',
BSCSCAN: '',
TRONSCAN: '',
CMC: '',
CMC_BACKUP: '',
NEWSAPI: '',
CRYPTOCOMPARE: '',
HUGGINGFACE: ''
};
// Backend API Endpoints (HuggingFace Space)
export const API_BASE_URL = window.location.origin;
// Complete API Endpoints mapping
export const API_ENDPOINTS = {
// Health & Status
health: '/api/health',
status: '/api/status',
routers: '/api/routers',
monitoring: '/api/monitoring/status',
// Market Data
rate: '/api/service/rate',
rateBatch: '/api/service/rate/batch',
coinsTop: '/api/coins/top',
trending: '/api/trending',
market: '/api/market',
marketTop: '/api/market/top',
marketTrending: '/api/market/trending',
history: '/api/service/history',
ohlc: '/api/market/ohlc',
// Sentiment & AI
sentimentGlobal: '/api/sentiment/global',
sentimentAsset: '/api/sentiment/asset',
sentimentAnalyze: '/api/service/sentiment',
aiSignals: '/api/ai/signals',
aiDecision: '/api/ai/decision',
// News
news: '/api/news',
newsLatest: '/api/news/latest',
// Models
modelsList: '/api/models/list',
modelsStatus: '/api/models/status',
modelsSummary: '/api/models/summary',
modelsHealth: '/api/models/health',
modelsTest: '/api/models/test',
modelsReinitialize: '/api/models/reinitialize',
// Trading
ohlcv: '/api/ohlcv',
backtest: '/api/trading/backtest',
futuresPositions: '/api/futures/positions',
// Technical Analysis
technicalQuick: '/api/technical/quick',
technicalComprehensive: '/api/technical/comprehensive',
technicalRisk: '/api/technical/risk',
// Resources
resources: '/api/resources',
resourcesSummary: '/api/resources/summary',
resourcesStats: '/api/resources/stats',
resourcesCategories: '/api/resources/categories',
resourcesCategory: '/api/resources/category',
resourcesApis: '/api/resources/apis',
providers: '/api/providers',
// Support / Debug (client-consumable)
supportFualt: '/api/support/fualt',
supportRealEndpoints: '/api/support/realendpoints',
// Advanced
multiSourceData: '/api/multi-source/data',
sourcesAll: '/api/sources/all',
testSource: '/api/test-source',
// External APIs (for reference)
external: {
coingecko: {
baseUrl: 'https://api.coingecko.com/api/v3',
endpoints: {
simplePrice: '/simple/price',
coins: '/coins',
trending: '/search/trending',
global: '/global'
}
},
coinmarketcap: {
baseUrl: 'https://pro-api.coinmarketcap.com/v1',
key: API_KEYS.CMC,
endpoints: {
quotes: '/cryptocurrency/quotes/latest',
listings: '/cryptocurrency/listings/latest'
}
},
binance: {
baseUrl: 'https://api.binance.com/api/v3',
endpoints: {
ticker: '/ticker/price',
ticker24hr: '/ticker/24hr',
klines: '/klines'
}
},
alternativeMe: {
baseUrl: 'https://api.alternative.me',
endpoints: {
fng: '/fng'
}
},
etherscan: {
baseUrl: 'https://api.etherscan.io/api',
key: API_KEYS.ETHERSCAN,
endpoints: {
balance: '?module=account&action=balance',
txlist: '?module=account&action=txlist'
}
},
bscscan: {
baseUrl: 'https://api.bscscan.com/api',
key: API_KEYS.BSCSCAN,
endpoints: {
balance: '?module=account&action=balance',
txlist: '?module=account&action=txlist'
}
},
tronscan: {
baseUrl: 'https://apilist.tronscanapi.com/api',
key: API_KEYS.TRONSCAN,
endpoints: {
account: '/account',
transactions: '/transaction'
}
}
}
};
// Page metadata for navigation
export const PAGE_METADATA = [
{ page: 'dashboard', title: 'Dashboard | Crypto Hub', icon: 'dashboard' },
{ page: 'market', title: 'Market Data | Crypto Hub', icon: 'trending_up' },
{ page: 'models', title: 'AI Models | Crypto Hub', icon: 'psychology' },
{ page: 'sentiment', title: 'Sentiment Analysis | Crypto Hub', icon: 'sentiment_satisfied' },
{ page: 'ai-analyst', title: 'AI Analyst | Crypto Hub', icon: 'smart_toy' },
{ page: 'trading-assistant', title: 'Trading Assistant | Crypto Hub', icon: 'show_chart' },
{ page: 'news', title: 'Crypto News | Crypto Hub', icon: 'article' },
{ page: 'providers', title: 'API Providers | Crypto Hub', icon: 'cloud' },
{ page: 'diagnostics', title: 'System Diagnostics | Crypto Hub', icon: 'monitor_heart' },
{ page: 'api-explorer', title: 'API Explorer | Crypto Hub', icon: 'code' }
];
// Polling intervals (milliseconds)
export const POLLING_INTERVALS = {
health: 30000, // 30 seconds
market: 10000, // 10 seconds
sentiment: 60000, // 1 minute
news: 300000, // 5 minutes
models: 60000 // 1 minute
};
// Cache TTL (milliseconds)
export const CACHE_TTL = {
health: 10000, // 10 seconds
market: 30000, // 30 seconds
sentiment: 60000, // 1 minute
news: 300000, // 5 minutes
static: 3600000 // 1 hour
};
// API configuration
export const API_CONFIG = {
timeout: 10000,
retries: 3,
cacheTimeout: 60000, // 1 minute
corsProxies: [
// Disabled on Hugging Face Spaces (avoid third-party proxy dependencies)
]
};
// Detect environment
const IS_HUGGINGFACE = window.location.hostname.includes('hf.space') || window.location.hostname.includes('huggingface.co');
const IS_LOCALHOST = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
// CONFIG object for api-client.js compatibility
export const CONFIG = {
API_BASE_URL: window.location.origin,
API_TIMEOUT: 10000,
CACHE_TTL: 60000,
MAX_RETRIES: 3,
RETRY_DELAY: 1000,
RETRIES: 3,
// UI defaults (used by shared components like toast)
TOAST: {
MAX_VISIBLE: 3,
DEFAULT_DURATION: 3500,
ERROR_DURATION: 6000
},
IS_HUGGINGFACE: IS_HUGGINGFACE,
IS_LOCALHOST: IS_LOCALHOST,
ENVIRONMENT: IS_HUGGINGFACE ? 'huggingface' : IS_LOCALHOST ? 'local' : 'production'
};
// Export CONFIG to window for non-module scripts
if (typeof window !== 'undefined') {
window.CONFIG = CONFIG;
}
// Helper function to build API URLs
export function buildApiUrl(endpoint, params = {}) {
const base = CONFIG.API_BASE_URL;
let url = `${base}${endpoint}`;
if (Object.keys(params).length > 0) {
const queryString = new URLSearchParams(params).toString();
url += (url.includes('?') ? '&' : '?') + queryString;
}
return url;
}
// Helper function to get cache key
export function getCacheKey(endpoint, params = {}) {
return `${endpoint}:${JSON.stringify(params)}`;
}
// Export default configuration
export default {
CONFIG,
API_KEYS,
API_ENDPOINTS,
PAGE_METADATA,
API_CONFIG,
buildApiUrl,
getCacheKey
};
|