Endpoints¶
Referência completa. Todos os endpoints /api/* exigem X-API-Key. Endpoints /admin/* exigem X-Admin-Secret.
📡 Sinais (EA consome)¶
GET /api/scan¶
Retorna 1 sinal por slot (símbolo × TF) — o mais recente.
Query params:
min_confidence(float, default 0.0) — filtro mínimo
Headers: X-API-Key
Response:
{
"items": [
{
"symbol": "EURUSD",
"timeframe": "H1",
"signal": "BUY",
"confidence": 0.67,
"prob_buy": 0.55,
"prob_sell": 0.20,
"prob_no": 0.25,
"regime": "trend_up",
"expected_rr": 1.85,
"ts": "2026-05-27T14:00:00Z",
"model_v": "lgbm_EURUSD_H1_v85b52764"
}
],
"plan_tier": "pro",
"filtered_by_plan": false
}
Filtragem por plano:
basic→ só EURUSD/GBPUSD/XAUUSD em H1/H4pro/owner→ todos os ativos × TFs
GET /api/signals/{symbol}/{tf}¶
Histórico de sinais de 1 slot.
Query params:
limit(int, default 200, max 1000)
Response:
[
{
"ts": "2026-05-27T14:00:00Z",
"signal": "BUY",
"confidence": 0.67,
"regime": "trend_up",
"expected_rr": 1.85
},
...
]
GET /api/history/predictions¶
Predições agregadas (estatísticas, não dados brutos).
Query params:
symbol,tf_code,days(default 7),limit(default 500)
💼 Execuções (EA reporta)¶
POST /api/executions¶
EA reporta abertura/fechamento de posição.
Headers: X-API-Key (chave do assinante)
Body:
{
"pred_id": 12345,
"ticket": 987654321,
"symbol": "EURUSD",
"timeframe": "H1",
"signal": "BUY",
"confidence": 0.67,
"opened_at": "2026-05-27T10:23:00Z",
"closed_at": "2026-05-27T12:45:00Z",
"entry_price": 1.0823,
"exit_price": 1.0851,
"pnl": 12.45,
"result": "TP"
}
Idempotente por ticket. Reenvio atualiza closed_at/exit_price/pnl/result.
Response 201:
action é "updated" em retransmissões.
👤 Account (Frontend /minha-conta)¶
GET /api/account/me¶
Metadados da chave + status do EA.
Response:
{
"plan_tier": "pro",
"user_name": "João Silva",
"email": "joao@exemplo.com",
"expires_at": "2026-06-27T00:00:00Z",
"days_remaining": 30,
"symbols_allowed": null,
"tfs_allowed": null,
"rate_limit_per_min": 300,
"last_seen_at": "2026-05-27T14:35:00Z",
"ea_status": {
"status": "online",
"label": "Online",
"online": true,
"mins_since": 0.5
},
"api_key_hint": "xxxxxxxx…",
"is_owner_env": false,
"created_at": "2026-05-25T03:14:00Z"
}
GET /api/account/signals¶
Sinais visíveis para a chave (respeita symbols_allowed / tfs_allowed).
Query params:
days(1-90, default 7)limit(1-500, default 50)include_no_trade(bool, default false)
Response:
{
"count": 28,
"days": 7,
"signals": [
{
"symbol": "EURUSD",
"timeframe": "H1",
"signal": "BUY",
"confidence": 0.67,
"prob_buy": 0.55,
"prob_sell": 0.20,
"prob_no": 0.25,
"regime": "trend_up",
"expected_rr": 1.85,
"ts": "2026-05-27T14:00:00Z",
"created_at": "2026-05-27T14:00:15Z",
"model_v": "lgbm_EURUSD_H1_v85b52764"
}
]
}
GET /api/account/executions¶
Operações do EA do assinante + agregados (PF, win rate).
Query params:
days(1-365, default 30)limit(1-1000, default 100)
Response:
{
"executions": [
{
"exec_id": 4567,
"ticket": 987654321,
"symbol": "EURUSD",
"timeframe": "H1",
"signal": "BUY",
"confidence": 0.67,
"opened_at": "2026-05-27T10:23:00Z",
"closed_at": "2026-05-27T12:45:00Z",
"entry_price": 1.0823,
"exit_price": 1.0851,
"pnl": 12.45,
"result": "TP"
}
],
"summary": {
"days": 30,
"n_total": 42,
"n_closed": 38,
"n_wins": 22,
"n_losses": 16,
"win_rate_pct": 57.9,
"profit_factor": 1.43,
"total_pnl": 287.50,
"gross_profit": 412.30,
"gross_loss": 124.80
}
}
POST /api/account/regenerate-key¶
Gera nova UUID, revoga a anterior imediatamente.
Headers: X-API-Key (a chave atual)
Response:
{
"ok": true,
"key_id": 42,
"api_key": "newxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"rotated_at": "2026-05-27T14:40:00Z",
"warning": "A chave anterior foi revogada. Atualize InpApiKey no EA imediatamente."
}
Email automático em background com a nova chave.
📊 EA Status¶
GET /api/ea-status¶
Diagnóstico completo do EA do assinante.
Response:
{
"online": true,
"last_heartbeat": "2026-05-27T14:35:00Z",
"mins_since": 0.5,
"account": {
"name": "João",
"tier": "pro"
},
"slot_coverage": {
"expected": 56,
"active": 54,
"pct": 96.4
},
"recent_signals_24h": 28,
"lag_minutes": 3.5
}
🔍 Health & Status¶
GET /api/health¶
Status geral do sistema. Sem autenticação.
Response 200 ou 503:
{
"status": "ok",
"api_version": "2.0.0",
"db": "ok",
"last_prediction": "2026-05-27T14:35:00Z",
"last_candle": "2026-05-27T14:30:00Z",
"pred_lag_minutes": 3.5,
"btc_lag_minutes": 4.1,
"stale_pred_count": 17,
"total_active_slots": 40,
"reasons": null
}
status: "degraded" ou "down" retorna 503 (UptimeRobot alerta).
GET /api/status¶
Status detalhado (auth requerida).
🏆 Performance¶
GET /api/performance¶
Track record por símbolo/TF/modelo nos últimos N dias.
Query params:
days(default 30),symbol(opcional),tf_code(opcional)
📐 Calibration¶
GET /api/calibration¶
ECE e Brier por modelo. Usado pelo dashboard /ops.
🎓 Models¶
GET /api/models¶
Lista todos os champions ativos (cached no startup).
Response:
{
"count": 56,
"models": [
{
"symbol": "EURUSD",
"tf_code": "H1",
"model_v": "lgbm_EURUSD_H1_v85b52764",
"auc_wf": 0.621,
"pf_wf": 1.42,
"is_active": true,
"trained_at": "2026-05-25T03:14:00Z"
}
]
}
🌐 Public¶
GET /api/public/stats¶
Estatísticas agregadas, sem autenticação. Usado pela landing page.
Response:
{
"active_models": 71,
"total_signals_24h": 142,
"directional_signals_24h": 18,
"monitored_pairs": 14,
"uptime_pct_30d": 99.8
}
🔐 Admin¶
POST /admin/keys¶
Cria nova chave de assinante.
Headers: X-Admin-Secret
Body:
{
"user_name": "João",
"email": "joao@email.com",
"plan_tier": "pro",
"expires_at": "2026-06-27T00:00:00Z",
"notes": "Criado via admin manual"
}
Response 201:
{
"key_id": 42,
"api_key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"plan_tier": "pro",
"_ea_config": {
"InpApiUrl": "https://api.quantfx.com.br",
"InpApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
GET /admin/keys¶
Lista todas as chaves (active e inactive). Mascarada na resposta.
DELETE /admin/keys/{key_id}¶
Revoga (active=FALSE).
GET /admin/monitoring-data¶
Dashboard /ops data: EA health, signals dist, feature health, models 24h.
🪝 Webhook¶
POST /webhooks/eduzz¶
Recebe eventos Eduzz com HMAC-SHA256 validation. Ver Webhooks.