fmp-node-api 0.0.8 → 0.1.1

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/dist/index.js CHANGED
@@ -1,1648 +1,2 @@
1
- 'use strict';
2
-
3
- var axios = require('axios');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var axios__default = /*#__PURE__*/_interopDefault(axios);
8
-
9
- // src/client.ts
10
- function unwrapSingleObject(data) {
11
- if (Array.isArray(data) && data.length === 1) {
12
- return data[0];
13
- }
14
- return data;
15
- }
16
- function normalizeArrayResponse(data) {
17
- if (Array.isArray(data)) return data;
18
- if (data == null) return [];
19
- return data;
20
- }
21
- function normalizeObjectResponse(data) {
22
- if (data == null) return {};
23
- return data;
24
- }
25
- var FMPClient = class {
26
- constructor(config) {
27
- this.apiKey = config.apiKey;
28
- this.v3Client = this.createClient("https://financialmodelingprep.com/api/v3", config.timeout);
29
- this.v4Client = this.createClient("https://financialmodelingprep.com/api/v4", config.timeout);
30
- this.stableClient = this.createClient(
31
- "https://financialmodelingprep.com/stable",
32
- config.timeout
33
- );
34
- }
35
- createClient(baseURL, timeout) {
36
- const client = axios__default.default.create({
37
- baseURL,
38
- timeout: timeout || 1e4,
39
- headers: { "Content-Type": "application/json" }
40
- });
41
- client.interceptors.request.use((config) => {
42
- config.params = { ...config.params, apikey: this.apiKey };
43
- return config;
44
- });
45
- return client;
46
- }
47
- /**
48
- * Standard get method - returns raw API response
49
- *
50
- * For endpoints that return arrays, this will always return an array (possibly empty) for `data` when success is true.
51
- * For endpoints that return objects, data is returned as-is.
52
- */
53
- async get(endpoint, version = "v3", params) {
54
- const client = this.getClientForVersion(version);
55
- try {
56
- const response = await client.get(endpoint, { params });
57
- let data = response.data;
58
- if (Array.isArray(data) || data == null) {
59
- data = normalizeArrayResponse(data);
60
- }
61
- return {
62
- success: true,
63
- data,
64
- error: null,
65
- status: response.status
66
- };
67
- } catch (error) {
68
- return {
69
- success: false,
70
- data: null,
71
- error: error.message || "Unknown error occurred",
72
- status: error.response?.status || 500
73
- };
74
- }
75
- }
76
- /**
77
- * Get method for single-object endpoints - unwraps single-item arrays
78
- *
79
- * For endpoints that return single objects, this will always return an object (possibly empty) for `data` when success is true.
80
- */
81
- async getSingle(endpoint, version = "v3", params) {
82
- const client = this.getClientForVersion(version);
83
- try {
84
- const response = await client.get(endpoint, { params });
85
- const data = normalizeObjectResponse(unwrapSingleObject(response.data));
86
- return {
87
- success: true,
88
- data,
89
- error: null,
90
- status: response.status
91
- };
92
- } catch (error) {
93
- return {
94
- success: false,
95
- data: null,
96
- error: error.message || "Unknown error occurred",
97
- status: error.response?.status || 500
98
- };
99
- }
100
- }
101
- getClientForVersion(version) {
102
- switch (version) {
103
- case "v3":
104
- return this.v3Client;
105
- case "v4":
106
- return this.v4Client;
107
- case "stable":
108
- return this.stableClient;
109
- default:
110
- return this.v3Client;
111
- }
112
- }
113
- };
114
-
115
- // src/shared.ts
116
- var FMPError = class extends Error {
117
- constructor(message, status, code) {
118
- super(message);
119
- this.status = status;
120
- this.code = code;
121
- this.name = "FMPError";
122
- }
123
- };
124
-
125
- // src/utils/validation.ts
126
- function validateApiKey(apiKey) {
127
- if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
128
- throw new FMPError("API key is required and must be a non-empty string");
129
- }
130
- }
131
- function validateSymbol(symbol) {
132
- if (!symbol || typeof symbol !== "string" || symbol.trim().length === 0) {
133
- throw new FMPError("Symbol is required and must be a non-empty string");
134
- }
135
- const symbolRegex = /^[A-Z0-9.-]+$/;
136
- if (!symbolRegex.test(symbol.toUpperCase())) {
137
- throw new FMPError(
138
- "Invalid symbol format. Symbols should contain only letters, numbers, dots, and hyphens"
139
- );
140
- }
141
- }
142
- function validateDate(date) {
143
- if (!date || typeof date !== "string") {
144
- throw new FMPError("Date is required and must be a string");
145
- }
146
- const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
147
- if (!dateRegex.test(date)) {
148
- throw new FMPError("Invalid date format. Use YYYY-MM-DD format");
149
- }
150
- const parsedDate = new Date(date);
151
- if (isNaN(parsedDate.getTime())) {
152
- throw new FMPError("Invalid date");
153
- }
154
- }
155
- function validatePeriod(period) {
156
- if (period && !["annual", "quarter"].includes(period)) {
157
- throw new FMPError('Period must be either "annual" or "quarter"');
158
- }
159
- }
160
- function validateLimit(limit) {
161
- if (limit !== void 0 && (typeof limit !== "number" || limit < 1 || limit > 1e3)) {
162
- throw new FMPError("Limit must be a number between 1 and 1000");
163
- }
164
- }
165
- function validatePage(page) {
166
- if (page !== void 0 && (typeof page !== "number" || page < 0)) {
167
- throw new FMPError("Page must be a non-negative number");
168
- }
169
- }
170
-
171
- // src/endpoints/stock.ts
172
- var StockEndpoints = class {
173
- constructor(client) {
174
- this.client = client;
175
- }
176
- /**
177
- * Get real-time stock quote
178
- * @deprecated Use `fmp.quote.getQuote()` instead. This method will be removed in version 0.1.0.
179
- * @param symbol - The stock symbol to get the quote for
180
- * @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.
181
- */
182
- async getQuote({ symbol }) {
183
- console.warn(
184
- "\u26A0\uFE0F StockEndpoints.getQuote() is deprecated. Use fmp.quote.getQuote() instead. This method will be removed in version 0.1.0."
185
- );
186
- return this.client.getSingle(`/quote/${symbol}`, "v3");
187
- }
188
- /**
189
- * Get historical stock prices
190
- * @deprecated Use `fmp.quote.getHistoricalPrice()` instead. This method will be removed in version 0.1.0.
191
- * @param symbol - The stock symbol to get the historical prices for
192
- * @param from - The start date to get the historical prices for
193
- * @param to - The end date to get the historical prices for
194
- * @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
195
- */
196
- async getHistoricalPrice({
197
- symbol,
198
- from,
199
- to
200
- }) {
201
- console.warn(
202
- "\u26A0\uFE0F StockEndpoints.getHistoricalPrice() is deprecated. Use fmp.quote.getHistoricalPrice() instead. This method will be removed in version 0.1.0."
203
- );
204
- const params = {};
205
- if (from) params.from = from;
206
- if (to) params.to = to;
207
- return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
208
- }
209
- /**
210
- * Get market cap
211
- * https://site.financialmodelingprep.com/developer/docs#market-cap-company-information
212
- * @param symbol - The stock symbol to get the market cap for
213
- * @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.
214
- */
215
- async getMarketCap({ symbol }) {
216
- return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
217
- }
218
- /**
219
- * Get stock splits
220
- * https://site.financialmodelingprep.com/developer/docs#splits-historical-splits
221
- * @param symbol - The stock symbol to get the splits for
222
- * @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.
223
- */
224
- async getStockSplits({ symbol }) {
225
- return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
226
- }
227
- /**
228
- * Get dividend history
229
- * https://site.financialmodelingprep.com/developer/docs#dividends-historical-dividends
230
- * @param symbol - The stock symbol to get the dividend history for
231
- * @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.
232
- */
233
- async getDividendHistory({
234
- symbol
235
- }) {
236
- return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
237
- }
238
- /**
239
- * Get stock real time price
240
- * @param symbol - The stock symbol to get the real time price for
241
- * @returns The real time price for the stock
242
- */
243
- async getRealTimePrice({
244
- symbols
245
- }) {
246
- const url = `stock/real-time-price/${symbols.join(",")}`;
247
- const result = await this.client.get(url, "v3");
248
- if (result.success && result.data && !Array.isArray(result.data)) {
249
- const data = result.data;
250
- if (typeof data === "object" && data !== null && "companiesPriceList" in data && Array.isArray(data.companiesPriceList)) {
251
- const filteredData2 = data.companiesPriceList.filter((item) => item && item.symbol);
252
- if (filteredData2.length > 0) {
253
- return { ...result, data: filteredData2 };
254
- }
255
- }
256
- if (typeof data === "object" && data !== null && "stockList" in data && Array.isArray(data.stockList)) {
257
- const filteredData2 = data.stockList.filter((item) => item && item.symbol);
258
- if (filteredData2.length > 0) {
259
- return { ...result, data: filteredData2 };
260
- }
261
- }
262
- if (data.symbol) {
263
- return { ...result, data: [data] };
264
- }
265
- if (symbols.length === 1) {
266
- console.warn(`No real-time price data found for symbol: ${symbols[0]}`);
267
- }
268
- return { ...result, data: [] };
269
- }
270
- const filteredData = result.data.filter((item) => item && item.symbol);
271
- return { ...result, data: filteredData };
272
- }
273
- /**
274
- * Get stock real time price full
275
- * https://site.financialmodelingprep.com/developer/docs#real-time-full-price-quote
276
- * @param symbols - The stock symbols to get the real time price for
277
- * @returns The real time price for the stocks
278
- */
279
- async getRealTimePriceForMultipleStocks({
280
- symbols
281
- }) {
282
- const url = `stock/full/real-time-price/${symbols.join(",")}`;
283
- const result = await this.client.get(url, "v3");
284
- if (result.success && result.data && !Array.isArray(result.data)) {
285
- const data = result.data;
286
- if (typeof data === "object" && data !== null && "companiesPriceList" in data && Array.isArray(data.companiesPriceList)) {
287
- const filteredData2 = data.companiesPriceList.filter((item) => item && item.symbol);
288
- if (filteredData2.length > 0) {
289
- return { ...result, data: filteredData2 };
290
- }
291
- }
292
- if (typeof data === "object" && data !== null && "stockList" in data && Array.isArray(data.stockList)) {
293
- const filteredData2 = data.stockList.filter((item) => item && item.symbol);
294
- if (filteredData2.length > 0) {
295
- return { ...result, data: filteredData2 };
296
- }
297
- }
298
- if (data.symbol) {
299
- return { ...result, data: [data] };
300
- }
301
- if (symbols.length === 1) {
302
- console.warn(`No full real-time price data found for symbol: ${symbols[0]}`);
303
- }
304
- return { ...result, data: [] };
305
- }
306
- const filteredData = result.data.filter(
307
- (item) => item && item.symbol
308
- );
309
- return { ...result, data: filteredData };
310
- }
311
- };
312
-
313
- // src/endpoints/financial.ts
314
- var FinancialEndpoints = class {
315
- constructor(client) {
316
- this.client = client;
317
- }
318
- /**
319
- * Get income statement
320
- * https://site.financialmodelingprep.com/developer/docs#income-statements-financial-statements
321
- * @param symbol - The stock symbol to get the income statement for
322
- * @param period - The period to get the income statement for (annual or quarter)
323
- * @param limit - The number of periods to get
324
- * @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.
325
- */
326
- async getIncomeStatement({
327
- symbol,
328
- period = "annual",
329
- limit = 5
330
- }) {
331
- return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
332
- }
333
- /**
334
- * Get balance sheet
335
- * https://site.financialmodelingprep.com/developer/docs#balance-sheet-statements-financial-statements
336
- * @param symbol - The stock symbol to get the balance sheet for
337
- * @param period - The period to get the balance sheet for (annual or quarter)
338
- * @param limit - The number of periods to get
339
- * @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.
340
- */
341
- async getBalanceSheet({
342
- symbol,
343
- period = "annual",
344
- limit = 5
345
- }) {
346
- return this.client.get(
347
- `/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`,
348
- "v3"
349
- );
350
- }
351
- /**
352
- * Get cash flow statement
353
- * https://site.financialmodelingprep.com/developer/docs#cashflow-statements-financial-statements
354
- * @param symbol - The stock symbol to get the cash flow statement for
355
- * @param period - The period to get the cash flow statement for (annual or quarter)
356
- * @param limit - The number of periods to get
357
- * @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.
358
- */
359
- async getCashFlowStatement({
360
- symbol,
361
- period = "annual",
362
- limit = 5
363
- }) {
364
- return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
365
- }
366
- /**
367
- * Get key metrics
368
- * https://site.financialmodelingprep.com/developer/docs#key-metrics-statement-analysis
369
- * @param symbol - The stock symbol to get the key metrics for
370
- * @param period - The period to get the key metrics for (annual or quarter)
371
- * @param limit - The number of periods to get
372
- * @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.
373
- */
374
- async getKeyMetrics({
375
- symbol,
376
- period = "annual",
377
- limit = 5
378
- }) {
379
- return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`, "v3");
380
- }
381
- /**
382
- * Get financial ratios
383
- * https://site.financialmodelingprep.com/developer/docs#ratios-statement-analysis
384
- * @param symbol - The stock symbol to get the financial ratios for
385
- * @param period - The period to get the financial ratios for (annual or quarter)
386
- * @param limit - The number of periods to get
387
- * @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.
388
- */
389
- async getFinancialRatios({
390
- symbol,
391
- period = "annual",
392
- limit = 5
393
- }) {
394
- return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`, "v3");
395
- }
396
- /**
397
- * Get enterprise value
398
- * https://site.financialmodelingprep.com/developer/docs#enterprise-values-statement-analysis
399
- * @param symbol - The stock symbol to get the enterprise value for
400
- * @param period - The period to get the enterprise value for (annual or quarter)
401
- * @param limit - The number of periods to get
402
- * @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.
403
- */
404
- async getEnterpriseValue({
405
- symbol,
406
- period = "annual",
407
- limit = 5
408
- }) {
409
- return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`, "v3");
410
- }
411
- /**
412
- * Get cashflow growth
413
- * https://site.financialmodelingprep.com/developer/docs#cashflow-growth-statement-analysis
414
- * @param symbol - The stock symbol to get the cashflow growth for
415
- * @param period - The period to get the cashflow growth for (annual or quarter)
416
- * @param limit - The number of periods to get
417
- * @returns Get the cash flow growth rate for a company. Measure how quickly a company's cash flow is growing.
418
- */
419
- async getCashflowGrowth({
420
- symbol,
421
- period = "annual",
422
- limit = 5
423
- }) {
424
- return this.client.get(
425
- `/cash-flow-statement-growth/${symbol}?period=${period}&limit=${limit}`,
426
- "v3"
427
- );
428
- }
429
- /**
430
- * Get income growth
431
- * https://site.financialmodelingprep.com/developer/docs#income-growth-statement-analysis
432
- * @param symbol - The stock symbol to get the income growth for
433
- * @param period - The period to get the income growth for (annual or quarter)
434
- * @param limit - The number of periods to get
435
- * @returns Get the income growth rate for a company. Measure how quickly a company's income is growing.
436
- */
437
- async getIncomeGrowth({
438
- symbol,
439
- period = "annual",
440
- limit = 5
441
- }) {
442
- return this.client.get(
443
- `/income-statement-growth/${symbol}?period=${period}&limit=${limit}`,
444
- "v3"
445
- );
446
- }
447
- /**
448
- * Get balance sheet growth
449
- * https://site.financialmodelingprep.com/developer/docs#balance-sheet-growth-statement-analysis
450
- * @param symbol - The stock symbol to get the balance sheet growth for
451
- * @param period - The period to get the balance sheet growth for (annual or quarter)
452
- * @param limit - The number of periods to get
453
- * @returns Get the balance sheet growth rate for a company. Measure how quickly a company's assets and liabilities are growing.
454
- */
455
- async getBalanceSheetGrowth({
456
- symbol,
457
- period = "annual",
458
- limit = 5
459
- }) {
460
- return this.client.get(
461
- `/balance-sheet-statement-growth/${symbol}?period=${period}&limit=${limit}`,
462
- "v3"
463
- );
464
- }
465
- /**
466
- * Get financial growth
467
- * https://site.financialmodelingprep.com/developer/docs#financial-growth-statement-analysis
468
- * @param symbol - The stock symbol to get the financial growth for
469
- * @param period - The period to get the financial growth for (annual or quarter)
470
- * @param limit - The number of periods to get
471
- * @returns Financial Growth Get the financial growth rate for a company. Measure how quickly a company's overall financial performance is improving.
472
- */
473
- async getFinancialGrowth({
474
- symbol,
475
- period = "annual",
476
- limit = 5
477
- }) {
478
- return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
479
- }
480
- /**
481
- * Get earnings historical
482
- * https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings
483
- * @param symbol - The stock symbol to get the earnings historical for
484
- * @param limit - The number of periods to get
485
- * @returns A list of historical & upcoming earnings announcements for a specific company, including the date, estimated EPS, and actual EPS.
486
- */
487
- async getEarningsHistorical({
488
- symbol,
489
- limit = 5
490
- }) {
491
- return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
492
- }
493
- /**
494
- * Get earnings surprises
495
- * https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings
496
- * @param symbol - The stock symbol to get the earnings surprises for
497
- * @param limit - The number of periods to get
498
- * @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.
499
- */
500
- async getEarningsSurprises({
501
- symbol
502
- }) {
503
- return this.client.get(`/earnings-surprises/${symbol}`, "v3");
504
- }
505
- };
506
-
507
- // src/endpoints/forex.ts
508
- var ForexEndpoints = class {
509
- constructor(client) {
510
- this.client = client;
511
- }
512
- /**
513
- * Get forex quote
514
- * @deprecated Use `fmp.quote.getQuote()` instead. This method will be removed in version 0.1.0.
515
- * @param params - Parameters for the forex quote request
516
- * @returns Forex quote data
517
- */
518
- async getQuote(params) {
519
- console.warn(
520
- "\u26A0\uFE0F ForexEndpoints.getQuote() is deprecated. Use fmp.quote.getQuote() instead. This method will be removed in version 0.1.0."
521
- );
522
- return this.client.get("/quote", "v3", params);
523
- }
524
- /**
525
- * Get historical forex prices
526
- * @deprecated Use `fmp.quote.getHistoricalPrice()` instead. This method will be removed in version 0.1.0.
527
- * @param symbol - The forex symbol to get the historical prices for
528
- * @param from - The start date to get the historical prices for
529
- * @param to - The end date to get the historical prices for
530
- * @returns Historical forex price data
531
- */
532
- async getHistoricalPrice({
533
- symbol,
534
- from,
535
- to
536
- }) {
537
- console.warn(
538
- "\u26A0\uFE0F ForexEndpoints.getHistoricalPrice() is deprecated. Use fmp.quote.getHistoricalPrice() instead. This method will be removed in version 0.1.0."
539
- );
540
- const params = {};
541
- if (from) params.from = from;
542
- if (to) params.to = to;
543
- return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
544
- }
545
- };
546
-
547
- // src/endpoints/crypto.ts
548
- var CryptoEndpoints = class {
549
- constructor(client) {
550
- this.client = client;
551
- }
552
- /**
553
- * Get crypto quote
554
- * @deprecated Use `fmp.quote.getQuote()` instead. This method will be removed in version 0.1.0.
555
- * @param symbol - The crypto symbol to get the quote for
556
- * @returns Crypto quote data
557
- */
558
- async getQuote({ symbol }) {
559
- console.warn(
560
- "\u26A0\uFE0F CryptoEndpoints.getQuote() is deprecated. Use fmp.quote.getQuote() instead. This method will be removed in version 0.1.0."
561
- );
562
- return this.client.getSingle(`/quote/${symbol}`, "v3");
563
- }
564
- /**
565
- * Get historical crypto prices
566
- * @deprecated Use `fmp.quote.getHistoricalPrice()` instead. This method will be removed in version 0.1.0.
567
- * @param symbol - The crypto symbol to get the historical prices for
568
- * @param from - The start date to get the historical prices for
569
- * @param to - The end date to get the historical prices for
570
- * @returns Provides daily price data for all cryptocurrencies that are traded on exchanges around the world.
571
- */
572
- async getHistoricalPrice({
573
- symbol,
574
- from,
575
- to
576
- }) {
577
- console.warn(
578
- "\u26A0\uFE0F CryptoEndpoints.getHistoricalPrice() is deprecated. Use fmp.quote.getHistoricalPrice() instead. This method will be removed in version 0.1.0."
579
- );
580
- const params = {};
581
- if (from) params.from = from;
582
- if (to) params.to = to;
583
- return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
584
- }
585
- };
586
-
587
- // src/endpoints/etf.ts
588
- var ETFEndpoints = class {
589
- constructor(client) {
590
- this.client = client;
591
- }
592
- /**
593
- * Get ETF holding dates
594
- * https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings
595
- * @param symbol - The symbol of the ETF to get the holding dates for
596
- * @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.
597
- */
598
- async getHoldingDates({ symbol }) {
599
- const params = {};
600
- if (symbol) params.symbol = symbol;
601
- return this.client.get("/etf-holdings/portfolio-date", "v4", params);
602
- }
603
- /**
604
- * Get ETF holdings
605
- * https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings
606
- * @param symbol - The symbol of the ETF to get the holdings for
607
- * @param date - The date to get the holdings for
608
- * @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.
609
- */
610
- async getHoldings({
611
- symbol,
612
- date
613
- }) {
614
- const params = {};
615
- if (symbol) params.symbol = symbol;
616
- if (date) params.date = date;
617
- return this.client.get("/etf-holdings", "v4", params);
618
- }
619
- /**
620
- * Get ETF holder
621
- * https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings
622
- * @param symbol - The symbol of the ETF to get the holder for
623
- * @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.
624
- */
625
- async getHolder({ symbol }) {
626
- return this.client.get(`/etf-holder/${symbol}`, "v3");
627
- }
628
- /**
629
- * Get ETF profile
630
- * https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings
631
- * @param symbol - The symbol of the ETF to get the profile for
632
- * @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.
633
- */
634
- async getProfile({ symbol }) {
635
- const params = {};
636
- if (symbol) params.symbol = symbol;
637
- return this.client.getSingle("/etf-info", "v4", params);
638
- }
639
- /**
640
- * Get ETF sector weighting
641
- * https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings
642
- * @param symbol - The symbol of the ETF to get the sector exposure for
643
- * @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.
644
- */
645
- async getSectorWeighting({ symbol }) {
646
- return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
647
- }
648
- /**
649
- * Get ETF country weighting
650
- * https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings
651
- * @param symbol - The symbol of the ETF to get the country weighting for
652
- * @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.
653
- */
654
- async getCountryWeighting({ symbol }) {
655
- return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
656
- }
657
- /**
658
- * Get ETF Stock exposure
659
- * https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings
660
- * @param symbol - The symbol of the ETF to get the stock exposure for
661
- * @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.
662
- */
663
- async getStockExposure({ symbol }) {
664
- return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
665
- }
666
- };
667
-
668
- // src/endpoints/mutual-fund.ts
669
- var MutualFundEndpoints = class {
670
- constructor(client) {
671
- this.client = client;
672
- }
673
- /**
674
- * Get mutual fund quote
675
- * @deprecated Use `fmp.quote.getQuote()` instead. This method will be removed in a future release.
676
- * @param params - Parameters for the mutual fund quote request
677
- * @returns Mutual fund quote data
678
- */
679
- async getQuote(params) {
680
- return this.client.get("/quote", "v3", params);
681
- }
682
- /**
683
- * Get mutual fund holders
684
- * https://site.financialmodelingprep.com/developer/docs#mutual-fund-holder-mutual-funds-holdings
685
- * @param symbol - The symbol of the mutual fund to get the holders for
686
- * @returns Mutual fund holders data
687
- */
688
- async getHolders({ symbol }) {
689
- return this.client.get(`/mutual-fund-holder/${symbol}`, "v3");
690
- }
691
- };
692
-
693
- // src/endpoints/economic.ts
694
- var EconomicEndpoints = class {
695
- constructor(client) {
696
- this.client = client;
697
- }
698
- /**
699
- * Get treasury rates
700
- * https://site.financialmodelingprep.com/developer/docs#treasury-rates-economics-data
701
- * @param from - The start date to get the treasury rates for
702
- * @param to - The end date to get the treasury rates for
703
- * @returns Treasury rates data
704
- */
705
- async getTreasuryRates(params) {
706
- const { from, to } = params;
707
- const queryParams = {};
708
- if (from) queryParams.from = from;
709
- if (to) queryParams.to = to;
710
- return this.client.get("/treasury", "v4", queryParams);
711
- }
712
- /**
713
- * Get economic indicators
714
- * https://site.financialmodelingprep.com/developer/docs#economic-indicators-economics-data
715
- * @param name - GDP, realGDP, nominalPotentialGDP, realGDPPerCapita, federalFunds, CPI, inflationRate, inflation, retailSales, consumerSentiment, durableGoods, unemploymentRate, totalNonfarmPayroll, initialClaims, industrialProductionTotalIndex, newPrivatelyOwnedHousingUnitsStartedTotalUnits, totalVehicleSales, retailMoneyFunds, smoothedUSRecessionProbabilities, 3MonthOr90DayRatesAndYieldsCertificatesOfDeposit, commercialBankInterestRateOnCreditCardPlansAllAccounts, 30YearFixedRateMortgageAverage, 15YearFixedRateMortgageAverage
716
- * @param from - The start date to get the economic indicators for
717
- * @param to - The end date to get the economic indicators for
718
- * @returns Provides real-time and historical economic data for a variety of economic indicators, such as GDP, unemployment, and inflation.
719
- */
720
- async getEconomicIndicators(params) {
721
- const { name, from, to } = params;
722
- const queryParams = { name };
723
- if (from) queryParams.from = from;
724
- if (to) queryParams.to = to;
725
- return this.client.get(`/economic`, "v4", queryParams);
726
- }
727
- };
728
-
729
- // src/endpoints/market.ts
730
- var MarketEndpoints = class {
731
- constructor(client) {
732
- this.client = client;
733
- }
734
- /**
735
- * Get market hours
736
- */
737
- async getMarketHours() {
738
- return this.client.get("/market-hours", "v3");
739
- }
740
- /**
741
- * Get market performance
742
- */
743
- async getMarketPerformance() {
744
- return this.client.get("/market-performance", "v3");
745
- }
746
- /**
747
- * Get top gainers
748
- * https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview
749
- * @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.
750
- */
751
- async getGainers() {
752
- return this.client.get("/stock_market/gainers", "v3");
753
- }
754
- /**
755
- * Get top losers
756
- * https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview
757
- * @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.
758
- */
759
- async getLosers() {
760
- return this.client.get("/stock_market/losers", "v3");
761
- }
762
- /**
763
- * Get most active stocks
764
- */
765
- async getMostActive() {
766
- return this.client.get("/stock_market/actives", "v3");
767
- }
768
- /**
769
- * Get sector performance
770
- * https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview
771
- * @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.
772
- */
773
- async getSectorPerformance() {
774
- return this.client.get("/sector-performance", "v3");
775
- }
776
- /**
777
- * Get market indices
778
- * https://site.financialmodelingprep.com/developer/docs#market-index-market-overview
779
- * @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.
780
- */
781
- async getMarketIndex() {
782
- return this.client.get("/quotes/index", "v3");
783
- }
784
- };
785
-
786
- // src/endpoints/list.ts
787
- var ListEndpoints = class {
788
- constructor(client) {
789
- this.client = client;
790
- }
791
- /**
792
- * Get stock list
793
- * https://site.financialmodelingprep.com/developer/docs#symbol-list-stock-list
794
- * @returns The stock list
795
- */
796
- async getStockList() {
797
- return this.client.get("/stock/list");
798
- }
799
- /**
800
- * Get ETF list
801
- * https://site.financialmodelingprep.com/developer/docs#exchange-traded-fund-search-stock-list
802
- * @returns The ETF list
803
- */
804
- async getETFList() {
805
- return this.client.get("/etf/list");
806
- }
807
- /**
808
- * Get crypto list
809
- * https://site.financialmodelingprep.com/developer/docs#cryptocurrencies-list-crypto
810
- * @returns The crypto list
811
- */
812
- async getCryptoList() {
813
- return this.client.get("/symbol/available-cryptocurrencies");
814
- }
815
- /**
816
- * Get forex list
817
- * https://site.financialmodelingprep.com/developer/docs#forex-list-forex
818
- * @returns The forex list
819
- */
820
- async getForexList() {
821
- return this.client.get("/symbol/available-forex-currency-pairs");
822
- }
823
- /**
824
- * Get available indexes list
825
- * https://site.financialmodelingprep.com/developer/docs#available-indexes
826
- * @returns The available indexes list
827
- */
828
- async getAvailableIndexes() {
829
- return this.client.get("/symbol/available-indexes");
830
- }
831
- };
832
-
833
- // src/endpoints/calendar.ts
834
- var CalendarEndpoints = class {
835
- constructor(client) {
836
- this.client = client;
837
- }
838
- /**
839
- * Get earnings calendar
840
- * https://site.financialmodelingprep.com/developer/docs#earnings-calendar-earnings
841
- * @param from - The start date to get the earnings calendar for
842
- * @param to - The end date to get the earnings calendar for
843
- * @returns The earnings calendar
844
- */
845
- async getEarningsCalendar({ from, to } = {}) {
846
- const params = {};
847
- if (from) params.from = from;
848
- if (to) params.to = to;
849
- return this.client.get("/earning_calendar", "v3", params);
850
- }
851
- /**
852
- * Get earnings confirmed
853
- * https://site.financialmodelingprep.com/developer/docs#earnings-confirmed-earnings
854
- * @param from - The start date to get the earnings confirmed for
855
- * @param to - The end date to get the earnings confirmed for
856
- * @returns The earnings confirmed
857
- */
858
- async getEarningsConfirmed({ from, to } = {}) {
859
- const params = {};
860
- if (from) params.from = from;
861
- if (to) params.to = to;
862
- return this.client.get("/earning-calendar-confirmed", "v4", params);
863
- }
864
- /**
865
- * Get dividends calendar
866
- * https://site.financialmodelingprep.com/developer/docs#dividends-calendar-dividends
867
- * @param from - The start date to get the dividends calendar for
868
- * @param to - The end date to get the dividends calendar for
869
- * @returns The dividends calendar
870
- */
871
- async getDividendsCalendar({ from, to } = {}) {
872
- const params = {};
873
- if (from) params.from = from;
874
- if (to) params.to = to;
875
- return this.client.get("/stock_dividend_calendar", "v3", params);
876
- }
877
- /**
878
- * Get economics calendar
879
- * https://site.financialmodelingprep.com/developer/docs#economics-calendar-economics-data
880
- * @param from - The start date to get the economics calendar for
881
- * @param to - The end date to get the economics calendar for
882
- * @returns The economics calendar
883
- */
884
- async getEconomicsCalendar({ from, to } = {}) {
885
- const params = {};
886
- if (from) params.from = from;
887
- if (to) params.to = to;
888
- return this.client.get("/economic_calendar", "v3", params);
889
- }
890
- /**
891
- * Get IPO calendar
892
- * https://site.financialmodelingprep.com/developer/docs#ipo-calender-by-ipo-calendar
893
- * @param from - The start date to get the IPO calendar for
894
- * @param to - The end date to get the IPO calendar for
895
- * @returns The IPO calendar
896
- */
897
- async getIPOCalendar({ from, to } = {}) {
898
- const params = {};
899
- if (from) params.from = from;
900
- if (to) params.to = to;
901
- return this.client.get("/ipo_calendar", "v3", params);
902
- }
903
- /**
904
- * Get stock splits calendar
905
- * https://site.financialmodelingprep.com/developer/docs#splits-calendar-splits
906
- * @param from - The start date to get the stock splits calendar for
907
- * @param to - The end date to get the stock splits calendar for
908
- * @returns The stock splits calendar
909
- */
910
- async getSplitsCalendar({ from, to } = {}) {
911
- const params = {};
912
- if (from) params.from = from;
913
- if (to) params.to = to;
914
- return this.client.get("/stock_split_calendar", "v3", params);
915
- }
916
- };
917
-
918
- // src/endpoints/company.ts
919
- var CompanyEndpoints = class {
920
- constructor(client) {
921
- this.client = client;
922
- }
923
- /**
924
- * Get company profile
925
- * https://site.financialmodelingprep.com/developer/docs#company-profile-company-information
926
- * @param symbol - The stock symbol to get the profile for
927
- * @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.
928
- */
929
- async getCompanyProfile({ symbol }) {
930
- return this.client.getSingle(`/profile/${symbol}`, "v3");
931
- }
932
- /**
933
- * Get executive compensation
934
- * https://site.financialmodelingprep.com/developer/docs#executive-compensation-company-information
935
- * @param symbol - The stock symbol to get the executive compensation for
936
- * @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.
937
- */
938
- async getExecutiveCompensation({
939
- symbol
940
- }) {
941
- const params = { symbol };
942
- return this.client.get(`/governance/executive_compensation`, "v4", params);
943
- }
944
- /**
945
- * Get company notes
946
- * https://site.financialmodelingprep.com/developer/docs#company-notes-company-information
947
- * @param symbol - The stock symbol to get the notes for
948
- * @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.
949
- */
950
- async getCompanyNotes({ symbol }) {
951
- const params = { symbol };
952
- return this.client.get(`/company-notes`, "v4", params);
953
- }
954
- /**
955
- * Get historical employee count
956
- * https://site.financialmodelingprep.com/developer/docs#historical-employee-company-information
957
- * @param symbol - The stock symbol to get the historical employee count for
958
- * @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.
959
- */
960
- async getHistoricalEmployeeCount({
961
- symbol
962
- }) {
963
- const params = { symbol };
964
- return this.client.get(`/historical/employee_count`, "v4", params);
965
- }
966
- /**
967
- * Get shares float
968
- * https://site.financialmodelingprep.com/developer/docs#company-share-float-share-float
969
- * @param symbol - The stock symbol to get the shares float for
970
- * @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.
971
- */
972
- async getSharesFloat({ symbol }) {
973
- const params = { symbol };
974
- return this.client.getSingle(`/shares_float`, "v4", params);
975
- }
976
- /**
977
- * Get historical shares float
978
- * https://site.financialmodelingprep.com/developer/docs#company-historical-share-float
979
- * @param symbol - The stock symbol to get the historical shares float for
980
- * @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.
981
- */
982
- async getHistoricalSharesFloat({
983
- symbol
984
- }) {
985
- const params = { symbol };
986
- return this.client.get(`/historical/shares_float`, "v4", params);
987
- }
988
- /**
989
- * Get earnings call transcript
990
- * https://site.financialmodelingprep.com/developer/docs#earnings-transcript-earnings-transcripts
991
- * @param symbol - The stock symbol to get the earnings call transcript for
992
- * @param year - The year of the earnings call
993
- * @param quarter - The quarter of the earnings call
994
- * @returns The FMP Earnings Call Transcript endpoint provides the transcript of a company's earnings call.
995
- */
996
- async getEarningsCallTranscript({
997
- symbol,
998
- year,
999
- quarter
1000
- }) {
1001
- const params = { year, quarter };
1002
- return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", params);
1003
- }
1004
- /**
1005
- * Get company transcript dates
1006
- * https://site.financialmodelingprep.com/developer/docs#transcript-dates-earnings-transcripts
1007
- * @param symbol - The stock symbol to get the transcript data for
1008
- * @returns The FMP Company Transcript Data endpoint provides the transcript data for a company's earnings call.
1009
- */
1010
- async getCompanyTranscriptData({
1011
- symbol
1012
- }) {
1013
- const params = { symbol };
1014
- return this.client.getSingle(`/earning_call_transcript`, "v4", params);
1015
- }
1016
- };
1017
-
1018
- // src/endpoints/quote.ts
1019
- var QuoteEndpoints = class {
1020
- constructor(client) {
1021
- this.client = client;
1022
- }
1023
- /**
1024
- * Get quote for any asset type (stock, crypto, forex, commodity, ETF)
1025
- * @param params - Parameters for the quote request
1026
- * @returns Quote data for the specified asset
1027
- */
1028
- async getQuote(params) {
1029
- const { symbol } = params;
1030
- return this.client.getSingle(`/quote/${symbol}`, "v3");
1031
- }
1032
- /**
1033
- * Get historical prices for any asset type
1034
- * @param params - Parameters for the historical price request
1035
- * @returns Historical price data for the specified asset
1036
- */
1037
- async getHistoricalPrice(params) {
1038
- const { symbol, from, to } = params;
1039
- const queryParams = {};
1040
- if (from) queryParams.from = from;
1041
- if (to) queryParams.to = to;
1042
- return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", queryParams);
1043
- }
1044
- /**
1045
- * Get multiple quotes for any asset type
1046
- * @param symbols - Array of symbols to get quotes for
1047
- * @returns Array of quote data
1048
- */
1049
- async getQuotes(symbols) {
1050
- const symbolsParam = symbols.join(",");
1051
- return this.client.get(`/quote/${symbolsParam}`, "v3");
1052
- }
1053
- /**
1054
- * Get intraday data for any asset type
1055
- * @param params - Parameters for the intraday request
1056
- * @returns Intraday price data for the specified asset
1057
- */
1058
- async getIntraday(params) {
1059
- const { symbol, interval, from, to } = params;
1060
- const queryParams = {};
1061
- if (from) queryParams.from = from;
1062
- if (to) queryParams.to = to;
1063
- return this.client.get(`/historical-chart/${interval}/${symbol}`, "v3", queryParams);
1064
- }
1065
- };
1066
-
1067
- // src/endpoints/senate-house.ts
1068
- var SenateHouseEndpoints = class {
1069
- constructor(client) {
1070
- this.client = client;
1071
- }
1072
- /**
1073
- * Get senate trading data only
1074
- * https://site.financialmodelingprep.com/developer/docs#senate-trading
1075
- * @param symbol - The stock symbol to get the senate trading data for
1076
- * @returns Senate trading data only
1077
- */
1078
- async getSenateTrading(params) {
1079
- const { symbol } = params;
1080
- return this.client.get(`/senate-trading`, "v4", { symbol });
1081
- }
1082
- /** Get senate trading RSS feed
1083
- * https://site.financialmodelingprep.com/developer/docs#senate-trading-rss-feed-senate
1084
- * @param page - The page number to get
1085
- * @returns Senate trading RSS feed
1086
- */
1087
- async getSenateTradingRSSFeed(params) {
1088
- const { page } = params;
1089
- return this.client.get("/senate-trading-rss-feed", "v4", { page });
1090
- }
1091
- /** Get Senate trades by name
1092
- * https://site.financialmodelingprep.com/developer/docs/stable#senate-trading-by-name
1093
- * @param name - The name of the senator to get the trades for
1094
- * @returns Senate trades by name
1095
- */
1096
- async getSenateTradingByName(params) {
1097
- const { name } = params;
1098
- return this.client.get("/senate-trades-by-name", "stable", { name });
1099
- }
1100
- /**
1101
- * Get house trading data only
1102
- * https://site.financialmodelingprep.com/developer/docs#house-disclosure
1103
- * @param symbol - The stock symbol to get the house trading data for
1104
- * @returns House trading data only
1105
- */
1106
- async getHouseTrading(params) {
1107
- const { symbol } = params;
1108
- return this.client.get("/senate-disclosure", "v4", { symbol });
1109
- }
1110
- /** Get house trading RSS feed
1111
- * https://site.financialmodelingprep.com/developer/docs#house-disclosure-rss-feed-senate
1112
- * @param page - The page number to get
1113
- * @returns House trading RSS feed
1114
- */
1115
- async getHouseTradingRSSFeed(params) {
1116
- const { page } = params;
1117
- return this.client.get("/senate-disclosure-rss-feed", "v4", { page });
1118
- }
1119
- /** Get house trading by name
1120
- * https://site.financialmodelingprep.com/developer/docs/stable#house-trading-by-name
1121
- * @param name - The name of the representative to get the trades for
1122
- * @returns House trading by name
1123
- */
1124
- async getHouseTradingByName(params) {
1125
- const { name } = params;
1126
- return this.client.get("/house-trades-by-name", "stable", { name });
1127
- }
1128
- };
1129
-
1130
- // src/endpoints/institutional.ts
1131
- var InstitutionalEndpoints = class {
1132
- constructor(client) {
1133
- this.client = client;
1134
- }
1135
- /**
1136
- * Get Form 13F institutional stock ownership data
1137
- * https://site.financialmodelingprep.com/developer/docs#form-13f-13f---institutional-stock-ownership
1138
- * @param symbol - The stock symbol to get the Form 13F data for
1139
- * @param date - The date to get the Form 13F data for (optional)
1140
- * @returns Form 13F institutional stock ownership data
1141
- */
1142
- async getForm13F(params) {
1143
- const { cik, date } = params;
1144
- const queryParams = {};
1145
- if (date) queryParams.date = date;
1146
- return this.client.get(`/form-thirteen/${cik}`, "v3", queryParams);
1147
- }
1148
- /**
1149
- * Get Form 13F dates for institutional stock ownership
1150
- * https://site.financialmodelingprep.com/developer/docs#form-13f-dates-13f---institutional-stock-ownership
1151
- * @param symbol - The stock symbol to get the Form 13F dates for
1152
- * @returns Form 13F dates for institutional stock ownership
1153
- */
1154
- async getForm13FDates(params) {
1155
- const { cik } = params;
1156
- return this.client.get(`/form-thirteen-date/${cik}`, "v3");
1157
- }
1158
- /**
1159
- * Get institutional holders data
1160
- * https://site.financialmodelingprep.com/developer/docs#institutional-holder-13f---institutional-stock-ownership
1161
- * @param symbol - The stock symbol to get the institutional holders for
1162
- * @returns Institutional holders data
1163
- */
1164
- async getInstitutionalHolders(params) {
1165
- const { symbol } = params;
1166
- return this.client.get(`/institutional-holder/${symbol}`, "v3");
1167
- }
1168
- };
1169
-
1170
- // src/endpoints/insider.ts
1171
- var InsiderEndpoints = class {
1172
- constructor(client) {
1173
- this.client = client;
1174
- }
1175
- /**
1176
- * Get insider trading RSS feed
1177
- * https://site.financialmodelingprep.com/developer/docs#insider-trades-rss-insider-trading
1178
- * @param params - Parameters for the RSS feed request
1179
- * @returns An RSS feed of insider trades, updated in real time
1180
- */
1181
- async getInsiderTradingRSS({
1182
- page
1183
- }) {
1184
- return this.client.get(`/insider-trading-rss-feed`, "v4", { page });
1185
- }
1186
- /**
1187
- * Search for insider trades
1188
- * https://site.financialmodelingprep.com/developer/docs#insider-trades-search-insider-trading
1189
- * @param params - Parameters for the insider trading search
1190
- * @returns A list of insider trades filtered by the provided parameters
1191
- */
1192
- async searchInsiderTrading({
1193
- symbol,
1194
- reportingCik,
1195
- companyCik,
1196
- transactionType,
1197
- page
1198
- }) {
1199
- const params = { page };
1200
- if (symbol) params.symbol = symbol;
1201
- if (reportingCik) params.reportingCik = reportingCik;
1202
- if (companyCik) params.companyCik = companyCik;
1203
- if (transactionType) params.transactionType = transactionType;
1204
- return this.client.get(`/insider-trading`, "v4", params);
1205
- }
1206
- /**
1207
- * Get transaction types
1208
- * https://site.financialmodelingprep.com/developer/docs#transaction-types-insider-trading
1209
- * @returns A list of all insider transaction types
1210
- */
1211
- async getTransactionTypes() {
1212
- return this.client.get(`/insider-trading-transaction-type`, "v4");
1213
- }
1214
- /**
1215
- * Get insiders by symbol
1216
- * https://site.financialmodelingprep.com/developer/docs#insiders-by-symbol-insider-trading
1217
- * @param params - Parameters for the insiders request
1218
- * @returns A list of insiders for a specific company
1219
- */
1220
- async getInsidersBySymbol({
1221
- symbol
1222
- }) {
1223
- return this.client.get(`/insider-roaster`, "v4", { symbol });
1224
- }
1225
- /**
1226
- * Get insider trade statistics
1227
- * https://site.financialmodelingprep.com/developer/docs#insider-trade-statistics-insider-trading
1228
- * @param params - Parameters for the statistics request
1229
- * @returns Statistics on insider trading activity for a specific company
1230
- */
1231
- async getInsiderTradeStatistics({
1232
- symbol
1233
- }) {
1234
- return this.client.get(`/insider-roaster-statistic`, "v4", { symbol });
1235
- }
1236
- /**
1237
- * Get CIK mapper
1238
- * https://site.financialmodelingprep.com/developer/docs#cik-mapper-insider-trading
1239
- * @param params - Parameters for the CIK mapper request
1240
- * @returns A list of CIK numbers and corresponding company names
1241
- */
1242
- async getCikMapper({ page }) {
1243
- return this.client.get(`/mapper-cik-name`, "v4", { page });
1244
- }
1245
- /**
1246
- * Get CIK mapper by name
1247
- * https://site.financialmodelingprep.com/developer/docs#cik-mapper-by-name-insider-trading
1248
- * @param params - Parameters for the CIK mapper by name request
1249
- * @returns A list of CIK numbers and corresponding names matching the search term
1250
- */
1251
- async getCikMapperByName({
1252
- name,
1253
- page = 0
1254
- }) {
1255
- return this.client.get(`/mapper-cik-name`, "v4", { name, page });
1256
- }
1257
- /**
1258
- * Get CIK mapper by symbol
1259
- * https://site.financialmodelingprep.com/developer/docs#cik-mapper-company-insider-trading
1260
- * @param params - Parameters for the CIK mapper by symbol request
1261
- * @returns CIK number and corresponding company name for a specific symbol
1262
- */
1263
- async getCikMapperBySymbol({
1264
- symbol
1265
- }) {
1266
- return this.client.getSingle(`/mapper-cik-company/${symbol}`, "v4");
1267
- }
1268
- /**
1269
- * Get beneficial ownership acquisitions
1270
- * https://site.financialmodelingprep.com/developer/docs#acquisition-of-beneficial-ownership
1271
- * @param params - Parameters for the beneficial ownership request
1272
- * @returns A list of acquisitions of beneficial ownership for a specific company
1273
- */
1274
- async getBeneficialOwnership({
1275
- symbol
1276
- }) {
1277
- return this.client.get(`/insider/ownership/acquisition_of_beneficial_ownership`, "v4", {
1278
- symbol
1279
- });
1280
- }
1281
- /**
1282
- * Get fail to deliver data
1283
- * https://site.financialmodelingprep.com/developer/docs#fail-to-deliver
1284
- * @param params - Parameters for the fail to deliver request
1285
- * @returns A list of fail to deliver data for a specific company
1286
- */
1287
- async getFailToDeliver({
1288
- symbol,
1289
- page = 0
1290
- }) {
1291
- return this.client.get(`/fail_to_deliver`, "v4", { symbol, page });
1292
- }
1293
- /**
1294
- * Get all insider trades for a symbol (convenience method)
1295
- * @param symbol - The stock symbol to get insider trades for
1296
- * @param page - Page number for pagination (default: 0)
1297
- * @returns A list of insider trades for the specified symbol
1298
- */
1299
- async getInsiderTradesBySymbol(symbol, page = 0) {
1300
- return this.searchInsiderTrading({ symbol, page });
1301
- }
1302
- /**
1303
- * Get insider trades by transaction type (convenience method)
1304
- * @param transactionType - The transaction type to filter by
1305
- * @param page - Page number for pagination (default: 0)
1306
- * @returns A list of insider trades filtered by transaction type
1307
- */
1308
- async getInsiderTradesByType(transactionType, page = 0) {
1309
- return this.searchInsiderTrading({ transactionType, page });
1310
- }
1311
- /**
1312
- * Get insider trades by reporting CIK (convenience method)
1313
- * @param reportingCik - The reporting CIK to filter by
1314
- * @param page - Page number for pagination (default: 0)
1315
- * @returns A list of insider trades filtered by reporting CIK
1316
- */
1317
- async getInsiderTradesByReportingCik(reportingCik, page = 0) {
1318
- return this.searchInsiderTrading({ reportingCik, page });
1319
- }
1320
- /**
1321
- * Get insider trades by company CIK (convenience method)
1322
- * @param companyCik - The company CIK to filter by
1323
- * @param page - Page number for pagination (default: 0)
1324
- * @returns A list of insider trades filtered by company CIK
1325
- */
1326
- async getInsiderTradesByCompanyCik(companyCik, page = 0) {
1327
- return this.searchInsiderTrading({ companyCik, page });
1328
- }
1329
- };
1330
-
1331
- // src/endpoints/sec.ts
1332
- var SECEndpoints = class {
1333
- constructor(client) {
1334
- this.client = client;
1335
- }
1336
- /**
1337
- * Get RSS feed of SEC filings
1338
- * https://site.financialmodelingprep.com/developer/docs#rss-feed-securities-and-exchange-commission-(s.e.c)
1339
- * @param params - RSS feed parameters
1340
- * @returns A real-time feed of SEC filings from publicly traded companies, including the filing type, link to SEC page, and direct link to the filing. This endpoint can be used to stay up-to-date on the latest SEC filings for all companies or for a specific set of companies.
1341
- */
1342
- async getRSSFeed(params) {
1343
- return this.client.get("/rss_feed", "v4", params);
1344
- }
1345
- /**
1346
- * Get RSS feed of all SEC filings
1347
- * https://site.financialmodelingprep.com/developer/docs#rss-feed-all-securities-and-exchange-commission-(s.e.c)
1348
- * @param params - RSS feed all parameters
1349
- * @returns A real-time feed of all SEC filings from publicly traded companies in the latest RSS feed format. This endpoint provides a comprehensive overview of all SEC filings, including the filing type, link to SEC page, and direct link to the filing.
1350
- */
1351
- async getRSSFeedAll(params) {
1352
- return this.client.get("/rss_feed_all", "v4", params);
1353
- }
1354
- /**
1355
- * Get RSS feed V3 of SEC filings
1356
- * https://site.financialmodelingprep.com/developer/docs#rss-feed-v3-securities-and-exchange-commission-(s.e.c)
1357
- * @param params - RSS feed V3 parameters
1358
- * @returns A real-time feed of SEC filings from publicly traded companies in the latest RSS feed format (V3)
1359
- */
1360
- async getRSSFeedV3(params) {
1361
- return this.client.get("/rss_feed", "v3", params);
1362
- }
1363
- /**
1364
- * Get RSS feed of 8-K SEC filings
1365
- * https://site.financialmodelingprep.com/developer/docs#rss-feed-8-k-securities-and-exchange-commission-(s.e.c)
1366
- * @param params - RSS feed 8-K parameters
1367
- * @returns A real-time feed of 8-K SEC filings from publicly traded companies
1368
- */
1369
- async getRSSFeed8K(params) {
1370
- return this.client.get("/rss_feed_8k", "v4", params);
1371
- }
1372
- /**
1373
- * Get SEC filings for a specific company
1374
- * https://site.financialmodelingprep.com/developer/docs#sec-filings-securities-and-exchange-commission-(s.e.c)
1375
- * @param symbol - The stock symbol to get SEC filings for
1376
- * @param params - SEC filings parameters
1377
- * @returns Access direct links to SEC filings, including the filing type, link to the SEC page, and direct link to the specific filing
1378
- */
1379
- async getSECFilings({
1380
- symbol,
1381
- params
1382
- }) {
1383
- return this.client.get(`/sec_filings/${symbol}`, "v3", params);
1384
- }
1385
- /**
1386
- * Get individual industry classification
1387
- * https://site.financialmodelingprep.com/developer/docs#individual-industry-classification-standard-industrial-classification
1388
- * @param params - Industry classification parameters
1389
- * @returns Identify the industry in which a particular company operates, based on the Standard Industrial Classification (SIC) system
1390
- */
1391
- async getIndividualIndustryClassification(params) {
1392
- return this.client.getSingle("/standard_industrial_classification", "v4", params);
1393
- }
1394
- /**
1395
- * Get all industry classifications
1396
- * https://site.financialmodelingprep.com/developer/docs#all-industry-classification-standard-industrial-classification
1397
- * @returns Get a comprehensive overview of all industries, classified according to the SIC system
1398
- */
1399
- async getAllIndustryClassifications() {
1400
- return this.client.get("/standard_industrial_classification/all", "v4");
1401
- }
1402
- /**
1403
- * Get industry classification codes
1404
- * https://site.financialmodelingprep.com/developer/docs#industry-classification-codes-standard-industrial-classification
1405
- * @param params - Industry classification codes parameters
1406
- * @returns Learn more about the SIC system and identify the SIC code for a particular industry
1407
- */
1408
- async getIndustryClassificationCodes(params) {
1409
- return this.client.get("/standard_industrial_classification_list", "v4", params);
1410
- }
1411
- };
1412
-
1413
- // src/fmp.ts
1414
- var FMP = class {
1415
- constructor(config) {
1416
- validateApiKey(config.apiKey);
1417
- const client = new FMPClient(config);
1418
- this.stock = new StockEndpoints(client);
1419
- this.financial = new FinancialEndpoints(client);
1420
- this.crypto = new CryptoEndpoints(client);
1421
- this.etf = new ETFEndpoints(client);
1422
- this.market = new MarketEndpoints(client);
1423
- this.list = new ListEndpoints(client);
1424
- this.calendar = new CalendarEndpoints(client);
1425
- this.company = new CompanyEndpoints(client);
1426
- this.quote = new QuoteEndpoints(client);
1427
- this.senateHouse = new SenateHouseEndpoints(client);
1428
- this.institutional = new InstitutionalEndpoints(client);
1429
- this.insider = new InsiderEndpoints(client);
1430
- this.sec = new SECEndpoints(client);
1431
- this.forex = new ForexEndpoints(client);
1432
- this.economic = new EconomicEndpoints(client);
1433
- this.mutualFund = new MutualFundEndpoints(client);
1434
- }
1435
- /**
1436
- * Get the underlying client instance for advanced usage
1437
- */
1438
- getClient() {
1439
- return this.stock["client"];
1440
- }
1441
- };
1442
-
1443
- // src/types/common.ts
1444
- var Period = /* @__PURE__ */ ((Period2) => {
1445
- Period2["ANNUAL"] = "annual";
1446
- Period2["QUARTER"] = "quarter";
1447
- return Period2;
1448
- })(Period || {});
1449
- var Exchange = /* @__PURE__ */ ((Exchange2) => {
1450
- Exchange2["NYSE"] = "NYSE";
1451
- Exchange2["NASDAQ"] = "NASDAQ";
1452
- Exchange2["AMEX"] = "AMEX";
1453
- Exchange2["TSX"] = "TSX";
1454
- Exchange2["LSE"] = "LSE";
1455
- Exchange2["ASX"] = "ASX";
1456
- Exchange2["NSE"] = "NSE";
1457
- Exchange2["BSE"] = "BSE";
1458
- return Exchange2;
1459
- })(Exchange || {});
1460
-
1461
- // src/types/insider.ts
1462
- var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
1463
- TransactionType2["AWARD"] = "A-Award";
1464
- TransactionType2["CONVERSION"] = "C-Conversion";
1465
- TransactionType2["RETURN"] = "D-Return";
1466
- TransactionType2["EXPIRE_SHORT"] = "E-ExpireShort";
1467
- TransactionType2["IN_KIND"] = "F-InKind";
1468
- TransactionType2["GIFT"] = "G-Gift";
1469
- TransactionType2["EXPIRE_LONG"] = "H-ExpireLong";
1470
- TransactionType2["DISCRETIONARY"] = "I-Discretionary";
1471
- TransactionType2["OTHER"] = "J-Other";
1472
- TransactionType2["SMALL"] = "L-Small";
1473
- TransactionType2["EXEMPT"] = "M-Exempt";
1474
- TransactionType2["OUT_OF_THE_MONEY"] = "O-OutOfTheMoney";
1475
- TransactionType2["PURCHASE"] = "P-Purchase";
1476
- TransactionType2["SALE"] = "S-Sale";
1477
- TransactionType2["TENDER"] = "U-Tender";
1478
- TransactionType2["WILL"] = "W-Will";
1479
- TransactionType2["IN_THE_MONEY"] = "X-InTheMoney";
1480
- TransactionType2["TRUST"] = "Z-Trust";
1481
- return TransactionType2;
1482
- })(TransactionType || {});
1483
-
1484
- // src/utils/formatting.ts
1485
- function formatCurrency(value, currency = "USD") {
1486
- return new Intl.NumberFormat("en-US", {
1487
- style: "currency",
1488
- currency
1489
- }).format(value);
1490
- }
1491
- function formatPercentage(value, decimals = 2) {
1492
- return `${value.toFixed(decimals)}%`;
1493
- }
1494
- function formatLargeNumber(value) {
1495
- if (value >= 1e12) {
1496
- return `${(value / 1e12).toFixed(2)}T`;
1497
- } else if (value >= 1e9) {
1498
- return `${(value / 1e9).toFixed(2)}B`;
1499
- } else if (value >= 1e6) {
1500
- return `${(value / 1e6).toFixed(2)}M`;
1501
- } else if (value >= 1e3) {
1502
- return `${(value / 1e3).toFixed(2)}K`;
1503
- }
1504
- return value.toString();
1505
- }
1506
- function formatDate(date) {
1507
- const d = typeof date === "string" ? new Date(date) : date;
1508
- return d.toISOString().split("T")[0];
1509
- }
1510
- function formatReadableDate(date) {
1511
- const d = typeof date === "string" ? new Date(date) : date;
1512
- return d.toLocaleDateString("en-US", {
1513
- year: "numeric",
1514
- month: "long",
1515
- day: "numeric"
1516
- });
1517
- }
1518
- function formatTimestamp(timestamp) {
1519
- const date = new Date(timestamp * 1e3);
1520
- return date.toLocaleString("en-US");
1521
- }
1522
- function formatNumber(value, decimals = 2) {
1523
- return value.toFixed(decimals);
1524
- }
1525
- function formatVolume(volume) {
1526
- if (volume >= 1e9) {
1527
- return `${(volume / 1e9).toFixed(2)}B`;
1528
- } else if (volume >= 1e6) {
1529
- return `${(volume / 1e6).toFixed(2)}M`;
1530
- } else if (volume >= 1e3) {
1531
- return `${(volume / 1e3).toFixed(2)}K`;
1532
- }
1533
- return volume.toString();
1534
- }
1535
-
1536
- // src/utils/constants.ts
1537
- var DEFAULT_TIMEOUT = 1e4;
1538
- var DEFAULT_LIMIT = 100;
1539
- var MAX_LIMIT = 1e3;
1540
- var PERIODS = {
1541
- ANNUAL: "annual",
1542
- QUARTER: "quarter"
1543
- };
1544
- var EXCHANGES = {
1545
- NYSE: "NYSE",
1546
- NASDAQ: "NASDAQ",
1547
- AMEX: "AMEX",
1548
- TSX: "TSX",
1549
- LSE: "LSE",
1550
- ASX: "ASX",
1551
- NSE: "NSE",
1552
- BSE: "BSE"
1553
- };
1554
- var SECTORS = {
1555
- TECHNOLOGY: "Technology",
1556
- HEALTHCARE: "Healthcare",
1557
- FINANCIAL: "Financial",
1558
- CONSUMER_DISCRETIONARY: "Consumer Discretionary",
1559
- CONSUMER_STAPLES: "Consumer Staples",
1560
- INDUSTRIALS: "Industrials",
1561
- ENERGY: "Energy",
1562
- MATERIALS: "Materials",
1563
- UTILITIES: "Utilities",
1564
- REAL_ESTATE: "Real Estate",
1565
- COMMUNICATION_SERVICES: "Communication Services"
1566
- };
1567
- var COUNTRIES = {
1568
- US: "US",
1569
- CA: "CA",
1570
- GB: "GB",
1571
- AU: "AU",
1572
- IN: "IN",
1573
- DE: "DE",
1574
- FR: "FR",
1575
- JP: "JP",
1576
- CN: "CN",
1577
- BR: "BR"
1578
- };
1579
- var ERROR_MESSAGES = {
1580
- API_KEY_REQUIRED: "API key is required",
1581
- SYMBOL_REQUIRED: "Symbol is required",
1582
- INVALID_SYMBOL: "Invalid symbol format",
1583
- INVALID_DATE: "Invalid date format. Use YYYY-MM-DD",
1584
- INVALID_PERIOD: 'Period must be either "annual" or "quarter"',
1585
- INVALID_LIMIT: "Limit must be between 1 and 1000",
1586
- INVALID_PAGE: "Page must be a non-negative number",
1587
- REQUEST_FAILED: "Request failed",
1588
- RATE_LIMIT_EXCEEDED: "Rate limit exceeded",
1589
- UNAUTHORIZED: "Unauthorized - Invalid API key",
1590
- NOT_FOUND: "Resource not found"
1591
- };
1592
- var HTTP_STATUS = {
1593
- OK: 200,
1594
- CREATED: 201,
1595
- BAD_REQUEST: 400,
1596
- UNAUTHORIZED: 401,
1597
- FORBIDDEN: 403,
1598
- NOT_FOUND: 404,
1599
- TOO_MANY_REQUESTS: 429,
1600
- INTERNAL_SERVER_ERROR: 500
1601
- };
1602
-
1603
- exports.COUNTRIES = COUNTRIES;
1604
- exports.CalendarEndpoints = CalendarEndpoints;
1605
- exports.CompanyEndpoints = CompanyEndpoints;
1606
- exports.CryptoEndpoints = CryptoEndpoints;
1607
- exports.DEFAULT_LIMIT = DEFAULT_LIMIT;
1608
- exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
1609
- exports.ERROR_MESSAGES = ERROR_MESSAGES;
1610
- exports.ETFEndpoints = ETFEndpoints;
1611
- exports.EXCHANGES = EXCHANGES;
1612
- exports.EconomicEndpoints = EconomicEndpoints;
1613
- exports.Exchange = Exchange;
1614
- exports.FMP = FMP;
1615
- exports.FMPClient = FMPClient;
1616
- exports.FinancialEndpoints = FinancialEndpoints;
1617
- exports.ForexEndpoints = ForexEndpoints;
1618
- exports.HTTP_STATUS = HTTP_STATUS;
1619
- exports.InsiderEndpoints = InsiderEndpoints;
1620
- exports.InstitutionalEndpoints = InstitutionalEndpoints;
1621
- exports.ListEndpoints = ListEndpoints;
1622
- exports.MAX_LIMIT = MAX_LIMIT;
1623
- exports.MarketEndpoints = MarketEndpoints;
1624
- exports.MutualFundEndpoints = MutualFundEndpoints;
1625
- exports.PERIODS = PERIODS;
1626
- exports.Period = Period;
1627
- exports.QuoteEndpoints = QuoteEndpoints;
1628
- exports.SECEndpoints = SECEndpoints;
1629
- exports.SECTORS = SECTORS;
1630
- exports.SenateHouseEndpoints = SenateHouseEndpoints;
1631
- exports.StockEndpoints = StockEndpoints;
1632
- exports.TransactionType = TransactionType;
1633
- exports.formatCurrency = formatCurrency;
1634
- exports.formatDate = formatDate;
1635
- exports.formatLargeNumber = formatLargeNumber;
1636
- exports.formatNumber = formatNumber;
1637
- exports.formatPercentage = formatPercentage;
1638
- exports.formatReadableDate = formatReadableDate;
1639
- exports.formatTimestamp = formatTimestamp;
1640
- exports.formatVolume = formatVolume;
1641
- exports.validateApiKey = validateApiKey;
1642
- exports.validateDate = validateDate;
1643
- exports.validateLimit = validateLimit;
1644
- exports.validatePage = validatePage;
1645
- exports.validatePeriod = validatePeriod;
1646
- exports.validateSymbol = validateSymbol;
1647
- //# sourceMappingURL=index.js.map
1648
- //# sourceMappingURL=index.js.map
1
+ 'use strict';var C=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var C__default=/*#__PURE__*/_interopDefault(C);function E(i){return Array.isArray(i)&&i.length===1?i[0]:i}function v(i){return Array.isArray(i)?i:i??[]}function F(i){return i==null?{}:Array.isArray(i)&&i.length===0?{}:i}var l=class{constructor(e){if(!e.apiKey)throw new Error("API key is required for FMPClient");this.apiKey=e.apiKey,this.v3Client=C__default.default.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=C__default.default.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=C__default.default.create({baseURL:"https://financialmodelingprep.com/stable",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),[this.v3Client,this.v4Client,this.stableClient].forEach(t=>{t.interceptors.request.use(r=>(r.params={...r.params,apikey:this.apiKey},r));});}async get(e,t="v3",r){let n=this.getClientForVersion(t);try{let s=await n.get(e,{params:r}),o=s.data;return (Array.isArray(o)||o==null)&&(o=v(o)),{success:!0,data:o,error:null,status:s.status}}catch(s){return {success:false,data:null,error:s.message||"Unknown error occurred",status:s.response?.status||500}}}async getSingle(e,t="v3",r){let n=this.getClientForVersion(t);try{let s=await n.get(e,{params:r});return {success:!0,data:F(E(s.data)),error:null,status:s.status}}catch(s){return {success:false,data:null,error:s.message||"Unknown error occurred",status:s.response?.status||500}}}getClientForVersion(e){switch(e){case "v3":return this.v3Client;case "v4":return this.v4Client;case "stable":return this.stableClient;default:return this.v3Client}}};var c=class{static isValidSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{1,5}$/.test(e)}static isValidCryptoSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(e)}static isValidForexPair(e){return !e||typeof e!="string"?false:/^[A-Z]{3}[A-Z]{3}$/.test(e)}static isValidDate(e){if(!e||typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return false;let r=new Date(e);return !isNaN(r.getTime())&&r.toISOString().split("T")[0]===e}static isValidDateRange(e,t){if(!this.isValidDate(e)||!this.isValidDate(t))return false;let r=new Date(e),n=new Date(t);return r<=n}static isValidResponse(e){return !!(e&&typeof e=="object"&&typeof e.success=="boolean")}static isValidApiKey(e){return !e||typeof e!="string"?false:/^[a-zA-Z0-9]{32,}$/.test(e)}static isValidPeriod(e){return !e||typeof e!="string"?false:["annual","quarter","fy"].includes(e.toLowerCase())}static isValidLimit(e){return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=1e3}static validateQuoteParams(e){let t=[];return e?(e.symbol?!this.isValidSymbol(e.symbol)&&!this.isValidCryptoSymbol(e.symbol)&&!this.isValidForexPair(e.symbol)&&t.push("Invalid symbol format"):t.push("Symbol is required"),e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static validateFinancialParams(e){let t=[];return e?(e.symbol?this.isValidSymbol(e.symbol)||t.push("Invalid symbol format"):t.push("Symbol is required"),e.period&&!this.isValidPeriod(e.period)&&t.push('Invalid period (must be "annual", "quarter", or "FY")'),e.limit&&!this.isValidLimit(e.limit)&&t.push("Invalid limit (must be a positive integer <= 1000)"),t):(t.push("Parameters object is required"),t)}static validateDateRangeParams(e){let t=[];return e?(e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static throwIfInvalid(e,t="Validation"){if(e.length>0)throw new Error(`${t} failed: ${e.join(", ")}`)}};var m=class{constructor(e){this.client=e;}async getMarketCap(e){return this.client.getSingle(`/market-capitalization/${e}`,"v3")}async getStockSplits(e){return this.client.get(`/historical-price-full/stock_split/${e}`,"v3")}async getDividendHistory(e){return this.client.getSingle(`/historical-price-full/stock_dividend/${e}`,"v3")}async getRealTimePrice(e){let t=`stock/real-time-price/${e.join(",")}`,r=await this.client.get(t,"v3");if(r.success&&r.data&&!Array.isArray(r.data)){let s=r.data;if(typeof s=="object"&&s!==null&&"companiesPriceList"in s&&Array.isArray(s.companiesPriceList)){let o=s.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...r,data:o}}if(typeof s=="object"&&s!==null&&"stockList"in s&&Array.isArray(s.stockList)){let o=s.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...r,data:o}}return s.symbol?{...r,data:[s]}:(e.length===1&&console.warn(`No real-time price data found for symbol: ${e[0]}`),{...r,data:[]})}let n=r.data.filter(s=>s&&s.symbol);return {...r,data:n}}async getRealTimePriceForMultipleStocks(e){let t=`stock/full/real-time-price/${e.join(",")}`,r=await this.client.get(t,"v3");if(r.success&&r.data&&!Array.isArray(r.data)){let s=r.data;if(typeof s=="object"&&s!==null&&"companiesPriceList"in s&&Array.isArray(s.companiesPriceList)){let o=s.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...r,data:o}}if(typeof s=="object"&&s!==null&&"stockList"in s&&Array.isArray(s.stockList)){let o=s.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...r,data:o}}return s.symbol?{...r,data:[s]}:(e.length===1&&console.warn(`No full real-time price data found for symbol: ${e[0]}`),{...r,data:[]})}let n=r.data.filter(s=>s&&s.symbol);return {...r,data:n}}};var p=class{constructor(e){this.client=e;}async getIncomeStatement(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/income-statement/${t}?period=${r}&limit=${n}`,"v3")}async getBalanceSheet(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/balance-sheet-statement/${t}?period=${r}&limit=${n}`,"v3")}async getCashFlowStatement(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/cash-flow-statement/${t}?period=${r}&limit=${n}`,"v3")}async getKeyMetrics(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/key-metrics/${t}?period=${r}&limit=${n}`,"v3")}async getFinancialRatios(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/ratios/${t}?period=${r}&limit=${n}`,"v3")}async getEnterpriseValue(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/enterprise-value/${t}?period=${r}&limit=${n}`,"v3")}async getCashflowGrowth(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/cash-flow-statement-growth/${t}?period=${r}&limit=${n}`,"v3")}async getIncomeGrowth(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/income-statement-growth/${t}?period=${r}&limit=${n}`,"v3")}async getBalanceSheetGrowth(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/balance-sheet-statement-growth/${t}?period=${r}&limit=${n}`,"v3")}async getFinancialGrowth(e){let{symbol:t,period:r="annual",limit:n=5}=e;return this.client.get(`/financial-growth/${t}?period=${r}&limit=${n}`,"v3")}async getEarningsHistorical(e){let{symbol:t,limit:r=5}=e;return this.client.get(`/historical/earning_calendar/${t}?limit=${r}`,"v3")}async getEarningsSurprises(e){return this.client.get(`/earnings-surprises/${e}`,"v3")}};var u=class{constructor(e){this.client=e;}async getHoldingDates(e){return this.client.get("/etf-holdings/portfolio-date","v4",{symbol:e})}async getHoldings(e){let{symbol:t,date:r}=e,n={};return t&&(n.symbol=t),r&&(n.date=r),this.client.get("/etf-holdings","v4",n)}async getHolder(e){return this.client.get(`/etf-holder/${e}`,"v3")}async getProfile(e){return this.client.getSingle("/etf-info","v4",{symbol:e})}async getSectorWeighting(e){return this.client.get(`/etf-sector-weightings/${e}`,"v3")}async getCountryWeighting(e){return this.client.get(`/etf-country-weightings/${e}`,"v3")}async getStockExposure(e){return this.client.get(`/etf-stock-exposure/${e}`,"v3")}};var g=class{constructor(e){this.client=e;}async getTreasuryRates(e){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/treasury","v4",n)}async getEconomicIndicators(e){let{name:t,from:r,to:n}=e,s={name:t};return r&&(s.from=r),n&&(s.to=n),this.client.get("/economic","v4",s)}};var d=class{constructor(e){this.client=e;}async getMarketHours(){return this.client.get("/market-hours","v3")}async getMarketPerformance(){return this.client.get("/market-performance","v3")}async getGainers(){return this.client.get("/stock_market/gainers","v3")}async getLosers(){return this.client.get("/stock_market/losers","v3")}async getMostActive(){return this.client.get("/stock_market/actives","v3")}async getSectorPerformance(){return this.client.get("/sector-performance","v3")}async getMarketIndex(){return this.client.get("/quotes/index","v3")}};var f=class{constructor(e){this.client=e;}async getStockList(){return this.client.get("/stock/list")}async getETFList(){return this.client.get("/etf/list")}async getCryptoList(){return this.client.get("/symbol/available-cryptocurrencies")}async getForexList(){return this.client.get("/symbol/available-forex-currency-pairs")}async getAvailableIndexes(){return this.client.get("/symbol/available-indexes")}};var y=class{constructor(e){this.client=e;}async getEarningsCalendar(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/earning_calendar","v3",n)}async getEarningsConfirmed(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/earning-calendar-confirmed","v4",n)}async getDividendsCalendar(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/stock_dividend_calendar","v3",n)}async getEconomicsCalendar(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/economic_calendar","v3",n)}async getIPOCalendar(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/ipo_calendar","v3",n)}async getSplitsCalendar(e={}){let{from:t,to:r}=e,n={};return t&&(n.from=t),r&&(n.to=r),this.client.get("/stock_split_calendar","v3",n)}};var P=class{constructor(e){this.client=e;}async getCompanyProfile(e){return this.client.getSingle(`/profile/${e}`,"v3")}async getExecutiveCompensation(e){return this.client.get("/governance/executive_compensation","v4",{symbol:e})}async getCompanyNotes(e){return this.client.get("/company-notes","v4",{symbol:e})}async getHistoricalEmployeeCount(e){return this.client.get("/historical/employee_count","v4",{symbol:e})}async getSharesFloat(e){return this.client.getSingle("/shares_float","v4",{symbol:e})}async getHistoricalSharesFloat(e){return this.client.get("/historical/shares_float","v4",{symbol:e})}async getEarningsCallTranscript(e){let{symbol:t,year:r,quarter:n}=e;return this.client.getSingle(`/earning_call_transcript/${t}`,"v3",{year:r,quarter:n})}async getCompanyTranscriptData(e){return this.client.getSingle("/earning_call_transcript","v4",{symbol:e})}};var R=class{constructor(e){this.client=e;}async getQuote(e){return this.client.getSingle(`/quote/${e}`,"v3")}async getHistoricalPrice(e){let{symbol:t,from:r,to:n}=e,s={};return r&&(s.from=r),n&&(s.to=n),this.client.getSingle(`/historical-price-full/${t}`,"v3",s)}async getQuotes(e){let t=e.join(",");return this.client.get(`/quote/${t}`,"v3")}async getIntraday(e){let{symbol:t,interval:r,from:n,to:s}=e,o={};return n&&(o.from=n),s&&(o.to=s),this.client.get(`/historical-chart/${r}/${t}`,"v3",o)}};var h=class{constructor(e){this.client=e;}async getSenateTrading(e){let{symbol:t}=e;return this.client.get("/senate-trading","v4",{symbol:t})}async getSenateTradingRSSFeed(e){let{page:t}=e;return this.client.get("/senate-trading-rss-feed","v4",{page:t})}async getSenateTradingByName(e){let{name:t}=e;return this.client.get("/senate-trades-by-name","stable",{name:t})}async getHouseTrading(e){let{symbol:t}=e;return this.client.get("/senate-disclosure","v4",{symbol:t})}async getHouseTradingRSSFeed(e){let{page:t}=e;return this.client.get("/senate-disclosure-rss-feed","v4",{page:t})}async getHouseTradingByName(e){let{name:t}=e;return this.client.get("/house-trades-by-name","stable",{name:t})}};var I=class{constructor(e){this.client=e;}async getForm13F(e){let{cik:t,date:r}=e,n={};return r&&(n.date=r),this.client.get(`/form-thirteen/${t}`,"v3",n)}async getForm13FDates(e){let{cik:t}=e;return this.client.get(`/form-thirteen-date/${t}`,"v3")}async getInstitutionalHolders(e){let{symbol:t}=e;return this.client.get(`/institutional-holder/${t}`,"v3")}};var S=class{constructor(e){this.client=e;}async getInsiderTradingRSS(e){let{page:t=0}=e;return this.client.get("/insider-trading-rss-feed","v4",{page:t})}async searchInsiderTrading(e){let{symbol:t,reportingCik:r,companyCik:n,transactionType:s,page:o=0}=e,a={page:o};return t&&(a.symbol=t),r&&(a.reportingCik=r),n&&(a.companyCik=n),s&&(a.transactionType=s),this.client.get("/insider-trading","v4",a)}async getTransactionTypes(){return this.client.get("/insider-trading-transaction-type","v4")}async getInsidersBySymbol(e){let{symbol:t}=e;return this.client.get("/insider-roaster","v4",{symbol:t})}async getInsiderTradeStatistics(e){let{symbol:t}=e;return this.client.get("/insider-roaster-statistic","v4",{symbol:t})}async getCikMapper(e){let{page:t=0}=e;return this.client.get("/mapper-cik-name","v4",{page:t})}async getCikMapperByName(e){let{name:t,page:r=0}=e;return this.client.get("/mapper-cik-name","v4",{name:t,page:r})}async getCikMapperBySymbol(e){let{symbol:t}=e;return this.client.getSingle(`/mapper-cik-company/${t}`,"v4")}async getBeneficialOwnership(e){let{symbol:t}=e;return this.client.get("/insider/ownership/acquisition_of_beneficial_ownership","v4",{symbol:t})}async getFailToDeliver(e){let{symbol:t,page:r=0}=e;return this.client.get("/fail_to_deliver","v4",{symbol:t,page:r})}async getInsiderTradesBySymbol(e,t=0){return this.searchInsiderTrading({symbol:e,page:t})}async getInsiderTradesByType(e,t=0){return this.searchInsiderTrading({transactionType:e,page:t})}async getInsiderTradesByReportingCik(e,t=0){return this.searchInsiderTrading({reportingCik:e,page:t})}async getInsiderTradesByCompanyCik(e,t=0){return this.searchInsiderTrading({companyCik:e,page:t})}};var A=class{constructor(e){this.client=e;}async getRSSFeed(e){return this.client.get("/rss_feed","v4",e)}async getRSSFeedAll(e){return this.client.get("/rss_feed_all","v4",e)}async getRSSFeedV3(e){return this.client.get("/rss_feed","v3",e)}async getRSSFeed8K(e){return this.client.get("/rss_feed_8k","v4",e)}async getSECFilings({symbol:e,params:t}){return this.client.get(`/sec_filings/${e}`,"v3",t)}async getIndividualIndustryClassification(e){return this.client.getSingle("/standard_industrial_classification","v4",e)}async getAllIndustryClassifications(){return this.client.get("/standard_industrial_classification/all","v4")}async getIndustryClassificationCodes(e){return this.client.get("/standard_industrial_classification_list","v4",e)}};var b=class{constructor(e){this.client=e;}async getHolders(e){return this.client.get(`/mutual-fund-holder/${e}`,"v3")}};var T=class{constructor(e={}){let t=e.apiKey||process.env.FMP_API_KEY;if(!t)throw new Error("FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable.");if(!c.isValidApiKey(t))throw new Error("Invalid API key format");let r=new l({...e,apiKey:t});this.stock=new m(r),this.financial=new p(r),this.etf=new u(r),this.economic=new g(r),this.market=new d(r),this.list=new f(r),this.calendar=new y(r),this.company=new P(r),this.quote=new R(r),this.senateHouse=new h(r),this.institutional=new I(r),this.insider=new S(r),this.sec=new A(r),this.mutualFund=new b(r);}getClient(){return this.stock.client}};function k(i,e="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:e}).format(i)}function M(i,e=2){return `${i.toFixed(e)}%`}function D(i){return i>=1e12?`${(i/1e12).toFixed(2)}T`:i>=1e9?`${(i/1e9).toFixed(2)}B`:i>=1e6?`${(i/1e6).toFixed(2)}M`:i>=1e3?`${(i/1e3).toFixed(2)}K`:i.toString()}function x(i){return (typeof i=="string"?new Date(i):i).toISOString().split("T")[0]}function w(i){return i>=1e9?`${(i/1e9).toFixed(2)}B`:i>=1e6?`${(i/1e6).toFixed(2)}M`:i>=1e3?`${(i/1e3).toFixed(2)}K`:i.toString()}var L=1e4,_=100,$=1e3,N={ANNUAL:"annual",QUARTER:"quarter"},H={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},q={TECHNOLOGY:"Technology",HEALTHCARE:"Healthcare",FINANCIAL:"Financial",CONSUMER_DISCRETIONARY:"Consumer Discretionary",CONSUMER_STAPLES:"Consumer Staples",INDUSTRIALS:"Industrials",ENERGY:"Energy",MATERIALS:"Materials",UTILITIES:"Utilities",REAL_ESTATE:"Real Estate",COMMUNICATION_SERVICES:"Communication Services"};
2
+ exports.CalendarEndpoints=y;exports.CompanyEndpoints=P;exports.DEFAULT_LIMIT=_;exports.DEFAULT_TIMEOUT=L;exports.ETFEndpoints=u;exports.EXCHANGES=H;exports.EconomicEndpoints=g;exports.FMP=T;exports.FMPClient=l;exports.FMPValidation=c;exports.FinancialEndpoints=p;exports.InsiderEndpoints=S;exports.InstitutionalEndpoints=I;exports.ListEndpoints=f;exports.MAX_LIMIT=$;exports.MarketEndpoints=d;exports.MutualFundEndpoints=b;exports.PERIODS=N;exports.QuoteEndpoints=R;exports.SECEndpoints=A;exports.SECTORS=q;exports.SenateHouseEndpoints=h;exports.StockEndpoints=m;exports.formatCurrency=k;exports.formatDate=x;exports.formatLargeNumber=D;exports.formatPercentage=M;exports.formatVolume=w;