Loading live system stats...

1. Quick Start (3 steps)

Every example uses your current origin. Replace BASE if you call from another app.

const BASE = window.location.origin; // e.g. https://really-amin-datasourceforcryptocurrency-2.hf.space

// Step 1 — Is the server alive?
const health = await fetch(`${BASE}/health`).then(r => r.json());
console.log(health.status); // "healthy"

// Step 2 — Dashboard numbers (cards on home page)
const dash = await fetch(`${BASE}/api/dashboard/overview`).then(r => r.json());
console.log(dash.cards);

// Step 3 — Analyze one sentence
const sentiment = await fetch(`${BASE}/api/sentiment`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ text: 'Bitcoin looks bullish today' })
}).then(r => r.json());
console.log(sentiment.sentiment, sentiment.confidence);

Python: use requests.get(BASE + "/health") the same way. Always set timeout=30 on HF Spaces.

2. Discovery & Health

Find every endpoint before you integrate.

MethodPathWhat you get
GET/healthSimple alive check (also /api/health)
GET/api/statusProvider connectivity probe
GET/api/system/statusFull system drawer data (pools, models, keys)
GET/api/endpointsGrouped list of all routes
GET/api/routersWhich routers are loaded
GET/api/uptime/probeProbe 12 critical endpoints
GET/docsInteractive Swagger UI
curl "%BASE%/api/endpoints"
curl "%BASE%/api/routers"

3. Dashboard API

The home dashboard reads one endpoint for all hero cards.

MethodPathResponse highlights
GET/api/dashboard/overviewcards: resources, API keys, models v2+v4, rotation pools
GET/api/resources/summaryRegistry totals and categories
GET/api/models/summaryModels by category + v4 complement block
const overview = await fetch(`${BASE}/api/dashboard/overview`).then(r => r.json());
// cards.total_resources, cards.api_keys_env, cards.api_keys_file
// cards.models_loaded_v2, cards.models_loaded_v4, cards.pools_healthy

4. Market Data

Prices, top coins, OHLCV. Automatic fallback: local → Binance → v4 complement → cache.

MethodPathParameters
GET/api/market?limit=50Top market rows for dashboard table
GET/api/coins/top?limit=50Top coins by market cap
GET/api/trendingTrending coins
GET/api/ohlcv?symbol=BTC&timeframe=1h&limit=100Candles for charts
GET/api/klines?symbol=BTCUSDT&interval=1h&limit=100Binance-style alias
GET/api/market/gainers?limit=20Top gainers (with fallbacks)
GET/api/market/losers?limit=20Top losers
// Market table data
const market = await fetch(`${BASE}/api/market?limit=20`).then(r => r.json());

// OHLCV for TradingView-style charts
const ohlcv = await fetch(`${BASE}/api/ohlcv?symbol=BTC&timeframe=1h&limit=200`).then(r => r.json());

5. Sentiment & Fear/Greed

MethodPathBody / notes
GET/api/fear-greed?limit=30Fear & Greed index + history
GET/api/sentiment/globalGlobal market mood
GET/api/sentiment/asset/BTCPer-asset sentiment
POST/api/sentiment{"text":"..."} — v2 then v4 fallback
POST/api/sentiment/analyze{"text":"...","mode":"crypto"}
POST/api/hf/run-sentiment{"texts":["sentence 1"]} — must be array
// Fear & Greed (dashboard chart)
const fng = await fetch(`${BASE}/api/fear-greed?limit=30`).then(r => r.json());

// Text sentiment
const result = await fetch(`${BASE}/api/sentiment`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ text: 'ETH breaking resistance, very bullish' })
}).then(r => r.json());

6. AI Models (Hugging Face)

v2 loads models locally when possible. v4 complement adds more models via Inference API when v2 is exhausted.

MethodPathPurpose
GET/api/models/summaryBest for UI — categories + v4 block
GET/api/models/statusRegistry status, models_loaded
GET/api/models/listFull catalog
GET/api/models/healthPer-model health entries
GET/api/hf/modelsAlias → models list
GET/api/hf/healthHF connectivity check
POST/api/models/reinitializeWarm models again
POST/api/ai/decision{"symbol":"BTC","horizon":"swing"}
const summary = await fetch(`${BASE}/api/models/summary`).then(r => r.json());
console.log('v2 loaded:', summary.summary?.loaded_models);
console.log('v4 loaded:', summary.complement_v4?.loaded);

