fmp-node-api 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -72
- package/dist/index.d.mts +908 -508
- package/dist/index.d.ts +908 -508
- package/dist/index.js +608 -240
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +606 -237
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
|
|
3
3
|
// src/client.ts
|
|
4
|
+
function unwrapSingleObject(data) {
|
|
5
|
+
if (Array.isArray(data) && data.length === 1) {
|
|
6
|
+
return data[0];
|
|
7
|
+
}
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
4
10
|
var FMPClient = class {
|
|
5
11
|
constructor(config) {
|
|
6
12
|
this.apiKey = config.apiKey;
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
this.v3Client = this.createClient("https://financialmodelingprep.com/api/v3", config.timeout);
|
|
14
|
+
this.v4Client = this.createClient("https://financialmodelingprep.com/api/v4", config.timeout);
|
|
15
|
+
this.stableClient = this.createClient(
|
|
16
|
+
"https://financialmodelingprep.com/api/stable",
|
|
17
|
+
config.timeout
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
createClient(baseURL, timeout) {
|
|
21
|
+
const client = axios.create({
|
|
22
|
+
baseURL,
|
|
23
|
+
timeout: timeout || 1e4,
|
|
24
|
+
headers: { "Content-Type": "application/json" }
|
|
14
25
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
apikey: this.apiKey
|
|
19
|
-
};
|
|
20
|
-
return config2;
|
|
26
|
+
client.interceptors.request.use((config) => {
|
|
27
|
+
config.params = { ...config.params, apikey: this.apiKey };
|
|
28
|
+
return config;
|
|
21
29
|
});
|
|
30
|
+
return client;
|
|
22
31
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
async get(endpoint, params) {
|
|
32
|
+
// Standard get method - returns raw API response
|
|
33
|
+
async get(endpoint, version = "v3", params) {
|
|
34
|
+
const client = this.getClientForVersion(version);
|
|
27
35
|
try {
|
|
28
|
-
const response = await
|
|
36
|
+
const response = await client.get(endpoint, { params });
|
|
29
37
|
return {
|
|
30
38
|
success: true,
|
|
31
39
|
data: response.data,
|
|
@@ -39,15 +47,14 @@ var FMPClient = class {
|
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
async post(endpoint, data, config) {
|
|
50
|
+
// Get method for single-object endpoints - unwraps single-item arrays
|
|
51
|
+
async getSingle(endpoint, version = "v3", params) {
|
|
52
|
+
const client = this.getClientForVersion(version);
|
|
46
53
|
try {
|
|
47
|
-
const response = await
|
|
54
|
+
const response = await client.get(endpoint, { params });
|
|
48
55
|
return {
|
|
49
56
|
success: true,
|
|
50
|
-
data: response.data,
|
|
57
|
+
data: unwrapSingleObject(response.data),
|
|
51
58
|
status: response.status
|
|
52
59
|
};
|
|
53
60
|
} catch (error) {
|
|
@@ -58,11 +65,17 @@ var FMPClient = class {
|
|
|
58
65
|
};
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
getClientForVersion(version) {
|
|
69
|
+
switch (version) {
|
|
70
|
+
case "v3":
|
|
71
|
+
return this.v3Client;
|
|
72
|
+
case "v4":
|
|
73
|
+
return this.v4Client;
|
|
74
|
+
case "stable":
|
|
75
|
+
return this.stableClient;
|
|
76
|
+
default:
|
|
77
|
+
return this.v3Client;
|
|
78
|
+
}
|
|
66
79
|
}
|
|
67
80
|
};
|
|
68
81
|
|
|
@@ -75,36 +88,22 @@ var FMPError = class extends Error {
|
|
|
75
88
|
this.name = "FMPError";
|
|
76
89
|
}
|
|
77
90
|
};
|
|
91
|
+
|
|
92
|
+
// src/utils/validation.ts
|
|
78
93
|
function validateApiKey(apiKey) {
|
|
79
|
-
if (!apiKey || typeof apiKey !== "string") {
|
|
80
|
-
throw new FMPError("API key is required and must be a string");
|
|
94
|
+
if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
|
|
95
|
+
throw new FMPError("API key is required and must be a non-empty string");
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
function validateSymbol(symbol) {
|
|
84
|
-
if (!symbol || typeof symbol !== "string") {
|
|
85
|
-
throw new FMPError("Symbol is required and must be a string");
|
|
99
|
+
if (!symbol || typeof symbol !== "string" || symbol.trim().length === 0) {
|
|
100
|
+
throw new FMPError("Symbol is required and must be a non-empty string");
|
|
86
101
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Period2["QUARTER"] = "quarter";
|
|
93
|
-
return Period2;
|
|
94
|
-
})(Period || {});
|
|
95
|
-
var Exchange = /* @__PURE__ */ ((Exchange2) => {
|
|
96
|
-
Exchange2["NYSE"] = "NYSE";
|
|
97
|
-
Exchange2["NASDAQ"] = "NASDAQ";
|
|
98
|
-
Exchange2["AMEX"] = "AMEX";
|
|
99
|
-
Exchange2["TSX"] = "TSX";
|
|
100
|
-
Exchange2["LSE"] = "LSE";
|
|
101
|
-
return Exchange2;
|
|
102
|
-
})(Exchange || {});
|
|
103
|
-
|
|
104
|
-
// src/utils/validation.ts
|
|
105
|
-
function validateApiKey2(apiKey) {
|
|
106
|
-
if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
|
|
107
|
-
throw new FMPError("API key is required and must be a non-empty string");
|
|
102
|
+
const symbolRegex = /^[A-Z0-9.-]+$/;
|
|
103
|
+
if (!symbolRegex.test(symbol.toUpperCase())) {
|
|
104
|
+
throw new FMPError(
|
|
105
|
+
"Invalid symbol format. Symbols should contain only letters, numbers, dots, and hyphens"
|
|
106
|
+
);
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
function validateDate(date) {
|
|
@@ -143,68 +142,59 @@ var StockEndpoints = class {
|
|
|
143
142
|
}
|
|
144
143
|
/**
|
|
145
144
|
* Get real-time stock quote
|
|
145
|
+
* https://site.financialmodelingprep.com/developer/docs#full-quote-quote
|
|
146
|
+
* @param symbol - The stock symbol to get the quote for
|
|
147
|
+
* @returns This endpoint gives you the latest bid and ask prices for a stock, as well as the volume and last trade price in real time.
|
|
146
148
|
*/
|
|
147
149
|
async getQuote({ symbol }) {
|
|
148
|
-
return this.client.
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Get company profile
|
|
152
|
-
*/
|
|
153
|
-
async getCompanyProfile({ symbol }) {
|
|
154
|
-
return this.client.get(`/profile/${symbol}`);
|
|
150
|
+
return this.client.getSingle(`/quote/${symbol}`, "v3");
|
|
155
151
|
}
|
|
156
152
|
/**
|
|
157
153
|
* Get historical stock prices
|
|
154
|
+
* https://site.financialmodelingprep.com/developer/docs#daily-chart-charts
|
|
155
|
+
* @param symbol - The stock symbol to get the historical prices for
|
|
156
|
+
* @param from - The start date to get the historical prices for
|
|
157
|
+
* @param to - The end date to get the historical prices for
|
|
158
|
+
* @returns The FMP Daily Chart endpoint provides daily stock data for a specified company, including opening, high, low, and closing prices, with a default limit of 5 years of historical data. To access data beyond this limit, use the from and to parameters for custom date ranges, each with a 5-year limit
|
|
158
159
|
*/
|
|
159
160
|
async getHistoricalPrice({
|
|
160
161
|
symbol,
|
|
161
162
|
from,
|
|
162
163
|
to
|
|
163
164
|
}) {
|
|
164
|
-
const params =
|
|
165
|
-
if (from) params.
|
|
166
|
-
if (to) params.
|
|
167
|
-
|
|
168
|
-
return this.client.get(
|
|
169
|
-
`/historical-price-full/${symbol}${queryString ? `?${queryString}` : ""}`
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Get list of all stocks
|
|
174
|
-
*/
|
|
175
|
-
async getStockList() {
|
|
176
|
-
return this.client.get("/stock/list");
|
|
165
|
+
const params = {};
|
|
166
|
+
if (from) params.from = from;
|
|
167
|
+
if (to) params.to = to;
|
|
168
|
+
return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
|
|
177
169
|
}
|
|
178
170
|
/**
|
|
179
|
-
* Get market
|
|
171
|
+
* Get market cap
|
|
172
|
+
* https://site.financialmodelingprep.com/developer/docs#market-cap-company-information
|
|
173
|
+
* @param symbol - The stock symbol to get the market cap for
|
|
174
|
+
* @returns The FMP Market Cap endpoint provides the current market capitalization of a company. Market cap is a measure of the size and relative importance of a company in the stock market. It is calculated by multiplying the current share price by the number of outstanding shares.
|
|
180
175
|
*/
|
|
181
176
|
async getMarketCap({ symbol }) {
|
|
182
|
-
return this.client.
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get earnings calendar
|
|
186
|
-
*/
|
|
187
|
-
async getEarningsCalendar(params) {
|
|
188
|
-
const queryParams = {};
|
|
189
|
-
if (params.from) queryParams.from = params.from;
|
|
190
|
-
if (params.to) queryParams.to = params.to;
|
|
191
|
-
return this.client.get("/earning_calendar", queryParams);
|
|
177
|
+
return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
|
|
192
178
|
}
|
|
193
179
|
/**
|
|
194
180
|
* Get stock splits
|
|
181
|
+
* https://site.financialmodelingprep.com/developer/docs#splits-historical-splits
|
|
182
|
+
* @param symbol - The stock symbol to get the splits for
|
|
183
|
+
* @returns A list of historical stock splits for publicly traded companies, including the date of the stock split, the split ratio, and the type of stock split.
|
|
195
184
|
*/
|
|
196
185
|
async getStockSplits({ symbol }) {
|
|
197
|
-
return this.client.get(`/
|
|
186
|
+
return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
|
|
198
187
|
}
|
|
199
188
|
/**
|
|
200
189
|
* Get dividend history
|
|
190
|
+
* https://site.financialmodelingprep.com/developer/docs#dividends-historical-dividends
|
|
191
|
+
* @param symbol - The stock symbol to get the dividend history for
|
|
192
|
+
* @returns A list of historical dividend payments for publicly traded companies, including the date of the dividend payment, the ex-dividend date, and the dividend per share.
|
|
201
193
|
*/
|
|
202
|
-
async getDividendHistory({
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
data: response.success && response.data && Array.isArray(response.data.historical) ? response.data.historical : []
|
|
207
|
-
};
|
|
194
|
+
async getDividendHistory({
|
|
195
|
+
symbol
|
|
196
|
+
}) {
|
|
197
|
+
return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
|
|
208
198
|
}
|
|
209
199
|
};
|
|
210
200
|
|
|
@@ -215,63 +205,190 @@ var FinancialEndpoints = class {
|
|
|
215
205
|
}
|
|
216
206
|
/**
|
|
217
207
|
* Get income statement
|
|
208
|
+
* https://site.financialmodelingprep.com/developer/docs#income-statements-financial-statements
|
|
209
|
+
* @param symbol - The stock symbol to get the income statement for
|
|
210
|
+
* @param period - The period to get the income statement for (annual or quarter)
|
|
211
|
+
* @param limit - The number of periods to get
|
|
212
|
+
* @returns FMP's Income Statement API provides access to real-time income statement data for a wide range of companies, including public companies, private companies, and ETFs. This data can be used to track a company's profitability over time, to compare a company to its competitors, and to identify trends in a company's business.
|
|
218
213
|
*/
|
|
219
214
|
async getIncomeStatement({
|
|
220
215
|
symbol,
|
|
221
216
|
period = "annual",
|
|
222
217
|
limit = 5
|
|
223
218
|
}) {
|
|
224
|
-
return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}
|
|
219
|
+
return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
225
220
|
}
|
|
226
221
|
/**
|
|
227
222
|
* Get balance sheet
|
|
223
|
+
* https://site.financialmodelingprep.com/developer/docs#balance-sheet-statements-financial-statements
|
|
224
|
+
* @param symbol - The stock symbol to get the balance sheet for
|
|
225
|
+
* @param period - The period to get the balance sheet for (annual or quarter)
|
|
226
|
+
* @param limit - The number of periods to get
|
|
227
|
+
* @returns The balance sheet is a financial statement that displays a company's total assets, liabilities, and shareholder equity over a specific timeframe (quarterly or yearly). Investors can use this statement to determine if the company can fund its operations, meet its debt obligations, and pay a dividend.
|
|
228
228
|
*/
|
|
229
229
|
async getBalanceSheet({
|
|
230
230
|
symbol,
|
|
231
231
|
period = "annual",
|
|
232
232
|
limit = 5
|
|
233
233
|
}) {
|
|
234
|
-
return this.client.get(
|
|
234
|
+
return this.client.get(
|
|
235
|
+
`/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`,
|
|
236
|
+
"v3"
|
|
237
|
+
);
|
|
235
238
|
}
|
|
236
239
|
/**
|
|
237
240
|
* Get cash flow statement
|
|
241
|
+
* https://site.financialmodelingprep.com/developer/docs#cashflow-statements-financial-statements
|
|
242
|
+
* @param symbol - The stock symbol to get the cash flow statement for
|
|
243
|
+
* @param period - The period to get the cash flow statement for (annual or quarter)
|
|
244
|
+
* @param limit - The number of periods to get
|
|
245
|
+
* @returns The cash flow statement is a financial statement that highlights how cash moves through the company, including both cash inflows and outflows. This statement shows the cash flows in 3 main categories "Operating Cash Flows", "Investing Cash Flows", and "Financing Cash Flows", which help investors to understand if the company is making money or losing money by conducting business.
|
|
238
246
|
*/
|
|
239
247
|
async getCashFlowStatement({
|
|
240
248
|
symbol,
|
|
241
249
|
period = "annual",
|
|
242
250
|
limit = 5
|
|
243
251
|
}) {
|
|
244
|
-
return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}
|
|
252
|
+
return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
245
253
|
}
|
|
246
254
|
/**
|
|
247
255
|
* Get key metrics
|
|
256
|
+
* https://site.financialmodelingprep.com/developer/docs#key-metrics-statement-analysis
|
|
257
|
+
* @param symbol - The stock symbol to get the key metrics for
|
|
258
|
+
* @param period - The period to get the key metrics for (annual or quarter)
|
|
259
|
+
* @param limit - The number of periods to get
|
|
260
|
+
* @returns Get key financial metrics for a company, including revenue, net income, and price-to-earnings ratio (P/E ratio). Assess a company's financial performance and compare it to its competitors.
|
|
248
261
|
*/
|
|
249
262
|
async getKeyMetrics({
|
|
250
263
|
symbol,
|
|
251
264
|
period = "annual",
|
|
252
265
|
limit = 5
|
|
253
266
|
}) {
|
|
254
|
-
return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}
|
|
267
|
+
return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
255
268
|
}
|
|
256
269
|
/**
|
|
257
270
|
* Get financial ratios
|
|
271
|
+
* https://site.financialmodelingprep.com/developer/docs#ratios-statement-analysis
|
|
272
|
+
* @param symbol - The stock symbol to get the financial ratios for
|
|
273
|
+
* @param period - The period to get the financial ratios for (annual or quarter)
|
|
274
|
+
* @param limit - The number of periods to get
|
|
275
|
+
* @returns Get financial ratios for a company, such as the P/B ratio and the ROE. Assess a company's financial health and compare it to its competitors.
|
|
258
276
|
*/
|
|
259
277
|
async getFinancialRatios({
|
|
260
278
|
symbol,
|
|
261
279
|
period = "annual",
|
|
262
280
|
limit = 5
|
|
263
281
|
}) {
|
|
264
|
-
return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}
|
|
282
|
+
return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
265
283
|
}
|
|
266
284
|
/**
|
|
267
285
|
* Get enterprise value
|
|
286
|
+
* https://site.financialmodelingprep.com/developer/docs#enterprise-values-statement-analysis
|
|
287
|
+
* @param symbol - The stock symbol to get the enterprise value for
|
|
288
|
+
* @param period - The period to get the enterprise value for (annual or quarter)
|
|
289
|
+
* @param limit - The number of periods to get
|
|
290
|
+
* @returns Get the enterprise value of a company, which is the total value of a company, including its equity and debt. Assess a company's overall value and compare it to its peers.
|
|
268
291
|
*/
|
|
269
292
|
async getEnterpriseValue({
|
|
270
293
|
symbol,
|
|
271
294
|
period = "annual",
|
|
272
295
|
limit = 5
|
|
273
296
|
}) {
|
|
274
|
-
return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}
|
|
297
|
+
return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get cashflow growth
|
|
301
|
+
* https://site.financialmodelingprep.com/developer/docs#cashflow-growth-statement-analysis
|
|
302
|
+
* @param symbol - The stock symbol to get the cashflow growth for
|
|
303
|
+
* @param period - The period to get the cashflow growth for (annual or quarter)
|
|
304
|
+
* @param limit - The number of periods to get
|
|
305
|
+
* @returns Get the cash flow growth rate for a company. Measure how quickly a company's cash flow is growing.
|
|
306
|
+
*/
|
|
307
|
+
async getCashflowGrowth({
|
|
308
|
+
symbol,
|
|
309
|
+
period = "annual",
|
|
310
|
+
limit = 5
|
|
311
|
+
}) {
|
|
312
|
+
return this.client.get(
|
|
313
|
+
`/cash-flow-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
314
|
+
"v3"
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get income growth
|
|
319
|
+
* https://site.financialmodelingprep.com/developer/docs#income-growth-statement-analysis
|
|
320
|
+
* @param symbol - The stock symbol to get the income growth for
|
|
321
|
+
* @param period - The period to get the income growth for (annual or quarter)
|
|
322
|
+
* @param limit - The number of periods to get
|
|
323
|
+
* @returns Get the income growth rate for a company. Measure how quickly a company's income is growing.
|
|
324
|
+
*/
|
|
325
|
+
async getIncomeGrowth({
|
|
326
|
+
symbol,
|
|
327
|
+
period = "annual",
|
|
328
|
+
limit = 5
|
|
329
|
+
}) {
|
|
330
|
+
return this.client.get(
|
|
331
|
+
`/income-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
332
|
+
"v3"
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get balance sheet growth
|
|
337
|
+
* https://site.financialmodelingprep.com/developer/docs#balance-sheet-growth-statement-analysis
|
|
338
|
+
* @param symbol - The stock symbol to get the balance sheet growth for
|
|
339
|
+
* @param period - The period to get the balance sheet growth for (annual or quarter)
|
|
340
|
+
* @param limit - The number of periods to get
|
|
341
|
+
* @returns Get the balance sheet growth rate for a company. Measure how quickly a company's assets and liabilities are growing.
|
|
342
|
+
*/
|
|
343
|
+
async getBalanceSheetGrowth({
|
|
344
|
+
symbol,
|
|
345
|
+
period = "annual",
|
|
346
|
+
limit = 5
|
|
347
|
+
}) {
|
|
348
|
+
return this.client.get(
|
|
349
|
+
`/balance-sheet-statement-growth/${symbol}?period=${period}&limit=${limit}`,
|
|
350
|
+
"v3"
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Get financial growth
|
|
355
|
+
* https://site.financialmodelingprep.com/developer/docs#financial-growth-statement-analysis
|
|
356
|
+
* @param symbol - The stock symbol to get the financial growth for
|
|
357
|
+
* @param period - The period to get the financial growth for (annual or quarter)
|
|
358
|
+
* @param limit - The number of periods to get
|
|
359
|
+
* @returns Financial Growth Get the financial growth rate for a company. Measure how quickly a company's overall financial performance is improving.
|
|
360
|
+
*/
|
|
361
|
+
async getFinancialGrowth({
|
|
362
|
+
symbol,
|
|
363
|
+
period = "annual",
|
|
364
|
+
limit = 5
|
|
365
|
+
}) {
|
|
366
|
+
return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Get earnings historical
|
|
370
|
+
* https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings
|
|
371
|
+
* @param symbol - The stock symbol to get the earnings historical for
|
|
372
|
+
* @param limit - The number of periods to get
|
|
373
|
+
* @returns A list of historical & upcoming earnings announcements for a specific company, including the date, estimated EPS, and actual EPS.
|
|
374
|
+
*/
|
|
375
|
+
async getEarningsHistorical({
|
|
376
|
+
symbol,
|
|
377
|
+
limit = 5
|
|
378
|
+
}) {
|
|
379
|
+
return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Get earnings surprises
|
|
383
|
+
* https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings
|
|
384
|
+
* @param symbol - The stock symbol to get the earnings surprises for
|
|
385
|
+
* @param limit - The number of periods to get
|
|
386
|
+
* @returns A list of earnings announcements for publicly traded companies that were either positive or negative surprises. This endpoint includes the date of the earnings announcement, the estimated EPS, the actual EPS, and the earnings surprise.
|
|
387
|
+
*/
|
|
388
|
+
async getEarningsSurprises({
|
|
389
|
+
symbol
|
|
390
|
+
}) {
|
|
391
|
+
return this.client.get(`/earnings-surprises/${symbol}`, "v3");
|
|
275
392
|
}
|
|
276
393
|
};
|
|
277
394
|
|
|
@@ -281,59 +398,44 @@ var ForexEndpoints = class {
|
|
|
281
398
|
this.client = client;
|
|
282
399
|
}
|
|
283
400
|
/**
|
|
284
|
-
* Get
|
|
401
|
+
* Get forex quote
|
|
402
|
+
* @param params - Parameters for the forex quote request
|
|
403
|
+
* @returns Forex quote data
|
|
285
404
|
*/
|
|
286
405
|
async getQuote(params) {
|
|
287
|
-
return this.client.get(
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Get historical forex data
|
|
291
|
-
*/
|
|
292
|
-
async getHistoricalPrice(params) {
|
|
293
|
-
const queryParams = {};
|
|
294
|
-
if (params.from) queryParams.from = params.from;
|
|
295
|
-
if (params.to) queryParams.to = params.to;
|
|
296
|
-
if (params.timeseries) queryParams.timeseries = params.timeseries;
|
|
297
|
-
return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
|
|
406
|
+
return this.client.get("/quote", "v3", params);
|
|
298
407
|
}
|
|
299
408
|
/**
|
|
300
|
-
* Get
|
|
301
|
-
*
|
|
409
|
+
* Get historical forex prices
|
|
410
|
+
* @param symbol - The forex symbol to get the historical prices for
|
|
411
|
+
* @param from - The start date to get the historical prices for
|
|
412
|
+
* @param to - The end date to get the historical prices for
|
|
413
|
+
* @returns Historical forex price data
|
|
302
414
|
*/
|
|
303
|
-
async
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
return {
|
|
314
|
-
...response,
|
|
315
|
-
data: Array.isArray(response.data) ? response.data : Array.isArray(response.data?.forexList) ? response.data.forexList : []
|
|
316
|
-
};
|
|
317
|
-
} catch (error) {
|
|
318
|
-
return {
|
|
319
|
-
success: false,
|
|
320
|
-
error: "Failed to fetch forex pairs",
|
|
321
|
-
status: 500,
|
|
322
|
-
data: []
|
|
323
|
-
};
|
|
324
|
-
}
|
|
415
|
+
async getHistoricalPrice({
|
|
416
|
+
symbol,
|
|
417
|
+
from,
|
|
418
|
+
to
|
|
419
|
+
}) {
|
|
420
|
+
const params = {};
|
|
421
|
+
if (from) params.from = from;
|
|
422
|
+
if (to) params.to = to;
|
|
423
|
+
return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
|
|
325
424
|
}
|
|
326
425
|
/**
|
|
327
|
-
* Get forex rates for a specific currency
|
|
426
|
+
* Get forex rates for a specific base currency
|
|
427
|
+
* @param baseCurrency - The base currency to get forex rates for
|
|
428
|
+
* @returns Forex rates data
|
|
328
429
|
*/
|
|
329
430
|
async getForexRates(baseCurrency = "USD") {
|
|
330
|
-
return this.client.get(`/forex/${baseCurrency}
|
|
431
|
+
return this.client.get(`/forex/${baseCurrency}`, "v3");
|
|
331
432
|
}
|
|
332
433
|
/**
|
|
333
|
-
* Get forex rates
|
|
434
|
+
* Get all forex rates
|
|
435
|
+
* @returns All forex rates data
|
|
334
436
|
*/
|
|
335
437
|
async getAllForexRates() {
|
|
336
|
-
return this.client.get("/forex");
|
|
438
|
+
return this.client.get("/forex", "v3");
|
|
337
439
|
}
|
|
338
440
|
};
|
|
339
441
|
|
|
@@ -343,26 +445,31 @@ var CryptoEndpoints = class {
|
|
|
343
445
|
this.client = client;
|
|
344
446
|
}
|
|
345
447
|
/**
|
|
346
|
-
* Get
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Get historical crypto data
|
|
448
|
+
* Get crypto quote
|
|
449
|
+
* https://site.financialmodelingprep.com/developer/docs#full-quote-crypto
|
|
450
|
+
* @param symbol - The crypto symbol to get the quote for
|
|
451
|
+
* @returns Crypto quote data
|
|
353
452
|
*/
|
|
354
|
-
async
|
|
355
|
-
|
|
356
|
-
if (params.from) queryParams.from = params.from;
|
|
357
|
-
if (params.to) queryParams.to = params.to;
|
|
358
|
-
if (params.timeseries) queryParams.timeseries = params.timeseries;
|
|
359
|
-
return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
|
|
453
|
+
async getQuote({ symbol }) {
|
|
454
|
+
return this.client.getSingle(`/quote/${symbol}`, "v3");
|
|
360
455
|
}
|
|
361
456
|
/**
|
|
362
|
-
* Get
|
|
457
|
+
* Get historical crypto prices
|
|
458
|
+
* https://site.financialmodelingprep.com/developer/docs#cryptocurrency-daily-crypto
|
|
459
|
+
* @param symbol - The crypto symbol to get the historical prices for
|
|
460
|
+
* @param from - The start date to get the historical prices for
|
|
461
|
+
* @param to - The end date to get the historical prices for
|
|
462
|
+
* @returns Provides daily price data for all cryptocurrencies that are traded on exchanges around the world.
|
|
363
463
|
*/
|
|
364
|
-
async
|
|
365
|
-
|
|
464
|
+
async getHistoricalPrice({
|
|
465
|
+
symbol,
|
|
466
|
+
from,
|
|
467
|
+
to
|
|
468
|
+
}) {
|
|
469
|
+
const params = {};
|
|
470
|
+
if (from) params.from = from;
|
|
471
|
+
if (to) params.to = to;
|
|
472
|
+
return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
|
|
366
473
|
}
|
|
367
474
|
};
|
|
368
475
|
|
|
@@ -372,31 +479,78 @@ var ETFEndpoints = class {
|
|
|
372
479
|
this.client = client;
|
|
373
480
|
}
|
|
374
481
|
/**
|
|
375
|
-
* Get
|
|
482
|
+
* Get ETF holding dates
|
|
483
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings
|
|
484
|
+
* @param symbol - The symbol of the ETF to get the holding dates for
|
|
485
|
+
* @returns The FMP ETF Holding Dates endpoint provides a list of the dates on which ETF holdings are updated. For example, an investor may want to know when an ETF's holdings are updated in order to make sure that they are still aligned with their investment goals.
|
|
376
486
|
*/
|
|
377
|
-
async
|
|
378
|
-
|
|
487
|
+
async getHoldingDates({ symbol }) {
|
|
488
|
+
const params = {};
|
|
489
|
+
if (symbol) params.symbol = symbol;
|
|
490
|
+
return this.client.get("/etf-holdings/portfolio-date", "v4", params);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Get ETF holdings
|
|
494
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings
|
|
495
|
+
* @param symbol - The symbol of the ETF to get the holdings for
|
|
496
|
+
* @param date - The date to get the holdings for
|
|
497
|
+
* @returns The FMP ETF Holdings endpoint provides a list of all the institutional investors that own shares of an ETF. For example, an investor may want to know which ETF has the highest exposure to a particular industry or sector.
|
|
498
|
+
*/
|
|
499
|
+
async getHoldings({
|
|
500
|
+
symbol,
|
|
501
|
+
date
|
|
502
|
+
}) {
|
|
503
|
+
const params = {};
|
|
504
|
+
if (symbol) params.symbol = symbol;
|
|
505
|
+
if (date) params.date = date;
|
|
506
|
+
return this.client.get("/etf-holdings", "v4", params);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Get ETF holder
|
|
510
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings
|
|
511
|
+
* @param symbol - The symbol of the ETF to get the holder for
|
|
512
|
+
* @returns This endpoint returns all stocks held by a specific ETF. Assets, share number, and weight are among the fields returned. For example you can get components of SPY, VOO and more.
|
|
513
|
+
*/
|
|
514
|
+
async getHolder({ symbol }) {
|
|
515
|
+
return this.client.get(`/etf-holder/${symbol}`, "v3");
|
|
379
516
|
}
|
|
380
517
|
/**
|
|
381
518
|
* Get ETF profile
|
|
519
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings
|
|
520
|
+
* @param symbol - The symbol of the ETF to get the profile for
|
|
521
|
+
* @returns The FMP ETF Information endpoint provides basic information about an ETF, such as its ticker symbol, name, expense ratio, and asset under management. For example, an investor may want to compare the expense ratios of different ETFs to find the one that is most cost-effective.
|
|
382
522
|
*/
|
|
383
|
-
async getProfile(
|
|
384
|
-
|
|
523
|
+
async getProfile({ symbol }) {
|
|
524
|
+
const params = {};
|
|
525
|
+
if (symbol) params.symbol = symbol;
|
|
526
|
+
return this.client.getSingle("/etf-info", "v4", params);
|
|
385
527
|
}
|
|
386
528
|
/**
|
|
387
|
-
* Get ETF
|
|
529
|
+
* Get ETF sector weighting
|
|
530
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings
|
|
531
|
+
* @param symbol - The symbol of the ETF to get the sector exposure for
|
|
532
|
+
* @returns The FMP ETF Sector Weighting endpoint provides a breakdown of the percentage of an ETF's assets that are invested in each sector. For example, an investor may want to invest in an ETF that has a high exposure to the technology sector if they believe that the technology sector is poised for growth.
|
|
388
533
|
*/
|
|
389
|
-
async
|
|
390
|
-
|
|
391
|
-
if (params.limit) queryParams.limit = params.limit;
|
|
392
|
-
if (params.page) queryParams.page = params.page;
|
|
393
|
-
return this.client.get(`/etf-holder/${params.symbol}`, queryParams);
|
|
534
|
+
async getSectorWeighting({ symbol }) {
|
|
535
|
+
return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
|
|
394
536
|
}
|
|
395
537
|
/**
|
|
396
|
-
* Get
|
|
538
|
+
* Get ETF country weighting
|
|
539
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings
|
|
540
|
+
* @param symbol - The symbol of the ETF to get the country weighting for
|
|
541
|
+
* @returns The FMP ETF Country Weighting endpoint provides a breakdown of the percentage of an ETF's assets that are invested in each country. For example, an investor may want to invest in an ETF that has a high exposure to China if they believe that the Chinese economy is poised for growth.
|
|
397
542
|
*/
|
|
398
|
-
async
|
|
399
|
-
return this.client.get(
|
|
543
|
+
async getCountryWeighting({ symbol }) {
|
|
544
|
+
return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Get ETF Stock exposure
|
|
548
|
+
* https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings
|
|
549
|
+
* @param symbol - The symbol of the ETF to get the stock exposure for
|
|
550
|
+
* @returns This endpoint returns asset exposure from all ETFs that have it in their holdings. It has properties like market value, share number or weight percentage. It can be useful for looking up stock you like to check what ETF has it on their portfolio.
|
|
551
|
+
*/
|
|
552
|
+
async getStockExposure({ symbol }) {
|
|
553
|
+
return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
|
|
400
554
|
}
|
|
401
555
|
};
|
|
402
556
|
|
|
@@ -406,31 +560,24 @@ var MutualFundEndpoints = class {
|
|
|
406
560
|
this.client = client;
|
|
407
561
|
}
|
|
408
562
|
/**
|
|
409
|
-
* Get
|
|
563
|
+
* Get mutual fund quote
|
|
564
|
+
* @param params - Parameters for the mutual fund quote request
|
|
565
|
+
* @returns Mutual fund quote data
|
|
410
566
|
*/
|
|
411
567
|
async getQuote(params) {
|
|
412
|
-
return this.client.get(
|
|
568
|
+
return this.client.get("/quote", "v3", params);
|
|
413
569
|
}
|
|
414
570
|
/**
|
|
415
571
|
* Get mutual fund profile
|
|
416
572
|
*/
|
|
417
573
|
async getProfile(params) {
|
|
418
|
-
return this.client.get(
|
|
574
|
+
return this.client.get("/profile", "v3", params);
|
|
419
575
|
}
|
|
420
576
|
/**
|
|
421
577
|
* Get mutual fund holdings
|
|
422
578
|
*/
|
|
423
579
|
async getHoldings(params) {
|
|
424
|
-
|
|
425
|
-
if (params.limit) queryParams.limit = params.limit;
|
|
426
|
-
if (params.page) queryParams.page = params.page;
|
|
427
|
-
return this.client.get(`/mutual-fund-holder/${params.symbol}`, queryParams);
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Get list of all mutual funds
|
|
431
|
-
*/
|
|
432
|
-
async getMutualFundList() {
|
|
433
|
-
return this.client.get("/mutual-fund/list");
|
|
580
|
+
return this.client.get("/holdings", "v3", params);
|
|
434
581
|
}
|
|
435
582
|
};
|
|
436
583
|
|
|
@@ -440,26 +587,29 @@ var BondEndpoints = class {
|
|
|
440
587
|
this.client = client;
|
|
441
588
|
}
|
|
442
589
|
/**
|
|
443
|
-
* Get
|
|
590
|
+
* Get bond quote
|
|
591
|
+
* @param params - Parameters for the bond quote request
|
|
592
|
+
* @returns Bond quote data
|
|
444
593
|
*/
|
|
445
594
|
async getQuote(params) {
|
|
446
|
-
return this.client.get(
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Get historical bond data
|
|
450
|
-
*/
|
|
451
|
-
async getHistoricalPrice(params) {
|
|
452
|
-
const queryParams = {};
|
|
453
|
-
if (params.from) queryParams.from = params.from;
|
|
454
|
-
if (params.to) queryParams.to = params.to;
|
|
455
|
-
if (params.timeseries) queryParams.timeseries = params.timeseries;
|
|
456
|
-
return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
|
|
595
|
+
return this.client.get("/quote", "v3", params);
|
|
457
596
|
}
|
|
458
597
|
/**
|
|
459
|
-
* Get
|
|
598
|
+
* Get historical bond prices
|
|
599
|
+
* @param symbol - The bond symbol to get the historical prices for
|
|
600
|
+
* @param from - The start date to get the historical prices for
|
|
601
|
+
* @param to - The end date to get the historical prices for
|
|
602
|
+
* @returns Historical bond price data
|
|
460
603
|
*/
|
|
461
|
-
async
|
|
462
|
-
|
|
604
|
+
async getHistoricalPrice({
|
|
605
|
+
symbol,
|
|
606
|
+
from,
|
|
607
|
+
to
|
|
608
|
+
}) {
|
|
609
|
+
const params = {};
|
|
610
|
+
if (from) params.from = from;
|
|
611
|
+
if (to) params.to = to;
|
|
612
|
+
return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
|
|
463
613
|
}
|
|
464
614
|
};
|
|
465
615
|
|
|
@@ -472,46 +622,31 @@ var EconomicEndpoints = class {
|
|
|
472
622
|
* Get treasury rates
|
|
473
623
|
*/
|
|
474
624
|
async getTreasuryRates(params = {}) {
|
|
475
|
-
|
|
476
|
-
if (params.from) queryParams.from = params.from;
|
|
477
|
-
if (params.to) queryParams.to = params.to;
|
|
478
|
-
return this.client.get("/treasury-rates", queryParams);
|
|
625
|
+
return this.client.get("/treasury-rates", "v3", params);
|
|
479
626
|
}
|
|
480
627
|
/**
|
|
481
628
|
* Get federal funds rate
|
|
482
629
|
*/
|
|
483
630
|
async getFederalFundsRate(params = {}) {
|
|
484
|
-
|
|
485
|
-
if (params.from) queryParams.from = params.from;
|
|
486
|
-
if (params.to) queryParams.to = params.to;
|
|
487
|
-
return this.client.get("/federal-funds-rate", queryParams);
|
|
631
|
+
return this.client.get("/federal-funds-rate", "v3", params);
|
|
488
632
|
}
|
|
489
633
|
/**
|
|
490
634
|
* Get CPI data
|
|
491
635
|
*/
|
|
492
636
|
async getCPI(params = {}) {
|
|
493
|
-
|
|
494
|
-
if (params.from) queryParams.from = params.from;
|
|
495
|
-
if (params.to) queryParams.to = params.to;
|
|
496
|
-
return this.client.get("/economic-indicator/cpi", queryParams);
|
|
637
|
+
return this.client.get("/economic/cpi", "v3", params);
|
|
497
638
|
}
|
|
498
639
|
/**
|
|
499
640
|
* Get GDP data
|
|
500
641
|
*/
|
|
501
642
|
async getGDP(params = {}) {
|
|
502
|
-
|
|
503
|
-
if (params.from) queryParams.from = params.from;
|
|
504
|
-
if (params.to) queryParams.to = params.to;
|
|
505
|
-
return this.client.get("/economic-indicator/gdp", queryParams);
|
|
643
|
+
return this.client.get("/economic/gdp", "v3", params);
|
|
506
644
|
}
|
|
507
645
|
/**
|
|
508
646
|
* Get unemployment data
|
|
509
647
|
*/
|
|
510
648
|
async getUnemployment(params = {}) {
|
|
511
|
-
|
|
512
|
-
if (params.from) queryParams.from = params.from;
|
|
513
|
-
if (params.to) queryParams.to = params.to;
|
|
514
|
-
return this.client.get("/economic-indicator/unemployment", queryParams);
|
|
649
|
+
return this.client.get("/economic/unemployment", "v3", params);
|
|
515
650
|
}
|
|
516
651
|
};
|
|
517
652
|
|
|
@@ -524,63 +659,282 @@ var MarketEndpoints = class {
|
|
|
524
659
|
* Get market hours
|
|
525
660
|
*/
|
|
526
661
|
async getMarketHours() {
|
|
527
|
-
return this.client.get("/market-hours");
|
|
662
|
+
return this.client.get("/market-hours", "v3");
|
|
528
663
|
}
|
|
529
664
|
/**
|
|
530
665
|
* Get market performance
|
|
531
666
|
*/
|
|
532
667
|
async getMarketPerformance() {
|
|
533
|
-
return this.client.get("/market-performance");
|
|
668
|
+
return this.client.get("/market-performance", "v3");
|
|
534
669
|
}
|
|
535
670
|
/**
|
|
536
|
-
* Get
|
|
671
|
+
* Get top gainers
|
|
672
|
+
* https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview
|
|
673
|
+
* @returns The FMP Market Biggest Gainers endpoint provides a list of the stocks that have gained the most value on a given day. This information can be used by investors to identify stocks that are momentum and to potential investment opportunities.
|
|
537
674
|
*/
|
|
538
675
|
async getGainers() {
|
|
539
|
-
return this.client.get("/gainers");
|
|
676
|
+
return this.client.get("/stock_market/gainers", "v3");
|
|
540
677
|
}
|
|
541
678
|
/**
|
|
542
|
-
* Get
|
|
679
|
+
* Get top losers
|
|
680
|
+
* https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview
|
|
681
|
+
* @returns The FMP Market Biggest Losers endpoint provides a list of the stocks that have lost the most value on a given day. This information can be used by investors to identify stocks that are underperforming and to potential trading opportunities.
|
|
543
682
|
*/
|
|
544
683
|
async getLosers() {
|
|
545
|
-
return this.client.get("/losers");
|
|
684
|
+
return this.client.get("/stock_market/losers", "v3");
|
|
546
685
|
}
|
|
547
686
|
/**
|
|
548
687
|
* Get most active stocks
|
|
549
688
|
*/
|
|
550
689
|
async getMostActive() {
|
|
551
|
-
return this.client.get("/
|
|
690
|
+
return this.client.get("/stock_market/actives", "v3");
|
|
552
691
|
}
|
|
553
692
|
/**
|
|
554
693
|
* Get sector performance
|
|
694
|
+
* https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview
|
|
695
|
+
* @returns The FMP Sector Performance endpoint provides the performance of each sector of the stock market over a specified period of time. This information can be used by investors to identify sectors that are outperforming or underperforming the market.
|
|
555
696
|
*/
|
|
556
697
|
async getSectorPerformance() {
|
|
557
|
-
return this.client.get("/sector-performance");
|
|
698
|
+
return this.client.get("/sector-performance", "v3");
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Get market indices
|
|
702
|
+
* https://site.financialmodelingprep.com/developer/docs#market-index-market-overview
|
|
703
|
+
* @returns The FMP Market Index endpoint provides a list of all the major stock market indices, such as the S&P 500, the Dow Jones Industrial Average, and the Nasdaq Composite Index. This information can be used by investors to track the performance of the overall stock market and to identify sectors and industries that are outperforming or underperforming the market.
|
|
704
|
+
*/
|
|
705
|
+
async getMarketIndex() {
|
|
706
|
+
return this.client.get("/quotes/index", "v3");
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// src/endpoints/list.ts
|
|
711
|
+
var ListEndpoints = class {
|
|
712
|
+
constructor(client) {
|
|
713
|
+
this.client = client;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Get stock list
|
|
717
|
+
* https://site.financialmodelingprep.com/developer/docs#symbol-list-stock-list
|
|
718
|
+
* @returns The stock list
|
|
719
|
+
*/
|
|
720
|
+
async getStockList() {
|
|
721
|
+
return this.client.get("/stock/list");
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Get ETF list
|
|
725
|
+
* https://site.financialmodelingprep.com/developer/docs#exchange-traded-fund-search-stock-list
|
|
726
|
+
* @returns The ETF list
|
|
727
|
+
*/
|
|
728
|
+
async getETFList() {
|
|
729
|
+
return this.client.get("/etf/list");
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Get crypto list
|
|
733
|
+
* https://site.financialmodelingprep.com/developer/docs#cryptocurrencies-list-crypto
|
|
734
|
+
* @returns The crypto list
|
|
735
|
+
*/
|
|
736
|
+
async getCryptoList() {
|
|
737
|
+
return this.client.get("/symbol/available-cryptocurrencies");
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Get forex list
|
|
741
|
+
* https://site.financialmodelingprep.com/developer/docs#forex-list-forex
|
|
742
|
+
* @returns The forex list
|
|
743
|
+
*/
|
|
744
|
+
async getForexList() {
|
|
745
|
+
return this.client.get("/symbol/available-forex-currency-pairs");
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Get available indexes list
|
|
749
|
+
* https://site.financialmodelingprep.com/developer/docs#available-indexes
|
|
750
|
+
* @returns The available indexes list
|
|
751
|
+
*/
|
|
752
|
+
async getAvailableIndexes() {
|
|
753
|
+
return this.client.get("/symbol/available-indexes");
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
// src/endpoints/calendar.ts
|
|
758
|
+
var CalendarEndpoints = class {
|
|
759
|
+
constructor(client) {
|
|
760
|
+
this.client = client;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Get earnings calendar
|
|
764
|
+
* https://site.financialmodelingprep.com/developer/docs#earnings-calendar-earnings
|
|
765
|
+
* @param from - The start date to get the earnings calendar for
|
|
766
|
+
* @param to - The end date to get the earnings calendar for
|
|
767
|
+
* @returns The earnings calendar
|
|
768
|
+
*/
|
|
769
|
+
async getEarningsCalendar({ from, to } = {}) {
|
|
770
|
+
const params = {};
|
|
771
|
+
if (from) params.from = from;
|
|
772
|
+
if (to) params.to = to;
|
|
773
|
+
return this.client.get("/earning_calendar", "v3", params);
|
|
558
774
|
}
|
|
559
775
|
/**
|
|
560
|
-
* Get
|
|
776
|
+
* Get dividends calendar
|
|
777
|
+
* https://site.financialmodelingprep.com/developer/docs#dividends-calendar-dividends
|
|
778
|
+
* @param from - The start date to get the dividends calendar for
|
|
779
|
+
* @param to - The end date to get the dividends calendar for
|
|
780
|
+
* @returns The dividends calendar
|
|
561
781
|
*/
|
|
562
|
-
async
|
|
563
|
-
const
|
|
564
|
-
if (
|
|
565
|
-
if (
|
|
566
|
-
return this.client.get("/
|
|
782
|
+
async getDividendsCalendar({ from, to } = {}) {
|
|
783
|
+
const params = {};
|
|
784
|
+
if (from) params.from = from;
|
|
785
|
+
if (to) params.to = to;
|
|
786
|
+
return this.client.get("/stock_dividend_calendar", "v3", params);
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Get economics calendar
|
|
790
|
+
* https://site.financialmodelingprep.com/developer/docs#economics-calendar-economics-data
|
|
791
|
+
* @param from - The start date to get the economics calendar for
|
|
792
|
+
* @param to - The end date to get the economics calendar for
|
|
793
|
+
* @returns The economics calendar
|
|
794
|
+
*/
|
|
795
|
+
async getEconomicsCalendar({ from, to } = {}) {
|
|
796
|
+
const params = {};
|
|
797
|
+
if (from) params.from = from;
|
|
798
|
+
if (to) params.to = to;
|
|
799
|
+
return this.client.get("/economic_calendar", "v3", params);
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Get IPO calendar
|
|
803
|
+
* https://site.financialmodelingprep.com/developer/docs#ipo-calender-by-ipo-calendar
|
|
804
|
+
* @param from - The start date to get the IPO calendar for
|
|
805
|
+
* @param to - The end date to get the IPO calendar for
|
|
806
|
+
* @returns The IPO calendar
|
|
807
|
+
*/
|
|
808
|
+
async getIPOCalendar({ from, to } = {}) {
|
|
809
|
+
const params = {};
|
|
810
|
+
if (from) params.from = from;
|
|
811
|
+
if (to) params.to = to;
|
|
812
|
+
return this.client.get("/ipo_calendar", "v3", params);
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Get stock splits calendar
|
|
816
|
+
* https://site.financialmodelingprep.com/developer/docs#splits-calendar-splits
|
|
817
|
+
* @param from - The start date to get the stock splits calendar for
|
|
818
|
+
* @param to - The end date to get the stock splits calendar for
|
|
819
|
+
* @returns The stock splits calendar
|
|
820
|
+
*/
|
|
821
|
+
async getSplitsCalendar({ from, to } = {}) {
|
|
822
|
+
const params = {};
|
|
823
|
+
if (from) params.from = from;
|
|
824
|
+
if (to) params.to = to;
|
|
825
|
+
return this.client.get("/stock_split_calendar", "v3", params);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
// src/endpoints/company.ts
|
|
830
|
+
var CompanyEndpoints = class {
|
|
831
|
+
constructor(client) {
|
|
832
|
+
this.client = client;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Get company profile
|
|
836
|
+
* https://site.financialmodelingprep.com/developer/docs#company-profile-company-information
|
|
837
|
+
* @param symbol - The stock symbol to get the profile for
|
|
838
|
+
* @returns Get a comprehensive overview of a company with our Company Profile endpoint. This endpoint provides key information such as price, beta, market capitalization, description, headquarters, and more.
|
|
839
|
+
*/
|
|
840
|
+
async getCompanyProfile({
|
|
841
|
+
symbol
|
|
842
|
+
}) {
|
|
843
|
+
return this.client.getSingle(`/profile/${symbol}`, "v3");
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Get executive compensation
|
|
847
|
+
* https://site.financialmodelingprep.com/developer/docs#executive-compensation-company-information
|
|
848
|
+
* @param symbol - The stock symbol to get the executive compensation for
|
|
849
|
+
* @returns Understand how a company compensates its executives with our Executive Compensation endpoint. This endpoint provides information such as salary, bonus, and stock options for each executive.
|
|
850
|
+
*/
|
|
851
|
+
async getExecutiveCompensation({
|
|
852
|
+
symbol
|
|
853
|
+
}) {
|
|
854
|
+
const params = { symbol };
|
|
855
|
+
return this.client.get(`/governance/executive_compensation`, "v4", params);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Get company notes
|
|
859
|
+
* https://site.financialmodelingprep.com/developer/docs#company-notes-company-information
|
|
860
|
+
* @param symbol - The stock symbol to get the notes for
|
|
861
|
+
* @returns Stay up-to-date on a company's financial condition, operations, and risks with our Company Notes endpoint. This endpoint provides information about notes reported by a company in their financial statements.
|
|
862
|
+
*/
|
|
863
|
+
async getCompanyNotes({
|
|
864
|
+
symbol
|
|
865
|
+
}) {
|
|
866
|
+
const params = { symbol };
|
|
867
|
+
return this.client.get(`/company-notes`, "v4", params);
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Get historical employee count
|
|
871
|
+
* https://site.financialmodelingprep.com/developer/docs#historical-employee-company-information
|
|
872
|
+
* @param symbol - The stock symbol to get the historical employee count for
|
|
873
|
+
* @returns Track a company's employee count over time with our Historical Employee Count endpoint. This endpoint provides information about the number of employees a company has had each year.
|
|
874
|
+
*/
|
|
875
|
+
async getHistoricalEmployeeCount({
|
|
876
|
+
symbol
|
|
877
|
+
}) {
|
|
878
|
+
const params = { symbol };
|
|
879
|
+
return this.client.get(`/historical/employee_count`, "v4", params);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Get shares float
|
|
883
|
+
* https://site.financialmodelingprep.com/developer/docs#company-share-float-share-float
|
|
884
|
+
* @param symbol - The stock symbol to get the shares float for
|
|
885
|
+
* @returns The FMP Company Share Float endpoint provides the total number of shares that are publicly traded for a given company. This is also known as the company's float. The float is calculated by subtracting the number of restricted shares from the total number of outstanding shares.
|
|
886
|
+
*/
|
|
887
|
+
async getSharesFloat({ symbol }) {
|
|
888
|
+
const params = { symbol };
|
|
889
|
+
return this.client.getSingle(`/shares_float`, "v4", params);
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Get historical shares float
|
|
893
|
+
* https://site.financialmodelingprep.com/developer/docs#company-historical-share-float
|
|
894
|
+
* @param symbol - The stock symbol to get the historical shares float for
|
|
895
|
+
* @returns The FMP Historical Share Float endpoint provides historical data on the number of shares that are publicly traded for a given company. This is also known as the company's float. The float is calculated by subtracting the number of restricted shares from the total number of outstanding shares.
|
|
896
|
+
*/
|
|
897
|
+
async getHistoricalSharesFloat({
|
|
898
|
+
symbol
|
|
899
|
+
}) {
|
|
900
|
+
const params = { symbol };
|
|
901
|
+
return this.client.get(`/historical/shares_float`, "v4", params);
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Get earnings call transcript
|
|
905
|
+
* https://site.financialmodelingprep.com/developer/docs#earnings-transcript-earnings-transcripts
|
|
906
|
+
* @param symbol - The stock symbol to get the earnings call transcript for
|
|
907
|
+
* @param year - The year of the earnings call
|
|
908
|
+
* @param quarter - The quarter of the earnings call
|
|
909
|
+
* @returns The FMP Earnings Call Transcript endpoint provides the transcript of a company's earnings call.
|
|
910
|
+
*/
|
|
911
|
+
async getEarningsCallTranscript({
|
|
912
|
+
symbol,
|
|
913
|
+
year,
|
|
914
|
+
quarter
|
|
915
|
+
}) {
|
|
916
|
+
const params = { year, quarter };
|
|
917
|
+
return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", params);
|
|
567
918
|
}
|
|
568
919
|
};
|
|
569
920
|
|
|
570
921
|
// src/fmp.ts
|
|
571
922
|
var FMP = class {
|
|
572
923
|
constructor(config) {
|
|
573
|
-
|
|
924
|
+
validateApiKey(config.apiKey);
|
|
574
925
|
const client = new FMPClient(config);
|
|
575
926
|
this.stock = new StockEndpoints(client);
|
|
576
927
|
this.financial = new FinancialEndpoints(client);
|
|
577
|
-
this.forex = new ForexEndpoints(client);
|
|
578
928
|
this.crypto = new CryptoEndpoints(client);
|
|
579
929
|
this.etf = new ETFEndpoints(client);
|
|
580
|
-
this.mutualFund = new MutualFundEndpoints(client);
|
|
581
|
-
this.bond = new BondEndpoints(client);
|
|
582
|
-
this.economic = new EconomicEndpoints(client);
|
|
583
930
|
this.market = new MarketEndpoints(client);
|
|
931
|
+
this.list = new ListEndpoints(client);
|
|
932
|
+
this.calendar = new CalendarEndpoints(client);
|
|
933
|
+
this.company = new CompanyEndpoints(client);
|
|
934
|
+
this.forex = new ForexEndpoints(client);
|
|
935
|
+
this.economic = new EconomicEndpoints(client);
|
|
936
|
+
this.bond = new BondEndpoints(client);
|
|
937
|
+
this.mutualFund = new MutualFundEndpoints(client);
|
|
584
938
|
}
|
|
585
939
|
/**
|
|
586
940
|
* Get the underlying client instance for advanced usage
|
|
@@ -591,7 +945,22 @@ var FMP = class {
|
|
|
591
945
|
};
|
|
592
946
|
|
|
593
947
|
// src/types/common.ts
|
|
594
|
-
var
|
|
948
|
+
var Period = /* @__PURE__ */ ((Period2) => {
|
|
949
|
+
Period2["ANNUAL"] = "annual";
|
|
950
|
+
Period2["QUARTER"] = "quarter";
|
|
951
|
+
return Period2;
|
|
952
|
+
})(Period || {});
|
|
953
|
+
var Exchange = /* @__PURE__ */ ((Exchange2) => {
|
|
954
|
+
Exchange2["NYSE"] = "NYSE";
|
|
955
|
+
Exchange2["NASDAQ"] = "NASDAQ";
|
|
956
|
+
Exchange2["AMEX"] = "AMEX";
|
|
957
|
+
Exchange2["TSX"] = "TSX";
|
|
958
|
+
Exchange2["LSE"] = "LSE";
|
|
959
|
+
Exchange2["ASX"] = "ASX";
|
|
960
|
+
Exchange2["NSE"] = "NSE";
|
|
961
|
+
Exchange2["BSE"] = "BSE";
|
|
962
|
+
return Exchange2;
|
|
963
|
+
})(Exchange || {});
|
|
595
964
|
|
|
596
965
|
// src/utils/formatting.ts
|
|
597
966
|
function formatCurrency(value, currency = "USD") {
|
|
@@ -712,6 +1081,6 @@ var HTTP_STATUS = {
|
|
|
712
1081
|
INTERNAL_SERVER_ERROR: 500
|
|
713
1082
|
};
|
|
714
1083
|
|
|
715
|
-
export { BondEndpoints, COUNTRIES, CryptoEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient,
|
|
1084
|
+
export { BondEndpoints, COUNTRIES, CalendarEndpoints, CompanyEndpoints, CryptoEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient, FinancialEndpoints, ForexEndpoints, HTTP_STATUS, ListEndpoints, MAX_LIMIT, MarketEndpoints, MutualFundEndpoints, PERIODS, Period, SECTORS, StockEndpoints, formatCurrency, formatDate, formatLargeNumber, formatNumber, formatPercentage, formatReadableDate, formatTimestamp, formatVolume, validateApiKey, validateDate, validateLimit, validatePage, validatePeriod, validateSymbol };
|
|
716
1085
|
//# sourceMappingURL=index.mjs.map
|
|
717
1086
|
//# sourceMappingURL=index.mjs.map
|