fix(api): migrate fmp routes to stable endpoints

This commit is contained in:
root 2026-05-05 23:21:27 +00:00
parent 0c0cc93f57
commit 160920ea07

View File

@ -2873,7 +2873,7 @@ RULES:
const symbol = String(req.query.symbol || '').trim().toUpperCase();
if (!symbol) return res.status(400).json({ error: 'symbol required' });
const apiKey = await getUserFmpApiKey(authUserId);
const url = `https://financialmodelingprep.com/api/v3/profile/${symbol}?apikey=${apiKey}`;
const url = `https://financialmodelingprep.com/stable/profile?symbol=${encodeURIComponent(symbol)}&apikey=${apiKey}`;
const data = await fetchFmpJson(url) as any;
res.json(Array.isArray(data) ? data[0] ?? {} : data);
} catch (error: any) {
@ -2895,7 +2895,7 @@ RULES:
const symbol = String(req.query.symbol || '').trim().toUpperCase();
if (!symbol) return res.status(400).json({ error: 'symbol required' });
const apiKey = await getUserFmpApiKey(authUserId);
const url = `https://financialmodelingprep.com/api/v3/key-metrics/${symbol}?limit=4&apikey=${apiKey}`;
const url = `https://financialmodelingprep.com/stable/key-metrics?symbol=${encodeURIComponent(symbol)}&limit=4&apikey=${apiKey}`;
const data = await fetchFmpJson(url) as any;
res.json(Array.isArray(data) ? data[0] ?? {} : data);
} catch (error: any) {
@ -2917,7 +2917,7 @@ RULES:
const symbol = String(req.query.symbol || '').trim().toUpperCase();
if (!symbol) return res.status(400).json({ error: 'symbol required' });
const apiKey = await getUserFmpApiKey(authUserId);
const url = `https://financialmodelingprep.com/api/v3/historical/earning_calendar/${symbol}?limit=8&apikey=${apiKey}`;
const url = `https://financialmodelingprep.com/stable/earnings-calendar?symbol=${encodeURIComponent(symbol)}&limit=8&apikey=${apiKey}`;
const data = await fetchFmpJson(url) as any;
res.json({ earnings: Array.isArray(data) ? data : [] });
} catch (error: any) {
@ -2954,7 +2954,7 @@ RULES:
qs.set('limit', String(Math.min(100, Number(req.query.limit) || 50)));
qs.set('apikey', apiKey);
qs.set('isEtf', 'false');
const url = `https://financialmodelingprep.com/api/v3/stock-screener?${qs.toString()}`;
const url = `https://financialmodelingprep.com/stable/company-screener?${qs.toString()}`;
const data = await fetchFmpJson(url) as any;
res.json({ results: Array.isArray(data) ? data : [] });
} catch (error: any) {