// HF sentiment batch (texts must be an array)
await fetch(`${BASE}/api/hf/run-sentiment`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ texts: ['BTC pump incoming'] })
});

Set Space secret HF_TOKEN and variable HF_MODE=auth for gated models. v4 Space uses Inference API when local torch is unavailable.

7. API Keys, Resources & Rotation

Keys come from HF Secrets (env) plus inline keys in config/api_keys.json. Rotation uses api-resources/crypto_resources_unified_2025-11-11.json (10 pools).

Recommended Space secrets

  • CRYPTOCOMPARE_API_KEY, COINMARKETCAP_KEY_1, COINMARKETCAP_KEY_2
  • ETHERSCAN_KEY_1, ETHERSCAN_KEY_2, BSCSCAN_API_KEY, TRONSCAN_API_KEY
  • NEWSAPI_KEY, HF_TOKEN, COINGECKO_API_KEY (optional)
MethodPathPurpose
GET/api/resources/rotation/health10 pools + env key probe
GET/api/resources/rotationFull rotation status
GET/api/resources/fallback-chainsFailover chain JSON
GET/api/resources/summaryRegistry + key counts
GET/api/providersNamed provider list
GET/api/complement/v4/statusv4 Space health
const rotation = await fetch(`${BASE}/api/resources/rotation/health`).then(r => r.json());
console.log(rotation.pools_healthy, '/', rotation.pools_total);
console.log('Env keys:', rotation.env_keys?.configured);

8. News

MethodPathNotes
GET/api/news/latest?limit=20Latest crypto news
GET/api/news?limit=20Alias
const news = await fetch(`${BASE}/api/news/latest?limit=10`).then(r => r.json());
(news.articles || news.news || []).forEach(a => console.log(a.title));

9. Indicators & Technical Analysis

MethodPathNotes
GET/api/indicators/servicesList indicator services
GET/api/indicators/rsi?symbol=BTC&timeframe=1hRSI
GET/api/indicators/macd?symbol=BTC&timeframe=1hMACD
GET/api/indicators/comprehensive?symbol=BTCMulti-indicator bundle
POST/api/technical/ta-quickBody: symbol, timeframe, ohlcv array
POST/api/technical/comprehensiveCombined TA + FA + on-chain
const ohlcv = await fetch(`${BASE}/api/ohlcv?symbol=BTC&timeframe=4h&limit=200`).then(r => r.json());
const ta = await fetch(`${BASE}/api/technical/ta-quick`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ symbol: 'BTC', timeframe: '4h', ohlcv: ohlcv.data })
}).then(r => r.json());

10. v4 Complement Space

Secondary Space: https://really-amin-datasourceforcryptocurrency-4.hf.space. v2 calls it when local providers or models are exhausted.

  • v2 POST /api/sentiment → local model → v4 → lexical fallback
  • v2 /api/models/summary includes complement_v4 counts
  • v4 runs HF Inference API with HF_MODE=auth when torch is unavailable
const v4 = await fetch(`${BASE}/api/complement/v4/status`).then(r => r.json());
console.log(v4.probe); // endpoints_ok, healthy

11. Errors & Tips

  1. 404 on route — Check /api/endpoints or /docs; path may differ from old docs.
  2. 503 on market — CoinGecko rate limit; retry or use /api/market (Binance fallback).
  3. 422 on sentiment/api/hf/run-sentiment requires {"texts":["..."]} (array), not a single string.
  4. Empty models — Call POST /api/models/reinitialize or wait for lazy load; check HF_TOKEN.
  5. Space sleeping — First request may take 30–60s; increase client timeout.
  6. Hard refresh UICtrl+Shift+R after deploys.

Diagnostic checklist

curl "%BASE%/health"
curl "%BASE%/api/dashboard/overview"
curl "%BASE%/api/resources/rotation/health"
curl "%BASE%/api/models/summary"

HTTP only required. WebSocket endpoints are optional; the dashboard polls REST every 30 seconds. For interactive testing, open /docs or click the green ? floating button on the dashboard.