fix(api): migrate fmp routes to stable endpoints
This commit is contained in:
parent
0c0cc93f57
commit
160920ea07
@ -2873,7 +2873,7 @@ RULES:
|
|||||||
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
||||||
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
||||||
const apiKey = await getUserFmpApiKey(authUserId);
|
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;
|
const data = await fetchFmpJson(url) as any;
|
||||||
res.json(Array.isArray(data) ? data[0] ?? {} : data);
|
res.json(Array.isArray(data) ? data[0] ?? {} : data);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -2895,7 +2895,7 @@ RULES:
|
|||||||
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
||||||
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
||||||
const apiKey = await getUserFmpApiKey(authUserId);
|
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;
|
const data = await fetchFmpJson(url) as any;
|
||||||
res.json(Array.isArray(data) ? data[0] ?? {} : data);
|
res.json(Array.isArray(data) ? data[0] ?? {} : data);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -2917,7 +2917,7 @@ RULES:
|
|||||||
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
const symbol = String(req.query.symbol || '').trim().toUpperCase();
|
||||||
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
if (!symbol) return res.status(400).json({ error: 'symbol required' });
|
||||||
const apiKey = await getUserFmpApiKey(authUserId);
|
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;
|
const data = await fetchFmpJson(url) as any;
|
||||||
res.json({ earnings: Array.isArray(data) ? data : [] });
|
res.json({ earnings: Array.isArray(data) ? data : [] });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -2954,7 +2954,7 @@ RULES:
|
|||||||
qs.set('limit', String(Math.min(100, Number(req.query.limit) || 50)));
|
qs.set('limit', String(Math.min(100, Number(req.query.limit) || 50)));
|
||||||
qs.set('apikey', apiKey);
|
qs.set('apikey', apiKey);
|
||||||
qs.set('isEtf', 'false');
|
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;
|
const data = await fetchFmpJson(url) as any;
|
||||||
res.json({ results: Array.isArray(data) ? data : [] });
|
res.json({ results: Array.isArray(data) ? data : [] });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user