fmp-node-api 0.1.0 → 0.1.2

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.mjs CHANGED
@@ -1,4137 +1,2 @@
1
- import axios from 'axios';
2
-
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
- }
10
- function normalizeArrayResponse(data) {
11
- if (Array.isArray(data)) return data;
12
- if (data == null) return [];
13
- return data;
14
- }
15
- function normalizeObjectResponse(data) {
16
- if (data == null) return {};
17
- if (Array.isArray(data) && data.length === 0) return {};
18
- return data;
19
- }
20
- var FMPClient = class {
21
- constructor(config) {
22
- if (!config.apiKey) {
23
- throw new Error("API key is required for FMPClient");
24
- }
25
- this.apiKey = config.apiKey;
26
- this.v3Client = axios.create({
27
- baseURL: "https://financialmodelingprep.com/api/v3",
28
- timeout: config.timeout || 1e4,
29
- headers: { "Content-Type": "application/json" }
30
- });
31
- this.v4Client = axios.create({
32
- baseURL: "https://financialmodelingprep.com/api/v4",
33
- timeout: config.timeout || 1e4,
34
- headers: { "Content-Type": "application/json" }
35
- });
36
- this.stableClient = axios.create({
37
- baseURL: "https://financialmodelingprep.com/stable",
38
- timeout: config.timeout || 1e4,
39
- headers: { "Content-Type": "application/json" }
40
- });
41
- [this.v3Client, this.v4Client, this.stableClient].forEach((client) => {
42
- client.interceptors.request.use((config2) => {
43
- config2.params = { ...config2.params, apikey: this.apiKey };
44
- return config2;
45
- });
46
- });
47
- }
48
- /**
49
- * Standard get method - returns raw API response
50
- *
51
- * For endpoints that return arrays, this will always return an array (possibly empty) for `data` when success is true.
52
- * For endpoints that return objects, data is returned as-is.
53
- */
54
- async get(endpoint, version = "v3", params) {
55
- const client = this.getClientForVersion(version);
56
- try {
57
- const response = await client.get(endpoint, { params });
58
- let data = response.data;
59
- if (Array.isArray(data) || data == null) {
60
- data = normalizeArrayResponse(data);
61
- }
62
- return {
63
- success: true,
64
- data,
65
- error: null,
66
- status: response.status
67
- };
68
- } catch (error) {
69
- return {
70
- success: false,
71
- data: null,
72
- error: error.message || "Unknown error occurred",
73
- status: error.response?.status || 500
74
- };
75
- }
76
- }
77
- /**
78
- * Get method for single-object endpoints - unwraps single-item arrays
79
- *
80
- * For endpoints that return single objects, this will always return an object (possibly empty) for `data` when success is true.
81
- */
82
- async getSingle(endpoint, version = "v3", params) {
83
- const client = this.getClientForVersion(version);
84
- try {
85
- const response = await client.get(endpoint, { params });
86
- const data = normalizeObjectResponse(unwrapSingleObject(response.data));
87
- return {
88
- success: true,
89
- data,
90
- error: null,
91
- status: response.status
92
- };
93
- } catch (error) {
94
- return {
95
- success: false,
96
- data: null,
97
- error: error.message || "Unknown error occurred",
98
- status: error.response?.status || 500
99
- };
100
- }
101
- }
102
- getClientForVersion(version) {
103
- switch (version) {
104
- case "v3":
105
- return this.v3Client;
106
- case "v4":
107
- return this.v4Client;
108
- case "stable":
109
- return this.stableClient;
110
- default:
111
- return this.v3Client;
112
- }
113
- }
114
- };
115
-
116
- // src/utils/validation.ts
117
- var FMPValidation = class {
118
- /**
119
- * Validate stock symbol format
120
- * @param symbol - The symbol to validate
121
- * @returns True if the symbol format is valid
122
- */
123
- static isValidSymbol(symbol) {
124
- if (!symbol || typeof symbol !== "string") {
125
- return false;
126
- }
127
- return /^[A-Z]{1,5}$/.test(symbol);
128
- }
129
- /**
130
- * Validate crypto symbol format
131
- * @param symbol - The crypto symbol to validate
132
- * @returns True if the crypto symbol format is valid
133
- */
134
- static isValidCryptoSymbol(symbol) {
135
- if (!symbol || typeof symbol !== "string") {
136
- return false;
137
- }
138
- return /^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(symbol);
139
- }
140
- /**
141
- * Validate forex pair format
142
- * @param symbol - The forex pair to validate
143
- * @returns True if the forex pair format is valid
144
- */
145
- static isValidForexPair(symbol) {
146
- if (!symbol || typeof symbol !== "string") {
147
- return false;
148
- }
149
- return /^[A-Z]{3}[A-Z]{3}$/.test(symbol);
150
- }
151
- /**
152
- * Validate date format (YYYY-MM-DD)
153
- * @param date - The date string to validate
154
- * @returns True if the date format is valid
155
- */
156
- static isValidDate(date) {
157
- if (!date || typeof date !== "string") {
158
- return false;
159
- }
160
- const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
161
- if (!dateRegex.test(date)) {
162
- return false;
163
- }
164
- const dateObj = new Date(date);
165
- return !isNaN(dateObj.getTime()) && dateObj.toISOString().split("T")[0] === date;
166
- }
167
- /**
168
- * Validate date range
169
- * @param from - Start date
170
- * @param to - End date
171
- * @returns True if the date range is valid
172
- */
173
- static isValidDateRange(from, to) {
174
- if (!this.isValidDate(from) || !this.isValidDate(to)) {
175
- return false;
176
- }
177
- const fromDate = new Date(from);
178
- const toDate = new Date(to);
179
- return fromDate <= toDate;
180
- }
181
- /**
182
- * Validate API response structure
183
- * @param response - The response to validate
184
- * @returns True if the response has the expected structure
185
- */
186
- static isValidResponse(response) {
187
- return Boolean(
188
- response && typeof response === "object" && typeof response.success === "boolean"
189
- );
190
- }
191
- /**
192
- * Validate API key format
193
- * @param apiKey - The API key to validate
194
- * @returns True if the API key format is valid
195
- */
196
- static isValidApiKey(apiKey) {
197
- if (!apiKey || typeof apiKey !== "string") {
198
- return false;
199
- }
200
- return /^[a-zA-Z0-9]{32,}$/.test(apiKey);
201
- }
202
- /**
203
- * Validate period parameter
204
- * @param period - The period to validate
205
- * @returns True if the period is valid
206
- */
207
- static isValidPeriod(period) {
208
- if (!period || typeof period !== "string") {
209
- return false;
210
- }
211
- return ["annual", "quarter", "fy"].includes(period.toLowerCase());
212
- }
213
- /**
214
- * Validate limit parameter
215
- * @param limit - The limit to validate
216
- * @returns True if the limit is valid
217
- */
218
- static isValidLimit(limit) {
219
- return typeof limit === "number" && Number.isInteger(limit) && limit > 0 && limit <= 1e3;
220
- }
221
- /**
222
- * Get validation errors for quote parameters
223
- * @param params - The parameters to validate
224
- * @returns Array of validation error messages
225
- */
226
- static validateQuoteParams(params) {
227
- const errors = [];
228
- if (!params) {
229
- errors.push("Parameters object is required");
230
- return errors;
231
- }
232
- if (!params.symbol) {
233
- errors.push("Symbol is required");
234
- } else if (!this.isValidSymbol(params.symbol) && !this.isValidCryptoSymbol(params.symbol) && !this.isValidForexPair(params.symbol)) {
235
- errors.push("Invalid symbol format");
236
- }
237
- if (params.from && !this.isValidDate(params.from)) {
238
- errors.push("Invalid from date format (expected YYYY-MM-DD)");
239
- }
240
- if (params.to && !this.isValidDate(params.to)) {
241
- errors.push("Invalid to date format (expected YYYY-MM-DD)");
242
- }
243
- if (params.from && params.to && !this.isValidDateRange(params.from, params.to)) {
244
- errors.push("From date must be before or equal to to date");
245
- }
246
- return errors;
247
- }
248
- /**
249
- * Get validation errors for financial statement parameters
250
- * @param params - The parameters to validate
251
- * @returns Array of validation error messages
252
- */
253
- static validateFinancialParams(params) {
254
- const errors = [];
255
- if (!params) {
256
- errors.push("Parameters object is required");
257
- return errors;
258
- }
259
- if (!params.symbol) {
260
- errors.push("Symbol is required");
261
- } else if (!this.isValidSymbol(params.symbol)) {
262
- errors.push("Invalid symbol format");
263
- }
264
- if (params.period && !this.isValidPeriod(params.period)) {
265
- errors.push('Invalid period (must be "annual", "quarter", or "FY")');
266
- }
267
- if (params.limit && !this.isValidLimit(params.limit)) {
268
- errors.push("Invalid limit (must be a positive integer <= 1000)");
269
- }
270
- return errors;
271
- }
272
- /**
273
- * Get validation errors for date range parameters
274
- * @param params - The parameters to validate
275
- * @returns Array of validation error messages
276
- */
277
- static validateDateRangeParams(params) {
278
- const errors = [];
279
- if (!params) {
280
- errors.push("Parameters object is required");
281
- return errors;
282
- }
283
- if (params.from && !this.isValidDate(params.from)) {
284
- errors.push("Invalid from date format (expected YYYY-MM-DD)");
285
- }
286
- if (params.to && !this.isValidDate(params.to)) {
287
- errors.push("Invalid to date format (expected YYYY-MM-DD)");
288
- }
289
- if (params.from && params.to && !this.isValidDateRange(params.from, params.to)) {
290
- errors.push("From date must be before or equal to to date");
291
- }
292
- return errors;
293
- }
294
- /**
295
- * Validate and throw error if validation fails
296
- * @param errors - Array of validation errors
297
- * @param context - Context for the error message
298
- */
299
- static throwIfInvalid(errors, context = "Validation") {
300
- if (errors.length > 0) {
301
- throw new Error(`${context} failed: ${errors.join(", ")}`);
302
- }
303
- }
304
- };
305
-
306
- // src/endpoints/stock.ts
307
- var StockEndpoints = class {
308
- constructor(client) {
309
- this.client = client;
310
- }
311
- /**
312
- * Get current market capitalization for a stock
313
- *
314
- * Market capitalization represents the total value of a company's outstanding shares.
315
- * Calculated by multiplying the current share price by the number of outstanding shares.
316
- * This metric is crucial for understanding a company's size and market position.
317
- *
318
- * @param symbol - The stock symbol to get market cap for (e.g., 'AAPL', 'MSFT', 'GOOGL')
319
- *
320
- * @returns Promise resolving to market cap data including symbol, date, and market cap value
321
- *
322
- * @example
323
- * ```typescript
324
- * // Get market cap for Apple
325
- * const marketCap = await fmp.stock.getMarketCap('AAPL');
326
- * console.log(`Apple's market cap: $${marketCap.data.marketCap.toLocaleString()}`);
327
- *
328
- * // Get market cap for Microsoft
329
- * const msftCap = await fmp.stock.getMarketCap('MSFT');
330
- * ```
331
- *
332
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-cap-company-information|FMP Market Cap Documentation}
333
- */
334
- async getMarketCap(symbol) {
335
- return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
336
- }
337
- /**
338
- * Get historical stock splits for a company
339
- *
340
- * Stock splits occur when a company increases the number of shares by dividing existing shares.
341
- * This endpoint provides the complete history of stock splits including dates, ratios, and split types.
342
- * Useful for adjusting historical price data and understanding corporate actions.
343
- *
344
- * @param symbol - The stock symbol to get split history for (e.g., 'AAPL', 'TSLA', 'NVDA')
345
- *
346
- * @returns Promise resolving to historical stock splits with dates, labels, and split ratios
347
- *
348
- * @example
349
- * ```typescript
350
- * // Get Apple's split history
351
- * const splits = await fmp.stock.getStockSplits('AAPL');
352
- * splits.data.historical.forEach(split => {
353
- * console.log(`${split.date}: ${split.numerator}:${split.denominator} split`);
354
- * });
355
- *
356
- * // Get Tesla's split history
357
- * const teslaSplits = await fmp.stock.getStockSplits('TSLA');
358
- * ```
359
- *
360
- * @see {@link https://site.financialmodelingprep.com/developer/docs#splits-historical-splits|FMP Stock Splits Documentation}
361
- */
362
- async getStockSplits(symbol) {
363
- return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
364
- }
365
- /**
366
- * Get historical dividend payments for a stock
367
- *
368
- * Dividends are periodic payments made by companies to shareholders from profits.
369
- * This endpoint provides the complete dividend history including payment dates, amounts,
370
- * and important dates like ex-dividend, record, and declaration dates.
371
- *
372
- * @param symbol - The stock symbol to get dividend history for (e.g., 'KO', 'JNJ', 'PG')
373
- *
374
- * @returns Promise resolving to dividend history with payment details and important dates
375
- *
376
- * @example
377
- * ```typescript
378
- * // Get Coca-Cola's dividend history
379
- * const dividends = await fmp.stock.getDividendHistory('KO');
380
- * dividends.data.historical.forEach(dividend => {
381
- * console.log(`${dividend.date}: $${dividend.dividend} per share`);
382
- * });
383
- *
384
- * // Get Johnson & Johnson's dividend history
385
- * const jnjDividends = await fmp.stock.getDividendHistory('JNJ');
386
- * ```
387
- *
388
- * @see {@link https://site.financialmodelingprep.com/developer/docs#dividends-historical-dividends|FMP Dividends Documentation}
389
- */
390
- async getDividendHistory(symbol) {
391
- return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
392
- }
393
- /**
394
- * Get real-time stock prices for multiple symbols
395
- *
396
- * Provides current market prices for stocks with minimal data overhead.
397
- * Returns basic price information including symbol and current price.
398
- * Ideal for quick price checks and portfolio monitoring.
399
- *
400
- * @param symbols - Array of stock symbols to get real-time prices for
401
- *
402
- * @returns Promise resolving to array of real-time price data with symbol and price
403
- *
404
- * @example
405
- * ```typescript
406
- * // Get prices for multiple tech stocks
407
- * const prices = await fmp.stock.getRealTimePrice([
408
- * 'AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TSLA'
409
- * ]);
410
- *
411
- * prices.data.forEach(stock => {
412
- * console.log(`${stock.symbol}: $${stock.price}`);
413
- * });
414
- *
415
- * // Get price for single stock
416
- * const aaplPrice = await fmp.stock.getRealTimePrice(['AAPL']);
417
- * ```
418
- */
419
- async getRealTimePrice(symbols) {
420
- const url = `stock/real-time-price/${symbols.join(",")}`;
421
- const result = await this.client.get(url, "v3");
422
- if (result.success && result.data && !Array.isArray(result.data)) {
423
- const data = result.data;
424
- if (typeof data === "object" && data !== null && "companiesPriceList" in data && Array.isArray(data.companiesPriceList)) {
425
- const filteredData2 = data.companiesPriceList.filter((item) => item && item.symbol);
426
- if (filteredData2.length > 0) {
427
- return { ...result, data: filteredData2 };
428
- }
429
- }
430
- if (typeof data === "object" && data !== null && "stockList" in data && Array.isArray(data.stockList)) {
431
- const filteredData2 = data.stockList.filter((item) => item && item.symbol);
432
- if (filteredData2.length > 0) {
433
- return { ...result, data: filteredData2 };
434
- }
435
- }
436
- if (data.symbol) {
437
- return { ...result, data: [data] };
438
- }
439
- if (symbols.length === 1) {
440
- console.warn(`No real-time price data found for symbol: ${symbols[0]}`);
441
- }
442
- return { ...result, data: [] };
443
- }
444
- const filteredData = result.data.filter((item) => item && item.symbol);
445
- return { ...result, data: filteredData };
446
- }
447
- /**
448
- * Get comprehensive real-time stock data for multiple symbols
449
- *
450
- * Provides detailed real-time market data including bid/ask prices, volume, trade sizes,
451
- * and timestamps. This endpoint offers much more information than the basic real-time price.
452
- * Perfect for trading applications, market analysis, and detailed price monitoring.
453
- *
454
- * @param symbols - Array of stock symbols to get detailed real-time data for
455
- *
456
- * @returns Promise resolving to array of detailed real-time data including bid/ask, volume, and timestamps
457
- *
458
- * @example
459
- * ```typescript
460
- * // Get detailed data for multiple stocks
461
- * const detailedData = await fmp.stock.getRealTimePriceForMultipleStocks([
462
- * 'AAPL', 'MSFT', 'GOOGL'
463
- * ]);
464
- *
465
- * detailedData.data.forEach(stock => {
466
- * console.log(`${stock.symbol}:`);
467
- * console.log(` Bid: $${stock.bidPrice} (${stock.bidSize} shares)`);
468
- * console.log(` Ask: $${stock.askPrice} (${stock.askSize} shares)`);
469
- * console.log(` Last: $${stock.lastSalePrice} (${stock.lastSaleSize} shares)`);
470
- * console.log(` Volume: ${stock.volume.toLocaleString()}`);
471
- * });
472
- *
473
- * // Get detailed data for single stock
474
- * const aaplDetailed = await fmp.stock.getRealTimePriceForMultipleStocks(['AAPL']);
475
- * ```
476
- *
477
- * @see {@link https://site.financialmodelingprep.com/developer/docs#real-time-full-price-quote|FMP Real-Time Full Price Documentation}
478
- */
479
- async getRealTimePriceForMultipleStocks(symbols) {
480
- const url = `stock/full/real-time-price/${symbols.join(",")}`;
481
- const result = await this.client.get(url, "v3");
482
- if (result.success && result.data && !Array.isArray(result.data)) {
483
- const data = result.data;
484
- if (typeof data === "object" && data !== null && "companiesPriceList" in data && Array.isArray(data.companiesPriceList)) {
485
- const filteredData2 = data.companiesPriceList.filter((item) => item && item.symbol);
486
- if (filteredData2.length > 0) {
487
- return { ...result, data: filteredData2 };
488
- }
489
- }
490
- if (typeof data === "object" && data !== null && "stockList" in data && Array.isArray(data.stockList)) {
491
- const filteredData2 = data.stockList.filter((item) => item && item.symbol);
492
- if (filteredData2.length > 0) {
493
- return { ...result, data: filteredData2 };
494
- }
495
- }
496
- if (data.symbol) {
497
- return { ...result, data: [data] };
498
- }
499
- if (symbols.length === 1) {
500
- console.warn(`No full real-time price data found for symbol: ${symbols[0]}`);
501
- }
502
- return { ...result, data: [] };
503
- }
504
- const filteredData = result.data.filter(
505
- (item) => item && item.symbol
506
- );
507
- return { ...result, data: filteredData };
508
- }
509
- };
510
-
511
- // src/endpoints/financial.ts
512
- var FinancialEndpoints = class {
513
- constructor(client) {
514
- this.client = client;
515
- }
516
- /**
517
- * Get income statement data
518
- *
519
- * Provides comprehensive income statement data including revenue, expenses,
520
- * net income, and earnings per share. Essential for analyzing company
521
- * profitability, revenue trends, and financial performance over time.
522
- *
523
- * @param params - Income statement request parameters
524
- * @param params.symbol - The stock symbol to get income statement for (e.g., 'AAPL', 'MSFT', 'GOOGL')
525
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
526
- * @param params.limit - Number of periods to retrieve (default: 5)
527
- *
528
- * @returns Promise resolving to array of income statement data with financial metrics
529
- *
530
- * @example
531
- * ```typescript
532
- * // Get annual income statements for Apple
533
- * const incomeStatements = await fmp.financial.getIncomeStatement({ symbol: 'AAPL' });
534
- * incomeStatements.data.forEach(statement => {
535
- * console.log(`${statement.date}: Revenue $${statement.revenue.toLocaleString()}, Net Income $${statement.netIncome.toLocaleString()}`);
536
- * });
537
- *
538
- * // Get quarterly income statements for Microsoft
539
- * const quarterlyIncome = await fmp.financial.getIncomeStatement({ symbol: 'MSFT', period: 'quarter', limit: 8 });
540
- * ```
541
- *
542
- * @see {@link https://site.financialmodelingprep.com/developer/docs#income-statements-financial-statements|FMP Income Statement Documentation}
543
- */
544
- async getIncomeStatement(params) {
545
- const { symbol, period = "annual", limit = 5 } = params;
546
- return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
547
- }
548
- /**
549
- * Get balance sheet data
550
- *
551
- * Provides comprehensive balance sheet data including assets, liabilities,
552
- * and shareholder equity. Essential for analyzing company financial position,
553
- * liquidity, and capital structure.
554
- *
555
- * @param params - Balance sheet request parameters
556
- * @param params.symbol - The stock symbol to get balance sheet for (e.g., 'AAPL', 'MSFT', 'GOOGL')
557
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
558
- * @param params.limit - Number of periods to retrieve (default: 5)
559
- *
560
- * @returns Promise resolving to array of balance sheet data with financial position metrics
561
- *
562
- * @example
563
- * ```typescript
564
- * // Get annual balance sheets for Apple
565
- * const balanceSheets = await fmp.financial.getBalanceSheet({ symbol: 'AAPL' });
566
- * balanceSheets.data.forEach(sheet => {
567
- * console.log(`${sheet.date}: Assets $${sheet.totalAssets.toLocaleString()}, Equity $${sheet.totalStockholdersEquity.toLocaleString()}`);
568
- * });
569
- *
570
- * // Get quarterly balance sheets for Microsoft
571
- * const quarterlyBalance = await fmp.financial.getBalanceSheet({ symbol: 'MSFT', period: 'quarter', limit: 8 });
572
- * ```
573
- *
574
- * @see {@link https://site.financialmodelingprep.com/developer/docs#balance-sheet-statements-financial-statements|FMP Balance Sheet Documentation}
575
- */
576
- async getBalanceSheet(params) {
577
- const { symbol, period = "annual", limit = 5 } = params;
578
- return this.client.get(
579
- `/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`,
580
- "v3"
581
- );
582
- }
583
- /**
584
- * Get cash flow statement data
585
- *
586
- * Provides comprehensive cash flow data including operating, investing,
587
- * and financing cash flows. Essential for analyzing company cash generation,
588
- * capital allocation, and financial sustainability.
589
- *
590
- * @param params - Cash flow statement request parameters
591
- * @param params.symbol - The stock symbol to get cash flow statement for (e.g., 'AAPL', 'MSFT', 'GOOGL')
592
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
593
- * @param params.limit - Number of periods to retrieve (default: 5)
594
- *
595
- * @returns Promise resolving to array of cash flow statement data with cash flow metrics
596
- *
597
- * @example
598
- * ```typescript
599
- * // Get annual cash flow statements for Apple
600
- * const cashFlows = await fmp.financial.getCashFlowStatement({ symbol: 'AAPL' });
601
- * cashFlows.data.forEach(flow => {
602
- * console.log(`${flow.date}: Operating CF $${flow.operatingCashFlow.toLocaleString()}, Free CF $${flow.freeCashFlow.toLocaleString()}`);
603
- * });
604
- *
605
- * // Get quarterly cash flow statements for Microsoft
606
- * const quarterlyCashFlow = await fmp.financial.getCashFlowStatement({ symbol: 'MSFT', period: 'quarter', limit: 8 });
607
- * ```
608
- *
609
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cashflow-statements-financial-statements|FMP Cash Flow Statement Documentation}
610
- */
611
- async getCashFlowStatement(params) {
612
- const { symbol, period = "annual", limit = 5 } = params;
613
- return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
614
- }
615
- /**
616
- * Get key financial metrics
617
- *
618
- * Provides essential financial metrics including revenue, net income,
619
- * P/E ratio, and other key performance indicators. Essential for
620
- * fundamental analysis and company valuation.
621
- *
622
- * @param params - Key metrics request parameters
623
- * @param params.symbol - The stock symbol to get key metrics for (e.g., 'AAPL', 'MSFT', 'GOOGL')
624
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
625
- * @param params.limit - Number of periods to retrieve (default: 5)
626
- *
627
- * @returns Promise resolving to array of key metrics data with financial indicators
628
- *
629
- * @example
630
- * ```typescript
631
- * // Get key metrics for Apple
632
- * const keyMetrics = await fmp.financial.getKeyMetrics({ symbol: 'AAPL' });
633
- * keyMetrics.data.forEach(metric => {
634
- * console.log(`${metric.date}: P/E ${metric.peRatio}, ROE ${metric.roe}%`);
635
- * });
636
- *
637
- * // Get quarterly key metrics for Microsoft
638
- * const quarterlyMetrics = await fmp.financial.getKeyMetrics({ symbol: 'MSFT', period: 'quarter', limit: 8 });
639
- * ```
640
- *
641
- * @see {@link https://site.financialmodelingprep.com/developer/docs#key-metrics-statement-analysis|FMP Key Metrics Documentation}
642
- */
643
- async getKeyMetrics(params) {
644
- const { symbol, period = "annual", limit = 5 } = params;
645
- return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`, "v3");
646
- }
647
- /**
648
- * Get financial ratios
649
- *
650
- * Provides comprehensive financial ratios including P/B ratio, ROE,
651
- * debt-to-equity, and other important ratios. Essential for analyzing
652
- * company financial health and comparing with peers.
653
- *
654
- * @param params - Financial ratios request parameters
655
- * @param params.symbol - The stock symbol to get financial ratios for (e.g., 'AAPL', 'MSFT', 'GOOGL')
656
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
657
- * @param params.limit - Number of periods to retrieve (default: 5)
658
- *
659
- * @returns Promise resolving to array of financial ratios data with ratio metrics
660
- *
661
- * @example
662
- * ```typescript
663
- * // Get financial ratios for Apple
664
- * const ratios = await fmp.financial.getFinancialRatios({ symbol: 'AAPL' });
665
- * ratios.data.forEach(ratio => {
666
- * console.log(`${ratio.date}: P/B ${ratio.priceToBookRatio}, Debt/Equity ${ratio.debtToEquity}`);
667
- * });
668
- *
669
- * // Get quarterly ratios for Microsoft
670
- * const quarterlyRatios = await fmp.financial.getFinancialRatios({ symbol: 'MSFT', period: 'quarter', limit: 8 });
671
- * ```
672
- *
673
- * @see {@link https://site.financialmodelingprep.com/developer/docs#ratios-statement-analysis|FMP Financial Ratios Documentation}
674
- */
675
- async getFinancialRatios(params) {
676
- const { symbol, period = "annual", limit = 5 } = params;
677
- return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`, "v3");
678
- }
679
- /**
680
- * Get enterprise value data
681
- *
682
- * Provides enterprise value metrics including total enterprise value,
683
- * market cap, and debt information. Essential for company valuation
684
- * and comparing companies with different capital structures.
685
- *
686
- * @param params - Enterprise value request parameters
687
- * @param params.symbol - The stock symbol to get enterprise value for (e.g., 'AAPL', 'MSFT', 'GOOGL')
688
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
689
- * @param params.limit - Number of periods to retrieve (default: 5)
690
- *
691
- * @returns Promise resolving to array of enterprise value data with valuation metrics
692
- *
693
- * @example
694
- * ```typescript
695
- * // Get enterprise value for Apple
696
- * const enterpriseValue = await fmp.financial.getEnterpriseValue({ symbol: 'AAPL' });
697
- * enterpriseValue.data.forEach(ev => {
698
- * console.log(`${ev.date}: EV $${ev.enterpriseValue.toLocaleString()}, Market Cap $${ev.marketCapitalization.toLocaleString()}`);
699
- * });
700
- *
701
- * // Get quarterly enterprise value for Microsoft
702
- * const quarterlyEV = await fmp.financial.getEnterpriseValue({ symbol: 'MSFT', period: 'quarter', limit: 8 });
703
- * ```
704
- *
705
- * @see {@link https://site.financialmodelingprep.com/developer/docs#enterprise-values-statement-analysis|FMP Enterprise Value Documentation}
706
- */
707
- async getEnterpriseValue(params) {
708
- const { symbol, period = "annual", limit = 5 } = params;
709
- return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`, "v3");
710
- }
711
- /**
712
- * Get cash flow growth data
713
- *
714
- * Provides cash flow growth rates showing how quickly a company's
715
- * cash flows are growing over time. Essential for analyzing cash
716
- * generation trends and financial sustainability.
717
- *
718
- * @param params - Cash flow growth request parameters
719
- * @param params.symbol - The stock symbol to get cash flow growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
720
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
721
- * @param params.limit - Number of periods to retrieve (default: 5)
722
- *
723
- * @returns Promise resolving to array of cash flow growth data with growth metrics
724
- *
725
- * @example
726
- * ```typescript
727
- * // Get cash flow growth for Apple
728
- * const cashFlowGrowth = await fmp.financial.getCashflowGrowth({ symbol: 'AAPL' });
729
- * cashFlowGrowth.data.forEach(growth => {
730
- * console.log(`${growth.date}: Operating CF Growth ${growth.operatingCashFlowGrowth}%`);
731
- * });
732
- *
733
- * // Get quarterly cash flow growth for Microsoft
734
- * const quarterlyGrowth = await fmp.financial.getCashflowGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
735
- * ```
736
- *
737
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cashflow-growth-statement-analysis|FMP Cash Flow Growth Documentation}
738
- */
739
- async getCashflowGrowth(params) {
740
- const { symbol, period = "annual", limit = 5 } = params;
741
- return this.client.get(
742
- `/cash-flow-statement-growth/${symbol}?period=${period}&limit=${limit}`,
743
- "v3"
744
- );
745
- }
746
- /**
747
- * Get income growth data
748
- *
749
- * Provides income growth rates showing how quickly a company's
750
- * revenue and net income are growing over time. Essential for
751
- * analyzing profitability trends and business momentum.
752
- *
753
- * @param params - Income growth request parameters
754
- * @param params.symbol - The stock symbol to get income growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
755
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
756
- * @param params.limit - Number of periods to retrieve (default: 5)
757
- *
758
- * @returns Promise resolving to array of income growth data with growth metrics
759
- *
760
- * @example
761
- * ```typescript
762
- * // Get income growth for Apple
763
- * const incomeGrowth = await fmp.financial.getIncomeGrowth({ symbol: 'AAPL' });
764
- * incomeGrowth.data.forEach(growth => {
765
- * console.log(`${growth.date}: Revenue Growth ${growth.revenueGrowth}%, Net Income Growth ${growth.netIncomeGrowth}%`);
766
- * });
767
- *
768
- * // Get quarterly income growth for Microsoft
769
- * const quarterlyGrowth = await fmp.financial.getIncomeGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
770
- * ```
771
- *
772
- * @see {@link https://site.financialmodelingprep.com/developer/docs#income-growth-statement-analysis|FMP Income Growth Documentation}
773
- */
774
- async getIncomeGrowth(params) {
775
- const { symbol, period = "annual", limit = 5 } = params;
776
- return this.client.get(
777
- `/income-statement-growth/${symbol}?period=${period}&limit=${limit}`,
778
- "v3"
779
- );
780
- }
781
- /**
782
- * Get balance sheet growth data
783
- *
784
- * Provides balance sheet growth rates showing how quickly a company's
785
- * assets, liabilities, and equity are growing over time. Essential for
786
- * analyzing capital structure trends and financial position changes.
787
- *
788
- * @param params - Balance sheet growth request parameters
789
- * @param params.symbol - The stock symbol to get balance sheet growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
790
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
791
- * @param params.limit - Number of periods to retrieve (default: 5)
792
- *
793
- * @returns Promise resolving to array of balance sheet growth data with growth metrics
794
- *
795
- * @example
796
- * ```typescript
797
- * // Get balance sheet growth for Apple
798
- * const balanceSheetGrowth = await fmp.financial.getBalanceSheetGrowth({ symbol: 'AAPL' });
799
- * balanceSheetGrowth.data.forEach(growth => {
800
- * console.log(`${growth.date}: Assets Growth ${growth.totalAssetsGrowth}%, Equity Growth ${growth.totalStockholdersEquityGrowth}%`);
801
- * });
802
- *
803
- * // Get quarterly balance sheet growth for Microsoft
804
- * const quarterlyGrowth = await fmp.financial.getBalanceSheetGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
805
- * ```
806
- *
807
- * @see {@link https://site.financialmodelingprep.com/developer/docs#balance-sheet-growth-statement-analysis|FMP Balance Sheet Growth Documentation}
808
- */
809
- async getBalanceSheetGrowth(params) {
810
- const { symbol, period = "annual", limit = 5 } = params;
811
- return this.client.get(
812
- `/balance-sheet-statement-growth/${symbol}?period=${period}&limit=${limit}`,
813
- "v3"
814
- );
815
- }
816
- /**
817
- * Get financial growth data
818
- *
819
- * Provides comprehensive financial growth rates across all key
820
- * financial metrics. Essential for analyzing overall financial
821
- * performance trends and business momentum.
822
- *
823
- * @param params - Financial growth request parameters
824
- * @param params.symbol - The stock symbol to get financial growth for (e.g., 'AAPL', 'MSFT', 'GOOGL')
825
- * @param params.period - The reporting period: 'annual' or 'quarter' (default: 'annual')
826
- * @param params.limit - Number of periods to retrieve (default: 5)
827
- *
828
- * @returns Promise resolving to array of financial growth data with comprehensive growth metrics
829
- *
830
- * @example
831
- * ```typescript
832
- * // Get financial growth for Apple
833
- * const financialGrowth = await fmp.financial.getFinancialGrowth({ symbol: 'AAPL' });
834
- * financialGrowth.data.forEach(growth => {
835
- * console.log(`${growth.date}: Revenue Growth ${growth.revenueGrowth}%, EPS Growth ${growth.epsGrowth}%`);
836
- * });
837
- *
838
- * // Get quarterly financial growth for Microsoft
839
- * const quarterlyGrowth = await fmp.financial.getFinancialGrowth({ symbol: 'MSFT', period: 'quarter', limit: 8 });
840
- * ```
841
- *
842
- * @see {@link https://site.financialmodelingprep.com/developer/docs#financial-growth-statement-analysis|FMP Financial Growth Documentation}
843
- */
844
- async getFinancialGrowth(params) {
845
- const { symbol, period = "annual", limit = 5 } = params;
846
- return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
847
- }
848
- /**
849
- * Get historical earnings data
850
- *
851
- * Provides historical and upcoming earnings announcements including
852
- * dates, estimated EPS, and actual EPS. Essential for analyzing
853
- * earnings trends and tracking company performance.
854
- *
855
- * @param params - Earnings historical request parameters
856
- * @param params.symbol - The stock symbol to get earnings history for (e.g., 'AAPL', 'MSFT', 'GOOGL')
857
- * @param params.limit - Number of periods to retrieve (default: 5)
858
- *
859
- * @returns Promise resolving to array of historical earnings data with announcement details
860
- *
861
- * @example
862
- * ```typescript
863
- * // Get earnings history for Apple
864
- * const earningsHistory = await fmp.financial.getEarningsHistorical({ symbol: 'AAPL', limit: 10 });
865
- * earningsHistory.data.forEach(earning => {
866
- * console.log(`${earning.date}: Est. ${earning.estimatedEps}, Actual ${earning.actualEps}`);
867
- * });
868
- *
869
- * // Get earnings history for Microsoft
870
- * const msftEarnings = await fmp.financial.getEarningsHistorical({ symbol: 'MSFT', limit: 8 });
871
- * ```
872
- *
873
- * @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings|FMP Earnings Historical Documentation}
874
- */
875
- async getEarningsHistorical(params) {
876
- const { symbol, limit = 5 } = params;
877
- return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
878
- }
879
- /**
880
- * Get earnings surprises data
881
- *
882
- * Provides earnings announcements that exceeded or fell short of
883
- * analyst estimates. Essential for analyzing earnings quality and
884
- * market reactions to earnings releases.
885
- *
886
- * @param symbol - The stock symbol to get earnings surprises for (e.g., 'AAPL', 'MSFT', 'GOOGL')
887
- *
888
- * @returns Promise resolving to array of earnings surprises data with surprise details
889
- *
890
- * @example
891
- * ```typescript
892
- * // Get earnings surprises for Apple
893
- * const earningsSurprises = await fmp.financial.getEarningsSurprises('AAPL');
894
- * earningsSurprises.data.forEach(surprise => {
895
- * console.log(`${surprise.date}: Est. ${surprise.estimatedEps}, Actual ${surprise.actualEps}, Surprise ${surprise.surprisePercentage}%`);
896
- * });
897
- *
898
- * // Get earnings surprises for Microsoft
899
- * const msftSurprises = await fmp.financial.getEarningsSurprises('MSFT');
900
- * ```
901
- *
902
- * @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings|FMP Earnings Surprises Documentation}
903
- */
904
- async getEarningsSurprises(symbol) {
905
- return this.client.get(`/earnings-surprises/${symbol}`, "v3");
906
- }
907
- };
908
-
909
- // src/endpoints/etf.ts
910
- var ETFEndpoints = class {
911
- constructor(client) {
912
- this.client = client;
913
- }
914
- /**
915
- * Get available ETF holding dates
916
- *
917
- * Provides a list of dates when ETF holdings are updated and available.
918
- * Useful for determining when the most recent holdings data is available
919
- * and ensuring you're working with current portfolio information.
920
- *
921
- * @param symbol - ETF symbol to get holding dates for (e.g., 'SPY', 'VOO', 'QQQ')
922
- *
923
- * @returns Promise resolving to array of available holding dates
924
- *
925
- * @example
926
- * ```typescript
927
- * // Get holding dates for specific ETF
928
- * const spyDates = await fmp.etf.getHoldingDates('SPY');
929
- * spyDates.data.forEach(date => {
930
- * console.log(`Holdings available: ${date.date}`);
931
- * });
932
- *
933
- * // Get VOO holding dates
934
- * const vooDates = await fmp.etf.getHoldingDates('VOO');
935
- * ```
936
- *
937
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings|FMP ETF Holding Dates Documentation}
938
- */
939
- async getHoldingDates(symbol) {
940
- return this.client.get("/etf-holdings/portfolio-date", "v4", { symbol });
941
- }
942
- /**
943
- * Get ETF holdings for specific date
944
- *
945
- * Provides detailed holdings information for an ETF on a specific date.
946
- * Includes individual stocks, their weights, shares held, and market values.
947
- * Essential for understanding ETF composition and portfolio analysis.
948
- *
949
- * @param params - ETF holdings request parameters
950
- * @param params.symbol - The ETF symbol to get holdings for (e.g., 'SPY', 'VOO', 'QQQ')
951
- * @param params.date - The date to get holdings for in YYYY-MM-DD format
952
- *
953
- * @returns Promise resolving to array of ETF holdings with detailed stock information
954
- *
955
- * @example
956
- * ```typescript
957
- * // Get SPY holdings for specific date
958
- * const holdings = await fmp.etf.getHoldings({ symbol: 'SPY', date: '2024-01-15' });
959
- * holdings.data.forEach(holding => {
960
- * console.log(`${holding.asset}: ${holding.weight}% (${holding.sharesNumber} shares)`);
961
- * });
962
- *
963
- * // Get VOO holdings
964
- * const vooHoldings = await fmp.etf.getHoldings({ symbol: 'VOO', date: '2024-01-15' });
965
- * ```
966
- *
967
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings|FMP ETF Holdings Documentation}
968
- */
969
- async getHoldings(params) {
970
- const { symbol, date } = params;
971
- const queryParams = {};
972
- if (symbol) queryParams.symbol = symbol;
973
- if (date) queryParams.date = date;
974
- return this.client.get("/etf-holdings", "v4", queryParams);
975
- }
976
- /**
977
- * Get ETF holdings and components
978
- *
979
- * Provides all stocks held by a specific ETF including assets, share numbers,
980
- * and weight percentages. Essential for understanding ETF composition and
981
- * finding which ETFs hold specific stocks.
982
- *
983
- * @param symbol - The ETF symbol to get holdings for (e.g., 'SPY', 'VOO', 'QQQ')
984
- *
985
- * @returns Promise resolving to array of ETF holdings with stock details
986
- *
987
- * @example
988
- * ```typescript
989
- * // Get SPY holdings
990
- * const spyHoldings = await fmp.etf.getHolder('SPY');
991
- * spyHoldings.data.forEach(holding => {
992
- * console.log(`${holding.asset}: ${holding.weight}% (${holding.sharesNumber} shares)`);
993
- * });
994
- *
995
- * // Get VOO holdings
996
- * const vooHoldings = await fmp.etf.getHolder('VOO');
997
- * ```
998
- *
999
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings|FMP ETF Holder Documentation}
1000
- */
1001
- async getHolder(symbol) {
1002
- return this.client.get(`/etf-holder/${symbol}`, "v3");
1003
- }
1004
- /**
1005
- * Get ETF profile and information
1006
- *
1007
- * Provides comprehensive information about an ETF including ticker symbol,
1008
- * name, expense ratio, assets under management, and other key metrics.
1009
- * Essential for ETF comparison and due diligence.
1010
- *
1011
- * @param symbol - ETF symbol to get profile for (e.g., 'SPY', 'VOO', 'QQQ')
1012
- *
1013
- * @returns Promise resolving to ETF profile with detailed information
1014
- *
1015
- * @example
1016
- * ```typescript
1017
- * // Get SPY profile
1018
- * const spyProfile = await fmp.etf.getProfile('SPY');
1019
- * console.log(`SPY AUM: $${spyProfile.data.aum.toLocaleString()}`);
1020
- * console.log(`Expense Ratio: ${spyProfile.data.expenseRatio}%`);
1021
- *
1022
- * // Get VOO profile
1023
- * const vooProfile = await fmp.etf.getProfile('VOO');
1024
- * ```
1025
- *
1026
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings|FMP ETF Information Documentation}
1027
- */
1028
- async getProfile(symbol) {
1029
- return this.client.getSingle("/etf-info", "v4", { symbol });
1030
- }
1031
- /**
1032
- * Get ETF sector weighting and exposure
1033
- *
1034
- * Provides a breakdown of an ETF's sector allocation showing the percentage
1035
- * of assets invested in each sector. Essential for understanding sector
1036
- * exposure and diversification analysis.
1037
- *
1038
- * @param symbol - The ETF symbol to get sector weighting for (e.g., 'SPY', 'VOO', 'QQQ')
1039
- *
1040
- * @returns Promise resolving to array of sector weightings with percentage allocations
1041
- *
1042
- * @example
1043
- * ```typescript
1044
- * // Get SPY sector weightings
1045
- * const sectorWeightings = await fmp.etf.getSectorWeighting('SPY');
1046
- * sectorWeightings.data.forEach(sector => {
1047
- * console.log(`${sector.sector}: ${sector.weight}%`);
1048
- * });
1049
- *
1050
- * // Get QQQ sector exposure (tech-heavy)
1051
- * const qqqSectors = await fmp.etf.getSectorWeighting('QQQ');
1052
- * ```
1053
- *
1054
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings|FMP ETF Sector Weighting Documentation}
1055
- */
1056
- async getSectorWeighting(symbol) {
1057
- return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
1058
- }
1059
- /**
1060
- * Get ETF country weighting and exposure
1061
- *
1062
- * Provides a breakdown of an ETF's geographic allocation showing the percentage
1063
- * of assets invested in each country. Essential for understanding international
1064
- * exposure and geographic diversification.
1065
- *
1066
- * @param symbol - The ETF symbol to get country weighting for (e.g., 'SPY', 'VOO', 'EFA')
1067
- *
1068
- * @returns Promise resolving to array of country weightings with percentage allocations
1069
- *
1070
- * @example
1071
- * ```typescript
1072
- * // Get SPY country weightings
1073
- * const countryWeightings = await fmp.etf.getCountryWeighting('SPY');
1074
- * countryWeightings.data.forEach(country => {
1075
- * console.log(`${country.country}: ${country.weight}%`);
1076
- * });
1077
- *
1078
- * // Get international ETF exposure
1079
- * const efaCountries = await fmp.etf.getCountryWeighting('EFA');
1080
- * ```
1081
- *
1082
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings|FMP ETF Country Weighting Documentation}
1083
- */
1084
- async getCountryWeighting(symbol) {
1085
- return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
1086
- }
1087
- /**
1088
- * Get ETF stock exposure and holdings
1089
- *
1090
- * Provides detailed exposure information for a specific stock across all ETFs
1091
- * that hold it. Includes market value, share numbers, and weight percentages.
1092
- * Useful for finding which ETFs have exposure to specific stocks.
1093
- *
1094
- * @param symbol - The stock symbol to get ETF exposure for (e.g., 'AAPL', 'MSFT', 'GOOGL')
1095
- *
1096
- * @returns Promise resolving to array of ETF exposures with detailed holding information
1097
- *
1098
- * @example
1099
- * ```typescript
1100
- * // Find ETFs that hold Apple
1101
- * const appleExposure = await fmp.etf.getStockExposure('AAPL');
1102
- * appleExposure.data.forEach(etf => {
1103
- * console.log(`${etf.etfSymbol}: ${etf.weight}% (${etf.sharesNumber} shares)`);
1104
- * });
1105
- *
1106
- * // Find ETFs that hold Microsoft
1107
- * const msftExposure = await fmp.etf.getStockExposure('MSFT');
1108
- * ```
1109
- *
1110
- * @see {@link https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings|FMP ETF Stock Exposure Documentation}
1111
- */
1112
- async getStockExposure(symbol) {
1113
- return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
1114
- }
1115
- };
1116
-
1117
- // src/endpoints/economic.ts
1118
- var EconomicEndpoints = class {
1119
- constructor(client) {
1120
- this.client = client;
1121
- }
1122
- /**
1123
- * Get treasury rates data
1124
- *
1125
- * Provides historical treasury rates for various maturities including
1126
- * 1-month, 3-month, 6-month, 1-year, 2-year, 3-year, 5-year, 7-year,
1127
- * 10-year, 20-year, and 30-year treasury bonds. Essential for analyzing
1128
- * interest rate trends, yield curves, and fixed income investments.
1129
- *
1130
- * @param params - Treasury rates request parameters
1131
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
1132
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
1133
- *
1134
- * @returns Promise resolving to array of treasury rates data with yield information
1135
- *
1136
- * @example
1137
- * ```typescript
1138
- * // Get treasury rates for the last year
1139
- * const treasuryRates = await fmp.economic.getTreasuryRates({
1140
- * from: '2023-01-01',
1141
- * to: '2023-12-31'
1142
- * });
1143
- * treasuryRates.data.forEach(rate => {
1144
- * console.log(`${rate.date}: 10Y ${rate.tenY}%, 2Y ${rate.twoY}%`);
1145
- * });
1146
- *
1147
- * // Get recent treasury rates
1148
- * const recentRates = await fmp.economic.getTreasuryRates({
1149
- * from: '2024-01-01'
1150
- * });
1151
- * ```
1152
- *
1153
- * @see {@link https://site.financialmodelingprep.com/developer/docs#treasury-rates-economics-data|FMP Treasury Rates Documentation}
1154
- */
1155
- async getTreasuryRates(params) {
1156
- const { from, to } = params;
1157
- const queryParams = {};
1158
- if (from) queryParams.from = from;
1159
- if (to) queryParams.to = to;
1160
- return this.client.get("/treasury", "v4", queryParams);
1161
- }
1162
- /**
1163
- * Get economic indicators data
1164
- *
1165
- * Provides real-time and historical economic data for a wide variety of
1166
- * economic indicators including GDP, unemployment, inflation, retail sales,
1167
- * and many others. Essential for macroeconomic analysis and understanding
1168
- * economic trends and cycles.
1169
- *
1170
- * @param params - Economic indicators request parameters
1171
- * @param params.name - The economic indicator to retrieve
1172
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
1173
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
1174
- *
1175
- * @returns Promise resolving to array of economic indicator data with historical values
1176
- *
1177
- * @example
1178
- * ```typescript
1179
- * // Get GDP data for the last year
1180
- * const gdpData = await fmp.economic.getEconomicIndicators({
1181
- * name: 'GDP',
1182
- * from: '2023-01-01',
1183
- * to: '2023-12-31'
1184
- * });
1185
- * gdpData.data.forEach(gdp => {
1186
- * console.log(`${gdp.date}: GDP $${gdp.value.toLocaleString()} billion`);
1187
- * });
1188
- *
1189
- * // Get unemployment rate data
1190
- * const unemploymentData = await fmp.economic.getEconomicIndicators({
1191
- * name: 'unemploymentRate',
1192
- * from: '2024-01-01'
1193
- * });
1194
- *
1195
- * // Get inflation rate data
1196
- * const inflationData = await fmp.economic.getEconomicIndicators({
1197
- * name: 'inflationRate',
1198
- * from: '2023-01-01',
1199
- * to: '2023-12-31'
1200
- * });
1201
- * ```
1202
- *
1203
- * @see {@link https://site.financialmodelingprep.com/developer/docs#economic-indicators-economics-data|FMP Economic Indicators Documentation}
1204
- */
1205
- async getEconomicIndicators(params) {
1206
- const { name, from, to } = params;
1207
- const queryParams = { name };
1208
- if (from) queryParams.from = from;
1209
- if (to) queryParams.to = to;
1210
- return this.client.get(`/economic`, "v4", queryParams);
1211
- }
1212
- };
1213
-
1214
- // src/endpoints/market.ts
1215
- var MarketEndpoints = class {
1216
- constructor(client) {
1217
- this.client = client;
1218
- }
1219
- /**
1220
- * Get current market hours and trading status
1221
- *
1222
- * Provides real-time information about market trading hours, including
1223
- * whether markets are currently open or closed, trading session times,
1224
- * and upcoming market holidays. Essential for determining trading
1225
- * availability and market status.
1226
- *
1227
- * @returns Promise resolving to market hours data with trading status and session information
1228
- *
1229
- * @example
1230
- * ```typescript
1231
- * // Get current market status
1232
- * const marketHours = await fmp.market.getMarketHours();
1233
- * console.log(`Market is ${marketHours.data.isTheStockMarketOpen ? 'OPEN' : 'CLOSED'}`);
1234
- * console.log(`Current time: ${marketHours.data.currentTime}`);
1235
- * console.log(`Next trading day: ${marketHours.data.nextTradingDay}`);
1236
- *
1237
- * // Check if it's a trading day
1238
- * if (marketHours.data.isTheStockMarketOpen) {
1239
- * console.log('Markets are currently open for trading');
1240
- * } else {
1241
- * console.log('Markets are closed');
1242
- * }
1243
- * ```
1244
- *
1245
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-hours|FMP Market Hours Documentation}
1246
- */
1247
- async getMarketHours() {
1248
- return this.client.get("/market-hours", "v3");
1249
- }
1250
- /**
1251
- * Get overall market performance data
1252
- *
1253
- * Provides comprehensive market performance data including major indices,
1254
- * market breadth, and key performance metrics. Essential for understanding
1255
- * overall market sentiment, trends, and daily market activity.
1256
- *
1257
- * @returns Promise resolving to array of market performance data with indices and metrics
1258
- *
1259
- * @example
1260
- * ```typescript
1261
- * // Get overall market performance
1262
- * const marketPerformance = await fmp.market.getMarketPerformance();
1263
- * marketPerformance.data.forEach(market => {
1264
- * console.log(`${market.index}: ${market.change} (${market.changesPercentage}%)`);
1265
- * console.log(` Open: $${market.open}, High: $${market.dayHigh}, Low: $${market.dayLow}`);
1266
- * });
1267
- *
1268
- * // Find specific indices
1269
- * const sp500 = marketPerformance.data.find(market => market.index === 'S&P 500');
1270
- * console.log(`S&P 500 performance: ${sp500?.changesPercentage}%`);
1271
- *
1272
- * // Check market sentiment
1273
- * const gainers = marketPerformance.data.filter(market => market.changesPercentage > 0);
1274
- * const losers = marketPerformance.data.filter(market => market.changesPercentage < 0);
1275
- * console.log(`Gaining indices: ${gainers.length}, Losing indices: ${losers.length}`);
1276
- * ```
1277
- *
1278
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-performance|FMP Market Performance Documentation}
1279
- */
1280
- async getMarketPerformance() {
1281
- return this.client.get("/market-performance", "v3");
1282
- }
1283
- /**
1284
- * Get top gaining stocks for the current trading day
1285
- *
1286
- * Provides a list of stocks that have gained the most value during the
1287
- * current trading session. Essential for identifying momentum stocks,
1288
- * tracking market movers, and discovering potential investment opportunities.
1289
- * Useful for day trading, momentum strategies, and market analysis.
1290
- *
1291
- * @returns Promise resolving to array of top gaining stocks with price and percentage change data
1292
- *
1293
- * @example
1294
- * ```typescript
1295
- * // Get top gainers for the day
1296
- * const gainers = await fmp.market.getGainers();
1297
- * console.log(`Top ${gainers.data.length} gaining stocks today:`);
1298
- *
1299
- * gainers.data.forEach((stock, index) => {
1300
- * console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
1301
- * console.log(` Price: $${stock.price} | Change: +${stock.change} (${stock.changesPercentage}%)`);
1302
- * console.log(` Volume: ${stock.volume.toLocaleString()}`);
1303
- * });
1304
- *
1305
- * // Find stocks with >10% gains
1306
- * const bigGainers = gainers.data.filter(stock => stock.changesPercentage > 10);
1307
- * console.log(`Stocks with >10% gains: ${bigGainers.length}`);
1308
- *
1309
- * // Check volume leaders among gainers
1310
- * const highVolumeGainers = gainers.data.filter(stock => stock.volume > 1000000);
1311
- * console.log(`High volume gainers (>1M shares): ${highVolumeGainers.length}`);
1312
- * ```
1313
- *
1314
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview|FMP Market Biggest Gainers Documentation}
1315
- */
1316
- async getGainers() {
1317
- return this.client.get("/stock_market/gainers", "v3");
1318
- }
1319
- /**
1320
- * Get top losing stocks for the current trading day
1321
- *
1322
- * Provides a list of stocks that have lost the most value during the
1323
- * current trading session. Essential for identifying underperforming stocks,
1324
- * tracking market decliners, and discovering potential contrarian opportunities.
1325
- * Useful for risk management, short selling strategies, and market analysis.
1326
- *
1327
- * @returns Promise resolving to array of top losing stocks with price and percentage change data
1328
- *
1329
- * @example
1330
- * ```typescript
1331
- * // Get top losers for the day
1332
- * const losers = await fmp.market.getLosers();
1333
- * console.log(`Top ${losers.data.length} losing stocks today:`);
1334
- *
1335
- * losers.data.forEach((stock, index) => {
1336
- * console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
1337
- * console.log(` Price: $${stock.price} | Change: ${stock.change} (${stock.changesPercentage}%)`);
1338
- * console.log(` Volume: ${stock.volume.toLocaleString()}`);
1339
- * });
1340
- *
1341
- * // Find stocks with >10% losses
1342
- * const bigLosers = losers.data.filter(stock => stock.changesPercentage < -10);
1343
- * console.log(`Stocks with >10% losses: ${bigLosers.length}`);
1344
- *
1345
- * // Check for potential oversold conditions
1346
- * const highVolumeLosers = losers.data.filter(stock => stock.volume > 1000000);
1347
- * console.log(`High volume losers (>1M shares): ${highVolumeLosers.length}`);
1348
- *
1349
- * // Look for potential bounce candidates
1350
- * const oversoldStocks = losers.data.filter(stock =>
1351
- * stock.changesPercentage < -5 && stock.volume > 500000
1352
- * );
1353
- * ```
1354
- *
1355
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview|FMP Market Biggest Losers Documentation}
1356
- */
1357
- async getLosers() {
1358
- return this.client.get("/stock_market/losers", "v3");
1359
- }
1360
- /**
1361
- * Get most actively traded stocks for the current trading day
1362
- *
1363
- * Provides a list of stocks with the highest trading volume during the
1364
- * current trading session. Essential for identifying stocks with high
1365
- * liquidity, tracking market interest, and discovering stocks with
1366
- * significant trading activity. Useful for day trading and liquidity analysis.
1367
- *
1368
- * @returns Promise resolving to array of most active stocks with volume and price data
1369
- *
1370
- * @example
1371
- * ```typescript
1372
- * // Get most active stocks for the day
1373
- * const mostActive = await fmp.market.getMostActive();
1374
- * console.log(`Top ${mostActive.data.length} most active stocks today:`);
1375
- *
1376
- * mostActive.data.forEach((stock, index) => {
1377
- * console.log(`${index + 1}. ${stock.symbol} (${stock.name})`);
1378
- * console.log(` Volume: ${stock.volume.toLocaleString()} shares`);
1379
- * console.log(` Price: $${stock.price} | Change: ${stock.change} (${stock.changesPercentage}%)`);
1380
- * console.log(` Avg Volume: ${stock.avgVolume?.toLocaleString() || 'N/A'}`);
1381
- * });
1382
- *
1383
- * // Find stocks with unusual volume (>2x average)
1384
- * const unusualVolume = mostActive.data.filter(stock =>
1385
- * stock.avgVolume && stock.volume > stock.avgVolume * 2
1386
- * );
1387
- * console.log(`Stocks with unusual volume: ${unusualVolume.length}`);
1388
- *
1389
- * // Check for high volume gainers
1390
- * const highVolumeGainers = mostActive.data.filter(stock =>
1391
- * stock.changesPercentage > 0 && stock.volume > 1000000
1392
- * );
1393
- * console.log(`High volume gainers: ${highVolumeGainers.length}`);
1394
- *
1395
- * // Find penny stocks with high volume
1396
- * const pennyStocks = mostActive.data.filter(stock =>
1397
- * stock.price < 5 && stock.volume > 500000
1398
- * );
1399
- * ```
1400
- *
1401
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-most-actives|FMP Market Most Actives Documentation}
1402
- */
1403
- async getMostActive() {
1404
- return this.client.get("/stock_market/actives", "v3");
1405
- }
1406
- /**
1407
- * Get sector performance data for the current trading day
1408
- *
1409
- * Provides performance data for all major market sectors including
1410
- * technology, healthcare, financials, energy, and others. Essential for
1411
- * sector rotation analysis, identifying leading/lagging sectors, and
1412
- * understanding market breadth and sector-specific trends.
1413
- *
1414
- * @returns Promise resolving to array of sector performance data with percentage changes
1415
- *
1416
- * @example
1417
- * ```typescript
1418
- * // Get sector performance for the day
1419
- * const sectorPerformance = await fmp.market.getSectorPerformance();
1420
- * console.log(`Sector performance for ${sectorPerformance.data.length} sectors:`);
1421
- *
1422
- * sectorPerformance.data.forEach(sector => {
1423
- * const changeColor = sector.changesPercentage >= 0 ? 'green' : 'red';
1424
- * console.log(`${sector.sector}: ${sector.changesPercentage}%`);
1425
- * console.log(` Change: ${sector.changesPercentage >= 0 ? '+' : ''}${sector.changesPercentage}%`);
1426
- * });
1427
- *
1428
- * // Find best performing sectors
1429
- * const topSectors = sectorPerformance.data
1430
- * .sort((a, b) => b.changesPercentage - a.changesPercentage)
1431
- * .slice(0, 3);
1432
- * console.log('Top 3 performing sectors:');
1433
- * topSectors.forEach((sector, index) => {
1434
- * console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
1435
- * });
1436
- *
1437
- * // Find worst performing sectors
1438
- * const bottomSectors = sectorPerformance.data
1439
- * .sort((a, b) => a.changesPercentage - b.changesPercentage)
1440
- * .slice(0, 3);
1441
- * console.log('Bottom 3 performing sectors:');
1442
- * bottomSectors.forEach((sector, index) => {
1443
- * console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
1444
- * });
1445
- *
1446
- * // Check for sector rotation
1447
- * const gainingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage > 0);
1448
- * const losingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage < 0);
1449
- * console.log(`Sectors gaining: ${gainingSectors.length}, Sectors losing: ${losingSectors.length}`);
1450
- * ```
1451
- *
1452
- * @see {@link https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview|FMP Sector Performance Documentation}
1453
- */
1454
- async getSectorPerformance() {
1455
- return this.client.get("/sector-performance", "v3");
1456
- }
1457
- /**
1458
- * Get real-time data for major market indices
1459
- *
1460
- * Provides real-time quote data for all major stock market indices including
1461
- * S&P 500, Dow Jones Industrial Average, NASDAQ Composite, and other global
1462
- * indices. Essential for tracking overall market performance, understanding
1463
- * market sentiment, and identifying broad market trends.
1464
- *
1465
- * @returns Promise resolving to array of market index data with real-time quotes
1466
- *
1467
- * @example
1468
- * ```typescript
1469
- * // Get real-time market indices
1470
- * const marketIndices = await fmp.market.getMarketIndex();
1471
- * console.log(`Real-time data for ${marketIndices.data.length} major indices:`);
1472
- *
1473
- * marketIndices.data.forEach(index => {
1474
- * console.log(`${index.symbol} (${index.name}):`);
1475
- * console.log(` Price: $${index.price}`);
1476
- * console.log(` Change: ${index.change} (${index.changesPercentage}%)`);
1477
- * console.log(` Day Range: $${index.dayLow} - $${index.dayHigh}`);
1478
- * console.log(` Volume: ${index.volume?.toLocaleString() || 'N/A'}`);
1479
- * });
1480
- *
1481
- * // Find specific major indices
1482
- * const sp500 = marketIndices.data.find(index => index.symbol === '^GSPC');
1483
- * const nasdaq = marketIndices.data.find(index => index.symbol === '^IXIC');
1484
- * const dowJones = marketIndices.data.find(index => index.symbol === '^DJI');
1485
- *
1486
- * console.log(`S&P 500: ${sp500?.price} (${sp500?.changesPercentage}%)`);
1487
- * console.log(`NASDAQ: ${nasdaq?.price} (${nasdaq?.changesPercentage}%)`);
1488
- * console.log(`Dow Jones: ${dowJones?.price} (${dowJones?.changesPercentage}%)`);
1489
- *
1490
- * // Check market breadth
1491
- * const gainingIndices = marketIndices.data.filter(index => index.changesPercentage > 0);
1492
- * const losingIndices = marketIndices.data.filter(index => index.changesPercentage < 0);
1493
- * console.log(`Indices gaining: ${gainingIndices.length}, Indices losing: ${losingIndices.length}`);
1494
- *
1495
- * // Find international indices
1496
- * const internationalIndices = marketIndices.data.filter(index =>
1497
- * !index.symbol.startsWith('^') ||
1498
- * index.name.toLowerCase().includes('europe') ||
1499
- * index.name.toLowerCase().includes('asia')
1500
- * );
1501
- * ```
1502
- *
1503
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-index-market-overview|FMP Market Index Documentation}
1504
- */
1505
- async getMarketIndex() {
1506
- return this.client.get("/quotes/index", "v3");
1507
- }
1508
- };
1509
-
1510
- // src/endpoints/list.ts
1511
- var ListEndpoints = class {
1512
- constructor(client) {
1513
- this.client = client;
1514
- }
1515
- /**
1516
- * Get comprehensive list of all available stocks
1517
- *
1518
- * Provides a complete list of all stocks available on major exchanges including
1519
- * NYSE, NASDAQ, and other global markets. Essential for discovering available
1520
- * symbols, building watchlists, or creating stock screening applications.
1521
- *
1522
- * @returns Promise resolving to array of stock data with symbol, name, exchange, and price information
1523
- *
1524
- * @example
1525
- * ```typescript
1526
- * // Get all available stocks
1527
- * const stocks = await fmp.list.getStockList();
1528
- * console.log(`Total stocks available: ${stocks.data.length}`);
1529
- *
1530
- * // Find specific stocks
1531
- * const appleStock = stocks.data.find(stock => stock.symbol === 'AAPL');
1532
- * console.log(`Apple: ${appleStock?.name} (${appleStock?.exchange})`);
1533
- *
1534
- * // Filter by exchange
1535
- * const nasdaqStocks = stocks.data.filter(stock => stock.exchange === 'NASDAQ');
1536
- * console.log(`NASDAQ stocks: ${nasdaqStocks.length}`);
1537
- * ```
1538
- *
1539
- * @see {@link https://site.financialmodelingprep.com/developer/docs#symbol-list-stock-list|FMP Stock List Documentation}
1540
- */
1541
- async getStockList() {
1542
- return this.client.get("/stock/list");
1543
- }
1544
- /**
1545
- * Get comprehensive list of all available ETFs
1546
- *
1547
- * Provides a complete list of all Exchange-Traded Funds (ETFs) available for trading.
1548
- * Includes ETFs from various asset classes including equity, bond, commodity, and
1549
- * sector-specific funds. Essential for ETF research and portfolio construction.
1550
- *
1551
- * @returns Promise resolving to array of ETF data with symbol, name, exchange, and asset class information
1552
- *
1553
- * @example
1554
- * ```typescript
1555
- * // Get all available ETFs
1556
- * const etfs = await fmp.list.getETFList();
1557
- * console.log(`Total ETFs available: ${etfs.data.length}`);
1558
- *
1559
- * // Find specific ETFs
1560
- * const spyETF = etfs.data.find(etf => etf.symbol === 'SPY');
1561
- * console.log(`SPY: ${spyETF?.name} (${spyETF?.assetClass})`);
1562
- *
1563
- * // Filter by asset class
1564
- * const equityETFs = etfs.data.filter(etf => etf.assetClass === 'Equity');
1565
- * console.log(`Equity ETFs: ${equityETFs.length}`);
1566
- *
1567
- * // Find sector ETFs
1568
- * const techETFs = etfs.data.filter(etf =>
1569
- * etf.name.toLowerCase().includes('technology') ||
1570
- * etf.name.toLowerCase().includes('tech')
1571
- * );
1572
- * ```
1573
- *
1574
- * @see {@link https://site.financialmodelingprep.com/developer/docs#exchange-traded-fund-search-stock-list|FMP ETF List Documentation}
1575
- */
1576
- async getETFList() {
1577
- return this.client.get("/etf/list");
1578
- }
1579
- /**
1580
- * Get comprehensive list of all available cryptocurrencies
1581
- *
1582
- * Provides a complete list of all cryptocurrencies available for trading.
1583
- * Includes major cryptocurrencies like Bitcoin, Ethereum, and thousands of altcoins
1584
- * with their trading pairs against USD and other major currencies.
1585
- *
1586
- * @returns Promise resolving to array of cryptocurrency data with symbol, name, and exchange information
1587
- *
1588
- * @example
1589
- * ```typescript
1590
- * // Get all available cryptocurrencies
1591
- * const cryptos = await fmp.list.getCryptoList();
1592
- * console.log(`Total cryptocurrencies available: ${cryptos.data.length}`);
1593
- *
1594
- * // Find major cryptocurrencies
1595
- * const bitcoin = cryptos.data.find(crypto => crypto.symbol === 'BTCUSD');
1596
- * console.log(`Bitcoin: ${bitcoin?.name} (${bitcoin?.exchange})`);
1597
- *
1598
- * const ethereum = cryptos.data.find(crypto => crypto.symbol === 'ETHUSD');
1599
- * console.log(`Ethereum: ${ethereum?.name} (${ethereum?.exchange})`);
1600
- *
1601
- * // Filter by exchange
1602
- * const binanceCryptos = cryptos.data.filter(crypto => crypto.exchange === 'Binance');
1603
- * console.log(`Binance cryptocurrencies: ${binanceCryptos.length}`);
1604
- *
1605
- * // Find altcoins
1606
- * const altcoins = cryptos.data.filter(crypto =>
1607
- * !['BTCUSD', 'ETHUSD', 'USDTUSD', 'USDCUSD'].includes(crypto.symbol)
1608
- * );
1609
- * ```
1610
- *
1611
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cryptocurrencies-list-crypto|FMP Cryptocurrency List Documentation}
1612
- */
1613
- async getCryptoList() {
1614
- return this.client.get("/symbol/available-cryptocurrencies");
1615
- }
1616
- /**
1617
- * Get comprehensive list of all available forex currency pairs
1618
- *
1619
- * Provides a complete list of all foreign exchange currency pairs available for trading.
1620
- * Includes major, minor, and exotic currency pairs with their base and quote currencies.
1621
- * Essential for forex trading, currency analysis, and international market research.
1622
- *
1623
- * @returns Promise resolving to array of forex data with currency pair symbols and exchange information
1624
- *
1625
- * @example
1626
- * ```typescript
1627
- * // Get all available forex pairs
1628
- * const forexPairs = await fmp.list.getForexList();
1629
- * console.log(`Total forex pairs available: ${forexPairs.data.length}`);
1630
- *
1631
- * // Find major currency pairs
1632
- * const eurUsd = forexPairs.data.find(pair => pair.symbol === 'EURUSD');
1633
- * console.log(`EUR/USD: ${eurUsd?.name} (${eurUsd?.exchange})`);
1634
- *
1635
- * const gbpUsd = forexPairs.data.find(pair => pair.symbol === 'GBPUSD');
1636
- * console.log(`GBP/USD: ${gbpUsd?.name} (${gbpUsd?.exchange})`);
1637
- *
1638
- * // Filter major pairs (USD as quote currency)
1639
- * const majorPairs = forexPairs.data.filter(pair =>
1640
- * pair.symbol.endsWith('USD') && pair.symbol.length === 6
1641
- * );
1642
- * console.log(`Major pairs: ${majorPairs.length}`);
1643
- *
1644
- * // Find exotic pairs
1645
- * const exoticPairs = forexPairs.data.filter(pair =>
1646
- * pair.symbol.includes('ZAR') || pair.symbol.includes('TRY') || pair.symbol.includes('BRL')
1647
- * );
1648
- * ```
1649
- *
1650
- * @see {@link https://site.financialmodelingprep.com/developer/docs#forex-list-forex|FMP Forex List Documentation}
1651
- */
1652
- async getForexList() {
1653
- return this.client.get("/symbol/available-forex-currency-pairs");
1654
- }
1655
- /**
1656
- * Get comprehensive list of all available market indexes
1657
- *
1658
- * Provides a complete list of all market indexes available for tracking and analysis.
1659
- * Includes major global indexes like S&P 500, NASDAQ, Dow Jones, as well as
1660
- * international indexes, sector indexes, and specialized market benchmarks.
1661
- *
1662
- * @returns Promise resolving to array of index data with symbol, name, and exchange information
1663
- *
1664
- * @example
1665
- * ```typescript
1666
- * // Get all available indexes
1667
- * const indexes = await fmp.list.getAvailableIndexes();
1668
- * console.log(`Total indexes available: ${indexes.data.length}`);
1669
- *
1670
- * // Find major US indexes
1671
- * const sp500 = indexes.data.find(index => index.symbol === '^GSPC');
1672
- * console.log(`S&P 500: ${sp500?.name} (${sp500?.exchange})`);
1673
- *
1674
- * const nasdaq = indexes.data.find(index => index.symbol === '^IXIC');
1675
- * console.log(`NASDAQ: ${nasdaq?.name} (${nasdaq?.exchange})`);
1676
- *
1677
- * const dowJones = indexes.data.find(index => index.symbol === '^DJI');
1678
- * console.log(`Dow Jones: ${dowJones?.name} (${dowJones?.exchange})`);
1679
- *
1680
- * // Filter by exchange
1681
- * const nyseIndexes = indexes.data.filter(index => index.exchange === 'NYSE');
1682
- * console.log(`NYSE indexes: ${nyseIndexes.length}`);
1683
- *
1684
- * // Find sector indexes
1685
- * const techIndexes = indexes.data.filter(index =>
1686
- * index.name.toLowerCase().includes('technology') ||
1687
- * index.name.toLowerCase().includes('tech')
1688
- * );
1689
- * ```
1690
- *
1691
- * @see {@link https://site.financialmodelingprep.com/developer/docs#available-indexes|FMP Available Indexes Documentation}
1692
- */
1693
- async getAvailableIndexes() {
1694
- return this.client.get("/symbol/available-indexes");
1695
- }
1696
- };
1697
-
1698
- // src/endpoints/calendar.ts
1699
- var CalendarEndpoints = class {
1700
- constructor(client) {
1701
- this.client = client;
1702
- }
1703
- /**
1704
- * Get earnings calendar data
1705
- *
1706
- * Provides upcoming earnings announcements for all publicly traded companies
1707
- * within a specified date range. Essential for tracking earnings season,
1708
- * market events, and investment timing decisions.
1709
- *
1710
- * @param params - Earnings calendar request parameters
1711
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1712
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1713
- *
1714
- * @returns Promise resolving to array of earnings calendar data with announcement details
1715
- *
1716
- * @example
1717
- * ```typescript
1718
- * // Get earnings calendar for next week
1719
- * const earningsCalendar = await fmp.calendar.getEarningsCalendar({
1720
- * from: '2024-01-15',
1721
- * to: '2024-01-22'
1722
- * });
1723
- * earningsCalendar.data.forEach(earning => {
1724
- * console.log(`${earning.date}: ${earning.symbol} - Est. EPS: ${earning.estimatedEps}`);
1725
- * });
1726
- *
1727
- * // Get earnings calendar for current month
1728
- * const monthlyEarnings = await fmp.calendar.getEarningsCalendar({
1729
- * from: '2024-01-01',
1730
- * to: '2024-01-31'
1731
- * });
1732
- * ```
1733
- *
1734
- * @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-calendar-earnings|FMP Earnings Calendar Documentation}
1735
- */
1736
- async getEarningsCalendar(params = {}) {
1737
- const { from, to } = params;
1738
- const queryParams = {};
1739
- if (from) queryParams.from = from;
1740
- if (to) queryParams.to = to;
1741
- return this.client.get("/earning_calendar", "v3", queryParams);
1742
- }
1743
- /**
1744
- * Get confirmed earnings calendar data
1745
- *
1746
- * Provides confirmed earnings announcements with verified dates and times.
1747
- * These are earnings announcements that have been officially confirmed
1748
- * by companies, providing more reliable scheduling information.
1749
- *
1750
- * @param params - Confirmed earnings calendar request parameters
1751
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1752
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1753
- *
1754
- * @returns Promise resolving to array of confirmed earnings calendar data
1755
- *
1756
- * @example
1757
- * ```typescript
1758
- * // Get confirmed earnings for next week
1759
- * const confirmedEarnings = await fmp.calendar.getEarningsConfirmed({
1760
- * from: '2024-01-15',
1761
- * to: '2024-01-22'
1762
- * });
1763
- * confirmedEarnings.data.forEach(earning => {
1764
- * console.log(`${earning.date}: ${earning.symbol} - Confirmed: ${earning.time}`);
1765
- * });
1766
- *
1767
- * // Get confirmed earnings for current month
1768
- * const monthlyConfirmed = await fmp.calendar.getEarningsConfirmed({
1769
- * from: '2024-01-01',
1770
- * to: '2024-01-31'
1771
- * });
1772
- * ```
1773
- *
1774
- * @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-confirmed-earnings|FMP Earnings Confirmed Documentation}
1775
- */
1776
- async getEarningsConfirmed(params = {}) {
1777
- const { from, to } = params;
1778
- const queryParams = {};
1779
- if (from) queryParams.from = from;
1780
- if (to) queryParams.to = to;
1781
- return this.client.get("/earning-calendar-confirmed", "v4", queryParams);
1782
- }
1783
- /**
1784
- * Get dividends calendar data
1785
- *
1786
- * Provides upcoming dividend payments and ex-dividend dates for all
1787
- * publicly traded companies within a specified date range. Essential
1788
- * for dividend investors and income-focused strategies.
1789
- *
1790
- * @param params - Dividends calendar request parameters
1791
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1792
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1793
- *
1794
- * @returns Promise resolving to array of dividends calendar data with payment details
1795
- *
1796
- * @example
1797
- * ```typescript
1798
- * // Get dividends calendar for next week
1799
- * const dividendsCalendar = await fmp.calendar.getDividendsCalendar({
1800
- * from: '2024-01-15',
1801
- * to: '2024-01-22'
1802
- * });
1803
- * dividendsCalendar.data.forEach(dividend => {
1804
- * console.log(`${dividend.date}: ${dividend.symbol} - Amount: $${dividend.amount}`);
1805
- * });
1806
- *
1807
- * // Get dividends calendar for current month
1808
- * const monthlyDividends = await fmp.calendar.getDividendsCalendar({
1809
- * from: '2024-01-01',
1810
- * to: '2024-01-31'
1811
- * });
1812
- * ```
1813
- *
1814
- * @see {@link https://site.financialmodelingprep.com/developer/docs#dividends-calendar-dividends|FMP Dividends Calendar Documentation}
1815
- */
1816
- async getDividendsCalendar(params = {}) {
1817
- const { from, to } = params;
1818
- const queryParams = {};
1819
- if (from) queryParams.from = from;
1820
- if (to) queryParams.to = to;
1821
- return this.client.get("/stock_dividend_calendar", "v3", queryParams);
1822
- }
1823
- /**
1824
- * Get economic calendar data
1825
- *
1826
- * Provides upcoming economic events, indicators, and data releases
1827
- * that can impact financial markets. Essential for understanding
1828
- * market-moving events and economic trends.
1829
- *
1830
- * @param params - Economic calendar request parameters
1831
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1832
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1833
- *
1834
- * @returns Promise resolving to array of economic calendar data with event details
1835
- *
1836
- * @example
1837
- * ```typescript
1838
- * // Get economic calendar for next week
1839
- * const economicCalendar = await fmp.calendar.getEconomicsCalendar({
1840
- * from: '2024-01-15',
1841
- * to: '2024-01-22'
1842
- * });
1843
- * economicCalendar.data.forEach(event => {
1844
- * console.log(`${event.date}: ${event.event} - Country: ${event.country}`);
1845
- * });
1846
- *
1847
- * // Get economic calendar for current month
1848
- * const monthlyEconomic = await fmp.calendar.getEconomicsCalendar({
1849
- * from: '2024-01-01',
1850
- * to: '2024-01-31'
1851
- * });
1852
- * ```
1853
- *
1854
- * @see {@link https://site.financialmodelingprep.com/developer/docs#economics-calendar-economics-data|FMP Economic Calendar Documentation}
1855
- */
1856
- async getEconomicsCalendar(params = {}) {
1857
- const { from, to } = params;
1858
- const queryParams = {};
1859
- if (from) queryParams.from = from;
1860
- if (to) queryParams.to = to;
1861
- return this.client.get("/economic_calendar", "v3", queryParams);
1862
- }
1863
- /**
1864
- * Get IPO calendar data
1865
- *
1866
- * Provides upcoming initial public offerings (IPOs) and their details
1867
- * within a specified date range. Essential for tracking new market
1868
- * entrants and investment opportunities in newly public companies.
1869
- *
1870
- * @param params - IPO calendar request parameters
1871
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1872
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1873
- *
1874
- * @returns Promise resolving to array of IPO calendar data with offering details
1875
- *
1876
- * @example
1877
- * ```typescript
1878
- * // Get IPO calendar for next week
1879
- * const ipoCalendar = await fmp.calendar.getIPOCalendar({
1880
- * from: '2024-01-15',
1881
- * to: '2024-01-22'
1882
- * });
1883
- * ipoCalendar.data.forEach(ipo => {
1884
- * console.log(`${ipo.date}: ${ipo.symbol} - Price: $${ipo.price}, Shares: ${ipo.shares.toLocaleString()}`);
1885
- * });
1886
- *
1887
- * // Get IPO calendar for current month
1888
- * const monthlyIPOs = await fmp.calendar.getIPOCalendar({
1889
- * from: '2024-01-01',
1890
- * to: '2024-01-31'
1891
- * });
1892
- * ```
1893
- *
1894
- * @see {@link https://site.financialmodelingprep.com/developer/docs#ipo-calender-by-ipo-calendar|FMP IPO Calendar Documentation}
1895
- */
1896
- async getIPOCalendar(params = {}) {
1897
- const { from, to } = params;
1898
- const queryParams = {};
1899
- if (from) queryParams.from = from;
1900
- if (to) queryParams.to = to;
1901
- return this.client.get("/ipo_calendar", "v3", queryParams);
1902
- }
1903
- /**
1904
- * Get stock splits calendar data
1905
- *
1906
- * Provides upcoming stock splits for publicly traded companies within
1907
- * a specified date range. Essential for understanding corporate actions
1908
- * that affect share prices and trading dynamics.
1909
- *
1910
- * @param params - Stock splits calendar request parameters
1911
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to today)
1912
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to 30 days from today)
1913
- *
1914
- * @returns Promise resolving to array of stock splits calendar data with split details
1915
- *
1916
- * @example
1917
- * ```typescript
1918
- * // Get stock splits calendar for next week
1919
- * const splitsCalendar = await fmp.calendar.getSplitsCalendar({
1920
- * from: '2024-01-15',
1921
- * to: '2024-01-22'
1922
- * });
1923
- * splitsCalendar.data.forEach(split => {
1924
- * console.log(`${split.date}: ${split.symbol} - Ratio: ${split.numerator}:${split.denominator}`);
1925
- * });
1926
- *
1927
- * // Get stock splits calendar for current month
1928
- * const monthlySplits = await fmp.calendar.getSplitsCalendar({
1929
- * from: '2024-01-01',
1930
- * to: '2024-01-31'
1931
- * });
1932
- * ```
1933
- *
1934
- * @see {@link https://site.financialmodelingprep.com/developer/docs#splits-calendar-splits|FMP Stock Splits Calendar Documentation}
1935
- */
1936
- async getSplitsCalendar(params = {}) {
1937
- const { from, to } = params;
1938
- const queryParams = {};
1939
- if (from) queryParams.from = from;
1940
- if (to) queryParams.to = to;
1941
- return this.client.get("/stock_split_calendar", "v3", queryParams);
1942
- }
1943
- };
1944
-
1945
- // src/endpoints/company.ts
1946
- var CompanyEndpoints = class {
1947
- constructor(client) {
1948
- this.client = client;
1949
- }
1950
- /**
1951
- * Get comprehensive company profile and information
1952
- *
1953
- * Provides detailed company information including financial metrics, business description,
1954
- * headquarters location, and key performance indicators. Essential for fundamental analysis
1955
- * and understanding a company's business model and market position.
1956
- *
1957
- * @param symbol - The stock symbol to get the profile for (e.g., 'AAPL', 'MSFT', 'GOOGL')
1958
- *
1959
- * @returns Promise resolving to comprehensive company profile with financial and business information
1960
- *
1961
- * @example
1962
- * ```typescript
1963
- * // Get Apple's company profile
1964
- * const profile = await fmp.company.getCompanyProfile('AAPL');
1965
- * console.log(`Company: ${profile.data.companyName}`);
1966
- * console.log(`Industry: ${profile.data.industry}`);
1967
- * console.log(`Market Cap: $${profile.data.mktCap.toLocaleString()}`);
1968
- * console.log(`Description: ${profile.data.description.substring(0, 100)}...`);
1969
- *
1970
- * // Get Microsoft's profile
1971
- * const msftProfile = await fmp.company.getCompanyProfile('MSFT');
1972
- * ```
1973
- *
1974
- * @see {@link https://site.financialmodelingprep.com/developer/docs#company-profile-company-information|FMP Company Profile Documentation}
1975
- */
1976
- async getCompanyProfile(symbol) {
1977
- return this.client.getSingle(`/profile/${symbol}`, "v3");
1978
- }
1979
- /**
1980
- * Get executive compensation and governance information
1981
- *
1982
- * Provides detailed compensation data for company executives including salary, bonuses,
1983
- * stock options, and other benefits. Essential for governance analysis and understanding
1984
- * executive pay structures and alignment with shareholder interests.
1985
- *
1986
- * @param symbol - The stock symbol to get executive compensation for (e.g., 'AAPL', 'MSFT', 'TSLA')
1987
- *
1988
- * @returns Promise resolving to array of executive compensation data with detailed pay information
1989
- *
1990
- * @example
1991
- * ```typescript
1992
- * // Get Apple's executive compensation
1993
- * const compensation = await fmp.company.getExecutiveCompensation('AAPL');
1994
- * compensation.data.forEach(exec => {
1995
- * console.log(`${exec.name} (${exec.title}):`);
1996
- * console.log(` Salary: $${exec.salary.toLocaleString()}`);
1997
- * console.log(` Bonus: $${exec.bonus.toLocaleString()}`);
1998
- * console.log(` Stock Options: $${exec.stockAwards.toLocaleString()}`);
1999
- * });
2000
- *
2001
- * // Get Tesla's executive compensation
2002
- * const teslaComp = await fmp.company.getExecutiveCompensation('TSLA');
2003
- * ```
2004
- *
2005
- * @see {@link https://site.financialmodelingprep.com/developer/docs#executive-compensation-company-information|FMP Executive Compensation Documentation}
2006
- */
2007
- async getExecutiveCompensation(symbol) {
2008
- return this.client.get(`/governance/executive_compensation`, "v4", { symbol });
2009
- }
2010
- /**
2011
- * Get company notes and financial disclosures
2012
- *
2013
- * Provides important notes and disclosures from company financial statements.
2014
- * These notes contain critical information about accounting policies, risks,
2015
- * contingencies, and other material information that affects financial analysis.
2016
- *
2017
- * @param symbol - The stock symbol to get notes for (e.g., 'AAPL', 'MSFT', 'JPM')
2018
- *
2019
- * @returns Promise resolving to array of company notes with detailed disclosure information
2020
- *
2021
- * @example
2022
- * ```typescript
2023
- * // Get Apple's company notes
2024
- * const notes = await fmp.company.getCompanyNotes('AAPL');
2025
- * notes.data.forEach(note => {
2026
- * console.log(`Note ${note.noteNumber}: ${note.noteTitle}`);
2027
- * console.log(` Content: ${note.noteContent.substring(0, 100)}...`);
2028
- * });
2029
- *
2030
- * // Get JPMorgan's notes
2031
- * const jpmNotes = await fmp.company.getCompanyNotes('JPM');
2032
- * ```
2033
- *
2034
- * @see {@link https://site.financialmodelingprep.com/developer/docs#company-notes-company-information|FMP Company Notes Documentation}
2035
- */
2036
- async getCompanyNotes(symbol) {
2037
- return this.client.get(`/company-notes`, "v4", { symbol });
2038
- }
2039
- /**
2040
- * Get historical employee count data
2041
- *
2042
- * Provides historical data on company employee counts over time.
2043
- * Useful for analyzing company growth, operational efficiency, and workforce trends.
2044
- * Employee count is often a key indicator of company expansion or contraction.
2045
- *
2046
- * @param symbol - The stock symbol to get historical employee count for (e.g., 'AAPL', 'MSFT', 'AMZN')
2047
- *
2048
- * @returns Promise resolving to array of historical employee count data with year-by-year information
2049
- *
2050
- * @example
2051
- * ```typescript
2052
- * // Get Apple's employee count history
2053
- * const employees = await fmp.company.getHistoricalEmployeeCount('AAPL');
2054
- * employees.data.forEach(year => {
2055
- * console.log(`${year.year}: ${year.employeeCount.toLocaleString()} employees`);
2056
- * });
2057
- *
2058
- * // Get Amazon's employee growth
2059
- * const amazonEmployees = await fmp.company.getHistoricalEmployeeCount('AMZN');
2060
- * ```
2061
- *
2062
- * @see {@link https://site.financialmodelingprep.com/developer/docs#historical-employee-company-information|FMP Historical Employee Count Documentation}
2063
- */
2064
- async getHistoricalEmployeeCount(symbol) {
2065
- return this.client.get(`/historical/employee_count`, "v4", { symbol });
2066
- }
2067
- /**
2068
- * Get current shares float information
2069
- *
2070
- * Provides the total number of shares that are publicly traded (float) for a company.
2071
- * The float is calculated by subtracting restricted shares from total outstanding shares.
2072
- * Important for understanding liquidity, volatility, and trading dynamics.
2073
- *
2074
- * @param symbol - The stock symbol to get shares float for (e.g., 'AAPL', 'TSLA', 'NVDA')
2075
- *
2076
- * @returns Promise resolving to shares float data with current float information
2077
- *
2078
- * @example
2079
- * ```typescript
2080
- * // Get Apple's shares float
2081
- * const float = await fmp.company.getSharesFloat('AAPL');
2082
- * console.log(`Float: ${float.data.sharesFloat.toLocaleString()} shares`);
2083
- * console.log(`Outstanding: ${float.data.sharesOutstanding.toLocaleString()} shares`);
2084
- * console.log(`Restricted: ${float.data.restrictedShares.toLocaleString()} shares`);
2085
- *
2086
- * // Get Tesla's float
2087
- * const teslaFloat = await fmp.company.getSharesFloat('TSLA');
2088
- * ```
2089
- *
2090
- * @see {@link https://site.financialmodelingprep.com/developer/docs#company-share-float-share-float|FMP Shares Float Documentation}
2091
- */
2092
- async getSharesFloat(symbol) {
2093
- return this.client.getSingle(`/shares_float`, "v4", { symbol });
2094
- }
2095
- /**
2096
- * Get historical shares float data
2097
- *
2098
- * Provides historical data on company shares float over time.
2099
- * Useful for analyzing changes in liquidity, share issuance, and corporate actions
2100
- * that affect the number of publicly traded shares.
2101
- *
2102
- * @param symbol - The stock symbol to get historical shares float for (e.g., 'AAPL', 'TSLA', 'NVDA')
2103
- *
2104
- * @returns Promise resolving to array of historical shares float data with date-by-date information
2105
- *
2106
- * @example
2107
- * ```typescript
2108
- * // Get Apple's historical float
2109
- * const historicalFloat = await fmp.company.getHistoricalSharesFloat('AAPL');
2110
- * historicalFloat.data.forEach(entry => {
2111
- * console.log(`${entry.date}: ${entry.sharesFloat.toLocaleString()} shares`);
2112
- * });
2113
- *
2114
- * // Get Tesla's float history
2115
- * const teslaHistory = await fmp.company.getHistoricalSharesFloat('TSLA');
2116
- * ```
2117
- *
2118
- * @see {@link https://site.financialmodelingprep.com/developer/docs#company-historical-share-float|FMP Historical Shares Float Documentation}
2119
- */
2120
- async getHistoricalSharesFloat(symbol) {
2121
- return this.client.get(`/historical/shares_float`, "v4", { symbol });
2122
- }
2123
- /**
2124
- * Get earnings call transcript for specific quarter
2125
- *
2126
- * Provides the full transcript of a company's earnings conference call.
2127
- * Contains detailed Q&A sessions, management commentary, and insights into
2128
- * company performance, strategy, and future outlook.
2129
- *
2130
- * @param params - Earnings call transcript request parameters
2131
- * @param params.symbol - The stock symbol to get transcript for (e.g., 'AAPL', 'MSFT', 'TSLA')
2132
- * @param params.year - The year of the earnings call (e.g., 2024)
2133
- * @param params.quarter - The quarter of the earnings call (1, 2, 3, or 4)
2134
- *
2135
- * @returns Promise resolving to earnings call transcript with full text content
2136
- *
2137
- * @example
2138
- * ```typescript
2139
- * // Get Apple's Q1 2024 earnings call
2140
- * const transcript = await fmp.company.getEarningsCallTranscript({
2141
- * symbol: 'AAPL',
2142
- * year: 2024,
2143
- * quarter: 1
2144
- * });
2145
- * console.log(`Transcript: ${transcript.data[0].content.substring(0, 200)}...`);
2146
- *
2147
- * // Get Tesla's Q4 2023 earnings call
2148
- * const teslaTranscript = await fmp.company.getEarningsCallTranscript({
2149
- * symbol: 'TSLA',
2150
- * year: 2023,
2151
- * quarter: 4
2152
- * });
2153
- * ```
2154
- *
2155
- * @see {@link https://site.financialmodelingprep.com/developer/docs#earnings-transcript-earnings-transcripts|FMP Earnings Call Transcript Documentation}
2156
- */
2157
- async getEarningsCallTranscript(params) {
2158
- const { symbol, year, quarter } = params;
2159
- return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", { year, quarter });
2160
- }
2161
- /**
2162
- * Get available earnings call transcript dates
2163
- *
2164
- * Provides a list of all available earnings call transcript dates for a company.
2165
- * Useful for discovering which quarters have transcripts available before
2166
- * requesting the full transcript content.
2167
- *
2168
- * @param symbol - The stock symbol to get transcript dates for (e.g., 'AAPL', 'MSFT', 'TSLA')
2169
- *
2170
- * @returns Promise resolving to array of available transcript dates with quarter information
2171
- *
2172
- * @example
2173
- * ```typescript
2174
- * // Get Apple's available transcript dates
2175
- * const transcriptDates = await fmp.company.getCompanyTranscriptData('AAPL');
2176
- * transcriptDates.data.forEach(date => {
2177
- * console.log(`Q${date.quarter} ${date.year}: ${date.date}`);
2178
- * });
2179
- *
2180
- * // Get Microsoft's transcript availability
2181
- * const msftDates = await fmp.company.getCompanyTranscriptData('MSFT');
2182
- * ```
2183
- *
2184
- * @see {@link https://site.financialmodelingprep.com/developer/docs#transcript-dates-earnings-transcripts|FMP Company Transcript Data Documentation}
2185
- */
2186
- async getCompanyTranscriptData(symbol) {
2187
- return this.client.getSingle(`/earning_call_transcript`, "v4", { symbol });
2188
- }
2189
- };
2190
-
2191
- // src/endpoints/quote.ts
2192
- var QuoteEndpoints = class {
2193
- constructor(client) {
2194
- this.client = client;
2195
- }
2196
- /**
2197
- * Get real-time quote data for any asset type (stocks, crypto, forex, commodities, ETFs)
2198
- *
2199
- * This endpoint provides current market data including price, volume, market cap, and key metrics.
2200
- * Works with any valid symbol across all supported asset classes.
2201
- *
2202
- * @param symbol - The trading symbol (e.g., 'AAPL', 'BTCUSD', 'EURUSD', 'GCUSD', 'SPY')
2203
- *
2204
- * @returns Promise resolving to quote data with current price, volume, market cap, and performance metrics
2205
- *
2206
- * @example
2207
- * ```typescript
2208
- * // Get stock quote
2209
- * const aaplQuote = await fmp.quote.getQuote('AAPL');
2210
- *
2211
- * // Get crypto quote
2212
- * const btcQuote = await fmp.quote.getQuote('BTCUSD');
2213
- *
2214
- * // Get forex quote
2215
- * const eurQuote = await fmp.quote.getQuote('EURUSD');
2216
- * ```
2217
- */
2218
- async getQuote(symbol) {
2219
- return this.client.getSingle(`/quote/${symbol}`, "v3");
2220
- }
2221
- /**
2222
- * Get historical price data for any asset type with customizable date range
2223
- *
2224
- * Retrieves daily OHLCV (Open, High, Low, Close, Volume) data for the specified symbol.
2225
- * Data includes adjusted close prices, volume, and percentage changes.
2226
- *
2227
- * @param params - Historical price request parameters
2228
- * @param params.symbol - The trading symbol to get historical data for
2229
- * @param params.from - Start date in YYYY-MM-DD format (optional, defaults to 1 year ago)
2230
- * @param params.to - End date in YYYY-MM-DD format (optional, defaults to today)
2231
- *
2232
- * @returns Promise resolving to historical price data with daily OHLCV information
2233
- *
2234
- * @example
2235
- * ```typescript
2236
- * // Get last year's data
2237
- * const history = await fmp.quote.getHistoricalPrice({
2238
- * symbol: 'AAPL',
2239
- * from: '2023-01-01',
2240
- * to: '2023-12-31'
2241
- * });
2242
- *
2243
- * // Get recent data (last 30 days)
2244
- * const recent = await fmp.quote.getHistoricalPrice({
2245
- * symbol: 'BTCUSD',
2246
- * from: '2024-01-01'
2247
- * });
2248
- * ```
2249
- */
2250
- async getHistoricalPrice(params) {
2251
- const { symbol, from, to } = params;
2252
- const queryParams = {};
2253
- if (from) queryParams.from = from;
2254
- if (to) queryParams.to = to;
2255
- return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", queryParams);
2256
- }
2257
- /**
2258
- * Get real-time quotes for multiple symbols in a single request
2259
- *
2260
- * Efficiently retrieve quote data for multiple assets across different asset classes.
2261
- * Useful for portfolio tracking, market monitoring, or batch data collection.
2262
- *
2263
- * @param symbols - Array of trading symbols to get quotes for
2264
- *
2265
- * @returns Promise resolving to an array of quote data for all requested symbols
2266
- *
2267
- * @example
2268
- * ```typescript
2269
- * // Get quotes for a mixed portfolio
2270
- * const quotes = await fmp.quote.getQuotes([
2271
- * 'AAPL', // Stock
2272
- * 'BTCUSD', // Crypto
2273
- * 'EURUSD', // Forex
2274
- * 'SPY' // ETF
2275
- * ]);
2276
- *
2277
- * // Get quotes for tech stocks
2278
- * const techQuotes = await fmp.quote.getQuotes([
2279
- * 'AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TSLA'
2280
- * ]);
2281
- * ```
2282
- */
2283
- async getQuotes(symbols) {
2284
- const symbolsParam = symbols.join(",");
2285
- return this.client.get(`/quote/${symbolsParam}`, "v3");
2286
- }
2287
- /**
2288
- * Get intraday price data with customizable time intervals
2289
- *
2290
- * Retrieves intraday OHLCV data at specified intervals (1min to 4hour).
2291
- * Perfect for technical analysis, day trading, or short-term price monitoring.
2292
- *
2293
- * @param params - Intraday request parameters
2294
- * @param params.symbol - The trading symbol to get intraday data for
2295
- * @param params.interval - Time interval: '1min', '5min', '15min', '30min', '1hour', or '4hour'
2296
- * @param params.from - Start date in YYYY-MM-DD format (optional)
2297
- * @param params.to - End date in YYYY-MM-DD format (optional)
2298
- *
2299
- * @returns Promise resolving to intraday price data with OHLCV information at specified intervals
2300
- *
2301
- * @example
2302
- * ```typescript
2303
- * // Get 5-minute intraday data for today
2304
- * const intraday = await fmp.quote.getIntraday({
2305
- * symbol: 'AAPL',
2306
- * interval: '5min',
2307
- * from: '2024-01-15'
2308
- * });
2309
- *
2310
- * // Get 1-hour data for crypto
2311
- * const cryptoIntraday = await fmp.quote.getIntraday({
2312
- * symbol: 'BTCUSD',
2313
- * interval: '1hour',
2314
- * from: '2024-01-10',
2315
- * to: '2024-01-15'
2316
- * });
2317
- * ```
2318
- */
2319
- async getIntraday(params) {
2320
- const { symbol, interval, from, to } = params;
2321
- const queryParams = {};
2322
- if (from) queryParams.from = from;
2323
- if (to) queryParams.to = to;
2324
- return this.client.get(`/historical-chart/${interval}/${symbol}`, "v3", queryParams);
2325
- }
2326
- };
2327
-
2328
- // src/endpoints/senate-house.ts
2329
- var SenateHouseEndpoints = class {
2330
- constructor(client) {
2331
- this.client = client;
2332
- }
2333
- /**
2334
- * Get senate trading data for a specific stock symbol
2335
- *
2336
- * Provides detailed information about senate members' trading activities for a specific stock.
2337
- * Includes transaction details, amounts, dates, and ownership information for transparency
2338
- * and compliance with the STOCK Act (Stop Trading on Congressional Knowledge).
2339
- *
2340
- * @param params - Senate trading request parameters
2341
- * @param params.symbol - The stock symbol to get senate trading data for (e.g., 'AAPL', 'MSFT', 'TSLA')
2342
- *
2343
- * @returns Promise resolving to array of senate trading data with transaction details
2344
- *
2345
- * @example
2346
- * ```typescript
2347
- * // Get senate trading data for Apple
2348
- * const appleSenateTrading = await fmp.senateHouse.getSenateTrading({ symbol: 'AAPL' });
2349
- * appleSenateTrading.data.forEach(trade => {
2350
- * console.log(`${trade.firstName} ${trade.lastName} (${trade.office}):`);
2351
- * console.log(` ${trade.type} ${trade.amount} of ${trade.assetDescription}`);
2352
- * console.log(` Transaction Date: ${trade.transactionDate}`);
2353
- * });
2354
- *
2355
- * // Get senate trading data for Tesla
2356
- * const teslaSenateTrading = await fmp.senateHouse.getSenateTrading({ symbol: 'TSLA' });
2357
- * ```
2358
- *
2359
- * @see {@link https://site.financialmodelingprep.com/developer/docs#senate-trading|FMP Senate Trading Documentation}
2360
- */
2361
- async getSenateTrading(params) {
2362
- const { symbol } = params;
2363
- return this.client.get(`/senate-trading`, "v4", { symbol });
2364
- }
2365
- /**
2366
- * Get senate trading RSS feed with pagination
2367
- *
2368
- * Provides a paginated RSS feed of all senate trading activities across all stocks.
2369
- * Useful for monitoring congressional trading activities, compliance tracking,
2370
- * and transparency reporting. Returns recent trading disclosures from senate members.
2371
- *
2372
- * @param params - Senate trading RSS feed request parameters
2373
- * @param params.page - The page number to retrieve (starts from 0)
2374
- *
2375
- * @returns Promise resolving to array of senate trading data from RSS feed
2376
- *
2377
- * @example
2378
- * ```typescript
2379
- * // Get first page of senate trading RSS feed
2380
- * const firstPage = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 0 });
2381
- * console.log(`First page: ${firstPage.data.length} trading activities`);
2382
- *
2383
- * // Get second page of senate trading RSS feed
2384
- * const secondPage = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 1 });
2385
- * console.log(`Second page: ${secondPage.data.length} trading activities`);
2386
- *
2387
- * // Get recent senate trading activities
2388
- * const recentTrades = await fmp.senateHouse.getSenateTradingRSSFeed({ page: 0 });
2389
- * recentTrades.data.forEach(trade => {
2390
- * console.log(`${trade.firstName} ${trade.lastName}: ${trade.type} ${trade.amount}`);
2391
- * });
2392
- * ```
2393
- *
2394
- * @see {@link https://site.financialmodelingprep.com/developer/docs#senate-trading-rss-feed-senate|FMP Senate Trading RSS Feed Documentation}
2395
- */
2396
- async getSenateTradingRSSFeed(params) {
2397
- const { page } = params;
2398
- return this.client.get("/senate-trading-rss-feed", "v4", { page });
2399
- }
2400
- /**
2401
- * Get senate trading data for a specific senator by name
2402
- *
2403
- * Provides detailed trading activities for a specific senate member across all stocks.
2404
- * Useful for tracking individual senator's trading patterns, compliance monitoring,
2405
- * and transparency reporting. Returns all trading disclosures for the specified senator.
2406
- *
2407
- * @param params - Senate trading by name request parameters
2408
- * @param params.name - The name of the senator to get trading data for (e.g., 'John Smith', 'Jane Doe')
2409
- *
2410
- * @returns Promise resolving to array of senate trading data for the specified senator
2411
- *
2412
- * @example
2413
- * ```typescript
2414
- * // Get trading data for Senator John Smith
2415
- * const johnSmithTrades = await fmp.senateHouse.getSenateTradingByName({ name: 'John Smith' });
2416
- * johnSmithTrades.data.forEach(trade => {
2417
- * console.log(`${trade.symbol}: ${trade.type} ${trade.amount}`);
2418
- * console.log(` Transaction Date: ${trade.transactionDate}`);
2419
- * console.log(` Asset: ${trade.assetDescription}`);
2420
- * });
2421
- *
2422
- * // Get trading data for Senator Jane Doe
2423
- * const janeDoeTrades = await fmp.senateHouse.getSenateTradingByName({ name: 'Jane Doe' });
2424
- * console.log(`Jane Doe has ${janeDoeTrades.data.length} trading activities`);
2425
- * ```
2426
- *
2427
- * @see {@link https://site.financialmodelingprep.com/developer/docs/stable#senate-trading-by-name|FMP Senate Trading by Name Documentation}
2428
- */
2429
- async getSenateTradingByName(params) {
2430
- const { name } = params;
2431
- return this.client.get("/senate-trades-by-name", "stable", { name });
2432
- }
2433
- /**
2434
- * Get house trading data for a specific stock symbol
2435
- *
2436
- * Provides detailed information about house representatives' trading activities for a specific stock.
2437
- * Includes transaction details, amounts, dates, and district information for transparency
2438
- * and compliance with the STOCK Act (Stop Trading on Congressional Knowledge).
2439
- *
2440
- * @param params - House trading request parameters
2441
- * @param params.symbol - The stock symbol to get house trading data for (e.g., 'AAPL', 'MSFT', 'TSLA')
2442
- *
2443
- * @returns Promise resolving to array of house trading data with transaction details
2444
- *
2445
- * @example
2446
- * ```typescript
2447
- * // Get house trading data for Apple
2448
- * const appleHouseTrading = await fmp.senateHouse.getHouseTrading({ symbol: 'AAPL' });
2449
- * appleHouseTrading.data.forEach(trade => {
2450
- * console.log(`${trade.representative} (District ${trade.district}):`);
2451
- * console.log(` ${trade.type} ${trade.amount} of ${trade.assetDescription}`);
2452
- * console.log(` Transaction Date: ${trade.transactionDate}`);
2453
- * });
2454
- *
2455
- * // Get house trading data for Microsoft
2456
- * const msftHouseTrading = await fmp.senateHouse.getHouseTrading({ symbol: 'MSFT' });
2457
- * console.log(`Microsoft house trading activities: ${msftHouseTrading.data.length}`);
2458
- * ```
2459
- *
2460
- * @see {@link https://site.financialmodelingprep.com/developer/docs#house-disclosure|FMP House Trading Documentation}
2461
- */
2462
- async getHouseTrading(params) {
2463
- const { symbol } = params;
2464
- return this.client.get("/senate-disclosure", "v4", { symbol });
2465
- }
2466
- /**
2467
- * Get house trading RSS feed with pagination
2468
- *
2469
- * Provides a paginated RSS feed of all house trading activities across all stocks.
2470
- * Useful for monitoring congressional trading activities, compliance tracking,
2471
- * and transparency reporting. Returns recent trading disclosures from house representatives.
2472
- *
2473
- * @param params - House trading RSS feed request parameters
2474
- * @param params.page - The page number to retrieve (starts from 0)
2475
- *
2476
- * @returns Promise resolving to array of house trading data from RSS feed
2477
- *
2478
- * @example
2479
- * ```typescript
2480
- * // Get first page of house trading RSS feed
2481
- * const firstPage = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 0 });
2482
- * console.log(`First page: ${firstPage.data.length} trading activities`);
2483
- *
2484
- * // Get second page of house trading RSS feed
2485
- * const secondPage = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 1 });
2486
- * console.log(`Second page: ${secondPage.data.length} trading activities`);
2487
- *
2488
- * // Get recent house trading activities
2489
- * const recentTrades = await fmp.senateHouse.getHouseTradingRSSFeed({ page: 0 });
2490
- * recentTrades.data.forEach(trade => {
2491
- * console.log(`${trade.representative} (District ${trade.district}): ${trade.type} ${trade.amount}`);
2492
- * });
2493
- * ```
2494
- *
2495
- * @see {@link https://site.financialmodelingprep.com/developer/docs#house-disclosure-rss-feed-senate|FMP House Trading RSS Feed Documentation}
2496
- */
2497
- async getHouseTradingRSSFeed(params) {
2498
- const { page } = params;
2499
- return this.client.get("/senate-disclosure-rss-feed", "v4", { page });
2500
- }
2501
- /**
2502
- * Get house trading data for a specific representative by name
2503
- *
2504
- * Provides detailed trading activities for a specific house representative across all stocks.
2505
- * Useful for tracking individual representative's trading patterns, compliance monitoring,
2506
- * and transparency reporting. Returns all trading disclosures for the specified representative.
2507
- *
2508
- * @param params - House trading by name request parameters
2509
- * @param params.name - The name of the representative to get trading data for (e.g., 'John Smith', 'Jane Doe')
2510
- *
2511
- * @returns Promise resolving to array of house trading data for the specified representative
2512
- *
2513
- * @example
2514
- * ```typescript
2515
- * // Get trading data for Representative John Smith
2516
- * const johnSmithTrades = await fmp.senateHouse.getHouseTradingByName({ name: 'John Smith' });
2517
- * johnSmithTrades.data.forEach(trade => {
2518
- * console.log(`${trade.symbol}: ${trade.type} ${trade.amount}`);
2519
- * console.log(` Transaction Date: ${trade.transactionDate}`);
2520
- * console.log(` Asset: ${trade.assetDescription}`);
2521
- * console.log(` District: ${trade.district}`);
2522
- * });
2523
- *
2524
- * // Get trading data for Representative Jane Doe
2525
- * const janeDoeTrades = await fmp.senateHouse.getHouseTradingByName({ name: 'Jane Doe' });
2526
- * console.log(`Jane Doe has ${janeDoeTrades.data.length} trading activities`);
2527
- * ```
2528
- *
2529
- * @see {@link https://site.financialmodelingprep.com/developer/docs/stable#house-trading-by-name|FMP House Trading by Name Documentation}
2530
- */
2531
- async getHouseTradingByName(params) {
2532
- const { name } = params;
2533
- return this.client.get("/house-trades-by-name", "stable", { name });
2534
- }
2535
- };
2536
-
2537
- // src/endpoints/institutional.ts
2538
- var InstitutionalEndpoints = class {
2539
- constructor(client) {
2540
- this.client = client;
2541
- }
2542
- /**
2543
- * Get Form 13F institutional stock ownership data
2544
- *
2545
- * Provides Form 13F institutional stock ownership data for investment
2546
- * managers with over $100 million in assets under management. Essential
2547
- * for analyzing institutional investment patterns and holdings.
2548
- *
2549
- * @param params - Form 13F request parameters
2550
- * @param params.cik - Central Index Key (CIK) of the investment manager
2551
- * @param params.date - Specific date in YYYY-MM-DD format (optional, defaults to most recent filing)
2552
- *
2553
- * @returns Promise resolving to array of Form 13F institutional ownership data
2554
- *
2555
- * @example
2556
- * ```typescript
2557
- * // Get Berkshire Hathaway's Form 13F data
2558
- * const berkshire13F = await fmp.institutional.getForm13F({
2559
- * cik: '0001067983'
2560
- * });
2561
- * berkshire13F.data.forEach(holding => {
2562
- * console.log(`${holding.issuerName}: ${holding.value.toLocaleString()} shares, $${holding.value.toLocaleString()}`);
2563
- * });
2564
- *
2565
- * // Get Form 13F data for specific date
2566
- * const historical13F = await fmp.institutional.getForm13F({
2567
- * cik: '0001067983',
2568
- * date: '2023-12-31'
2569
- * });
2570
- *
2571
- * // Get BlackRock's Form 13F data
2572
- * const blackrock13F = await fmp.institutional.getForm13F({
2573
- * cik: '0001364742'
2574
- * });
2575
- * ```
2576
- *
2577
- * @see {@link https://site.financialmodelingprep.com/developer/docs#form-13f-13f---institutional-stock-ownership|FMP Form 13F Documentation}
2578
- */
2579
- async getForm13F(params) {
2580
- const { cik, date } = params;
2581
- const queryParams = {};
2582
- if (date) queryParams.date = date;
2583
- return this.client.get(`/form-thirteen/${cik}`, "v3", queryParams);
2584
- }
2585
- /**
2586
- * Get Form 13F filing dates for an investment manager
2587
- *
2588
- * Provides available filing dates for Form 13F submissions by a specific
2589
- * investment manager. Essential for discovering historical filing dates
2590
- * before requesting detailed Form 13F data.
2591
- *
2592
- * @param params - Form 13F dates request parameters
2593
- * @param params.cik - Central Index Key (CIK) of the investment manager
2594
- *
2595
- * @returns Promise resolving to array of available Form 13F filing dates
2596
- *
2597
- * @example
2598
- * ```typescript
2599
- * // Get Berkshire Hathaway's Form 13F filing dates
2600
- * const berkshireDates = await fmp.institutional.getForm13FDates({
2601
- * cik: '0001067983'
2602
- * });
2603
- * berkshireDates.data.forEach(date => {
2604
- * console.log(`Filing date: ${date}`);
2605
- * });
2606
- *
2607
- * // Get BlackRock's filing dates
2608
- * const blackrockDates = await fmp.institutional.getForm13FDates({
2609
- * cik: '0001364742'
2610
- * });
2611
- * ```
2612
- *
2613
- * @see {@link https://site.financialmodelingprep.com/developer/docs#form-13f-dates-13f---institutional-stock-ownership|FMP Form 13F Dates Documentation}
2614
- */
2615
- async getForm13FDates(params) {
2616
- const { cik } = params;
2617
- return this.client.get(`/form-thirteen-date/${cik}`, "v3");
2618
- }
2619
- /**
2620
- * Get institutional holders for a company
2621
- *
2622
- * Provides data on institutional investors holding shares in a specific
2623
- * company. Essential for understanding institutional ownership patterns,
2624
- * major shareholders, and investment sentiment.
2625
- *
2626
- * @param params - Institutional holders request parameters
2627
- * @param params.symbol - Stock symbol to get institutional holders for
2628
- *
2629
- * @returns Promise resolving to array of institutional holders data
2630
- *
2631
- * @example
2632
- * ```typescript
2633
- * // Get Apple's institutional holders
2634
- * const appleHolders = await fmp.institutional.getInstitutionalHolders({
2635
- * symbol: 'AAPL'
2636
- * });
2637
- * appleHolders.data.forEach(holder => {
2638
- * console.log(`${holder.holder}: ${holder.shares.toLocaleString()} shares (${holder.weight}%)`);
2639
- * });
2640
- *
2641
- * // Get Microsoft's institutional holders
2642
- * const msftHolders = await fmp.institutional.getInstitutionalHolders({
2643
- * symbol: 'MSFT'
2644
- * });
2645
- *
2646
- * // Get Tesla's institutional holders
2647
- * const teslaHolders = await fmp.institutional.getInstitutionalHolders({
2648
- * symbol: 'TSLA'
2649
- * });
2650
- * ```
2651
- *
2652
- * @see {@link https://site.financialmodelingprep.com/developer/docs#institutional-holder-13f---institutional-stock-ownership|FMP Institutional Holders Documentation}
2653
- */
2654
- async getInstitutionalHolders(params) {
2655
- const { symbol } = params;
2656
- return this.client.get(`/institutional-holder/${symbol}`, "v3");
2657
- }
2658
- };
2659
-
2660
- // src/endpoints/insider.ts
2661
- var InsiderEndpoints = class {
2662
- constructor(client) {
2663
- this.client = client;
2664
- }
2665
- /**
2666
- * Get insider trading RSS feed data
2667
- *
2668
- * Provides real-time RSS feed of insider trading activities across all
2669
- * publicly traded companies. Essential for monitoring insider trading
2670
- * patterns, corporate governance, and potential market-moving events.
2671
- *
2672
- * @param params - RSS feed request parameters
2673
- * @param params.page - Page number for pagination (default: 0)
2674
- *
2675
- * @returns Promise resolving to array of insider trading RSS feed data
2676
- *
2677
- * @example
2678
- * ```typescript
2679
- * // Get first page of insider trading RSS feed
2680
- * const rssFeed = await fmp.insider.getInsiderTradingRSS({ page: 0 });
2681
- * rssFeed.data.forEach(trade => {
2682
- * console.log(`${trade.date}: ${trade.symbol} - ${trade.insiderName} ${trade.transactionType}`);
2683
- * });
2684
- *
2685
- * // Get second page of RSS feed
2686
- * const nextPage = await fmp.insider.getInsiderTradingRSS({ page: 1 });
2687
- * ```
2688
- *
2689
- * @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trades-rss-insider-trading|FMP Insider Trading RSS Documentation}
2690
- */
2691
- async getInsiderTradingRSS(params) {
2692
- const { page = 0 } = params;
2693
- return this.client.get(`/insider-trading-rss-feed`, "v4", { page });
2694
- }
2695
- /**
2696
- * Search for insider trades with advanced filtering
2697
- *
2698
- * Provides comprehensive insider trading data with multiple filtering options
2699
- * including symbol, CIK numbers, and transaction types. Essential for detailed
2700
- * analysis of insider trading patterns and corporate governance.
2701
- *
2702
- * @param params - Insider trading search parameters
2703
- * @param params.symbol - Stock symbol to filter by (optional)
2704
- * @param params.reportingCik - Reporting CIK to filter by (optional)
2705
- * @param params.companyCik - Company CIK to filter by (optional)
2706
- * @param params.transactionType - Transaction type to filter by (optional)
2707
- * @param params.page - Page number for pagination (default: 0)
2708
- *
2709
- * @returns Promise resolving to array of insider trading search results
2710
- *
2711
- * @example
2712
- * ```typescript
2713
- * // Search for Apple insider trades
2714
- * const appleTrades = await fmp.insider.searchInsiderTrading({
2715
- * symbol: 'AAPL',
2716
- * page: 0
2717
- * });
2718
- * appleTrades.data.forEach(trade => {
2719
- * console.log(`${trade.date}: ${trade.insiderName} - ${trade.transactionType} ${trade.sharesTraded} shares`);
2720
- * });
2721
- *
2722
- * // Search by transaction type
2723
- * const purchases = await fmp.insider.searchInsiderTrading({
2724
- * transactionType: 'P-Purchase',
2725
- * page: 0
2726
- * });
2727
- *
2728
- * // Search by CIK
2729
- * const cikTrades = await fmp.insider.searchInsiderTrading({
2730
- * companyCik: '0000320193',
2731
- * page: 0
2732
- * });
2733
- * ```
2734
- *
2735
- * @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trades-search-insider-trading|FMP Insider Trading Search Documentation}
2736
- */
2737
- async searchInsiderTrading(params) {
2738
- const { symbol, reportingCik, companyCik, transactionType, page = 0 } = params;
2739
- const queryParams = { page };
2740
- if (symbol) queryParams.symbol = symbol;
2741
- if (reportingCik) queryParams.reportingCik = reportingCik;
2742
- if (companyCik) queryParams.companyCik = companyCik;
2743
- if (transactionType) queryParams.transactionType = transactionType;
2744
- return this.client.get(`/insider-trading`, "v4", queryParams);
2745
- }
2746
- /**
2747
- * Get all available transaction types
2748
- *
2749
- * Provides a comprehensive list of all insider trading transaction types
2750
- * used in SEC filings. Essential for understanding different types of
2751
- * insider trading activities and filtering search results.
2752
- *
2753
- * @returns Promise resolving to array of transaction types with descriptions
2754
- *
2755
- * @example
2756
- * ```typescript
2757
- * // Get all transaction types
2758
- * const transactionTypes = await fmp.insider.getTransactionTypes();
2759
- * transactionTypes.data.forEach(type => {
2760
- * console.log(`${type.code}: ${type.description}`);
2761
- * });
2762
- * ```
2763
- *
2764
- * @see {@link https://site.financialmodelingprep.com/developer/docs#transaction-types-insider-trading|FMP Transaction Types Documentation}
2765
- */
2766
- async getTransactionTypes() {
2767
- return this.client.get(`/insider-trading-transaction-type`, "v4");
2768
- }
2769
- /**
2770
- * Get insiders roster for a specific company
2771
- *
2772
- * Provides a list of all insiders (officers, directors, and beneficial owners)
2773
- * for a specific company. Essential for understanding corporate governance
2774
- * structure and identifying key personnel.
2775
- *
2776
- * @param params - Insiders request parameters
2777
- * @param params.symbol - Stock symbol to get insiders for
2778
- *
2779
- * @returns Promise resolving to array of insiders data for the company
2780
- *
2781
- * @example
2782
- * ```typescript
2783
- * // Get Apple's insiders roster
2784
- * const appleInsiders = await fmp.insider.getInsidersBySymbol({ symbol: 'AAPL' });
2785
- * appleInsiders.data.forEach(insider => {
2786
- * console.log(`${insider.name} - ${insider.title} (${insider.cik})`);
2787
- * });
2788
- *
2789
- * // Get Microsoft's insiders
2790
- * const msftInsiders = await fmp.insider.getInsidersBySymbol({ symbol: 'MSFT' });
2791
- * ```
2792
- *
2793
- * @see {@link https://site.financialmodelingprep.com/developer/docs#insiders-by-symbol-insider-trading|FMP Insiders by Symbol Documentation}
2794
- */
2795
- async getInsidersBySymbol(params) {
2796
- const { symbol } = params;
2797
- return this.client.get(`/insider-roaster`, "v4", { symbol });
2798
- }
2799
- /**
2800
- * Get insider trade statistics for a company
2801
- *
2802
- * Provides comprehensive statistics on insider trading activity for a
2803
- * specific company including total trades, volume, and value metrics.
2804
- * Essential for analyzing insider trading patterns and sentiment.
2805
- *
2806
- * @param params - Statistics request parameters
2807
- * @param params.symbol - Stock symbol to get statistics for
2808
- *
2809
- * @returns Promise resolving to array of insider trade statistics data
2810
- *
2811
- * @example
2812
- * ```typescript
2813
- * // Get Apple's insider trade statistics
2814
- * const appleStats = await fmp.insider.getInsiderTradeStatistics({ symbol: 'AAPL' });
2815
- * appleStats.data.forEach(stat => {
2816
- * console.log(`${stat.insiderName}: ${stat.totalTrades} trades, ${stat.totalShares} shares`);
2817
- * });
2818
- *
2819
- * // Get Microsoft's statistics
2820
- * const msftStats = await fmp.insider.getInsiderTradeStatistics({ symbol: 'MSFT' });
2821
- * ```
2822
- *
2823
- * @see {@link https://site.financialmodelingprep.com/developer/docs#insider-trade-statistics-insider-trading|FMP Insider Trade Statistics Documentation}
2824
- */
2825
- async getInsiderTradeStatistics(params) {
2826
- const { symbol } = params;
2827
- return this.client.get(`/insider-roaster-statistic`, "v4", { symbol });
2828
- }
2829
- /**
2830
- * Get CIK mapper data
2831
- *
2832
- * Provides a mapping between CIK (Central Index Key) numbers and company
2833
- * names. Essential for converting between CIK numbers and company
2834
- * identifiers in insider trading analysis.
2835
- *
2836
- * @param params - CIK mapper request parameters
2837
- * @param params.page - Page number for pagination (default: 0)
2838
- *
2839
- * @returns Promise resolving to array of CIK mapper data
2840
- *
2841
- * @example
2842
- * ```typescript
2843
- * // Get first page of CIK mapper
2844
- * const cikMapper = await fmp.insider.getCikMapper({ page: 0 });
2845
- * cikMapper.data.forEach(mapping => {
2846
- * console.log(`CIK: ${mapping.cik} - Company: ${mapping.name}`);
2847
- * });
2848
- *
2849
- * // Get second page
2850
- * const nextPage = await fmp.insider.getCikMapper({ page: 1 });
2851
- * ```
2852
- *
2853
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-insider-trading|FMP CIK Mapper Documentation}
2854
- */
2855
- async getCikMapper(params) {
2856
- const { page = 0 } = params;
2857
- return this.client.get(`/mapper-cik-name`, "v4", { page });
2858
- }
2859
- /**
2860
- * Get CIK mapper by name search
2861
- *
2862
- * Provides CIK numbers and company names matching a search term.
2863
- * Useful for finding companies by partial name matches and
2864
- * converting company names to CIK numbers.
2865
- *
2866
- * @param params - CIK mapper by name request parameters
2867
- * @param params.name - Company name or partial name to search for
2868
- * @param params.page - Page number for pagination (default: 0)
2869
- *
2870
- * @returns Promise resolving to array of CIK mapper data matching the search
2871
- *
2872
- * @example
2873
- * ```typescript
2874
- * // Search for Apple by name
2875
- * const appleCik = await fmp.insider.getCikMapperByName({
2876
- * name: 'Apple',
2877
- * page: 0
2878
- * });
2879
- * appleCik.data.forEach(mapping => {
2880
- * console.log(`CIK: ${mapping.cik} - Company: ${mapping.name}`);
2881
- * });
2882
- *
2883
- * // Search for Microsoft
2884
- * const msftCik = await fmp.insider.getCikMapperByName({
2885
- * name: 'Microsoft',
2886
- * page: 0
2887
- * });
2888
- * ```
2889
- *
2890
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-by-name-insider-trading|FMP CIK Mapper by Name Documentation}
2891
- */
2892
- async getCikMapperByName(params) {
2893
- const { name, page = 0 } = params;
2894
- return this.client.get(`/mapper-cik-name`, "v4", { name, page });
2895
- }
2896
- /**
2897
- * Get CIK mapper by symbol
2898
- *
2899
- * Provides CIK number and company name for a specific stock symbol.
2900
- * Essential for converting stock symbols to CIK numbers for use
2901
- * in insider trading searches and analysis.
2902
- *
2903
- * @param params - CIK mapper by symbol request parameters
2904
- * @param params.symbol - Stock symbol to get CIK for
2905
- *
2906
- * @returns Promise resolving to CIK mapper data for the symbol
2907
- *
2908
- * @example
2909
- * ```typescript
2910
- * // Get Apple's CIK by symbol
2911
- * const appleCik = await fmp.insider.getCikMapperBySymbol({ symbol: 'AAPL' });
2912
- * console.log(`Apple CIK: ${appleCik.data.cik} - ${appleCik.data.name}`);
2913
- *
2914
- * // Get Microsoft's CIK
2915
- * const msftCik = await fmp.insider.getCikMapperBySymbol({ symbol: 'MSFT' });
2916
- * ```
2917
- *
2918
- * @see {@link https://site.financialmodelingprep.com/developer/docs#cik-mapper-company-insider-trading|FMP CIK Mapper by Symbol Documentation}
2919
- */
2920
- async getCikMapperBySymbol(params) {
2921
- const { symbol } = params;
2922
- return this.client.getSingle(`/mapper-cik-company/${symbol}`, "v4");
2923
- }
2924
- /**
2925
- * Get beneficial ownership acquisitions
2926
- *
2927
- * Provides data on acquisitions of beneficial ownership for a specific
2928
- * company. Essential for tracking significant ownership changes and
2929
- * corporate governance events.
2930
- *
2931
- * @param params - Beneficial ownership request parameters
2932
- * @param params.symbol - Stock symbol to get beneficial ownership data for
2933
- *
2934
- * @returns Promise resolving to array of beneficial ownership acquisition data
2935
- *
2936
- * @example
2937
- * ```typescript
2938
- * // Get Apple's beneficial ownership acquisitions
2939
- * const appleOwnership = await fmp.insider.getBeneficialOwnership({ symbol: 'AAPL' });
2940
- * appleOwnership.data.forEach(acquisition => {
2941
- * console.log(`${acquisition.date}: ${acquisition.insiderName} acquired ${acquisition.sharesAcquired} shares`);
2942
- * });
2943
- *
2944
- * // Get Microsoft's beneficial ownership
2945
- * const msftOwnership = await fmp.insider.getBeneficialOwnership({ symbol: 'MSFT' });
2946
- * ```
2947
- *
2948
- * @see {@link https://site.financialmodelingprep.com/developer/docs#acquisition-of-beneficial-ownership|FMP Beneficial Ownership Documentation}
2949
- */
2950
- async getBeneficialOwnership(params) {
2951
- const { symbol } = params;
2952
- return this.client.get(`/insider/ownership/acquisition_of_beneficial_ownership`, "v4", {
2953
- symbol
2954
- });
2955
- }
2956
- /**
2957
- * Get fail to deliver data
2958
- *
2959
- * Provides fail to deliver data for a specific company, which indicates
2960
- * when market participants fail to deliver securities on settlement date.
2961
- * Important for understanding market mechanics and potential short interest.
2962
- *
2963
- * @param params - Fail to deliver request parameters
2964
- * @param params.symbol - Stock symbol to get fail to deliver data for
2965
- * @param params.page - Page number for pagination (default: 0)
2966
- *
2967
- * @returns Promise resolving to array of fail to deliver data
2968
- *
2969
- * @example
2970
- * ```typescript
2971
- * // Get Apple's fail to deliver data
2972
- * const appleFailToDeliver = await fmp.insider.getFailToDeliver({
2973
- * symbol: 'AAPL',
2974
- * page: 0
2975
- * });
2976
- * appleFailToDeliver.data.forEach(entry => {
2977
- * console.log(`${entry.date}: ${entry.shares} shares failed to deliver`);
2978
- * });
2979
- *
2980
- * // Get Microsoft's fail to deliver data
2981
- * const msftFailToDeliver = await fmp.insider.getFailToDeliver({
2982
- * symbol: 'MSFT',
2983
- * page: 0
2984
- * });
2985
- * ```
2986
- *
2987
- * @see {@link https://site.financialmodelingprep.com/developer/docs#fail-to-deliver|FMP Fail to Deliver Documentation}
2988
- */
2989
- async getFailToDeliver(params) {
2990
- const { symbol, page = 0 } = params;
2991
- return this.client.get(`/fail_to_deliver`, "v4", { symbol, page });
2992
- }
2993
- /**
2994
- * Get all insider trades for a symbol (convenience method)
2995
- * @param symbol - The stock symbol to get insider trades for
2996
- * @param page - Page number for pagination (default: 0)
2997
- * @returns A list of insider trades for the specified symbol
2998
- */
2999
- async getInsiderTradesBySymbol(symbol, page = 0) {
3000
- return this.searchInsiderTrading({ symbol, page });
3001
- }
3002
- /**
3003
- * Get insider trades by transaction type (convenience method)
3004
- * @param transactionType - The transaction type to filter by
3005
- * @param page - Page number for pagination (default: 0)
3006
- * @returns A list of insider trades filtered by transaction type
3007
- */
3008
- async getInsiderTradesByType(transactionType, page = 0) {
3009
- return this.searchInsiderTrading({ transactionType, page });
3010
- }
3011
- /**
3012
- * Get insider trades by reporting CIK (convenience method)
3013
- * @param reportingCik - The reporting CIK to filter by
3014
- * @param page - Page number for pagination (default: 0)
3015
- * @returns A list of insider trades filtered by reporting CIK
3016
- */
3017
- async getInsiderTradesByReportingCik(reportingCik, page = 0) {
3018
- return this.searchInsiderTrading({ reportingCik, page });
3019
- }
3020
- /**
3021
- * Get insider trades by company CIK (convenience method)
3022
- * @param companyCik - The company CIK to filter by
3023
- * @param page - Page number for pagination (default: 0)
3024
- * @returns A list of insider trades filtered by company CIK
3025
- */
3026
- async getInsiderTradesByCompanyCik(companyCik, page = 0) {
3027
- return this.searchInsiderTrading({ companyCik, page });
3028
- }
3029
- };
3030
-
3031
- // src/endpoints/sec.ts
3032
- var SECEndpoints = class {
3033
- constructor(client) {
3034
- this.client = client;
3035
- }
3036
- /**
3037
- * Get RSS feed of SEC filings
3038
- *
3039
- * Provides a real-time feed of SEC filings from publicly traded companies,
3040
- * including filing types, links to SEC pages, and direct links to filings.
3041
- * Essential for staying up-to-date on the latest SEC filings for all companies
3042
- * or for monitoring specific companies' regulatory activities.
3043
- *
3044
- * @param params - RSS feed parameters (optional)
3045
- * @returns Promise resolving to array of RSS feed items with SEC filing information
3046
- *
3047
- * @example
3048
- * ```typescript
3049
- * // Get all recent SEC filings
3050
- * const allFilings = await fmp.sec.getRSSFeed();
3051
- * console.log(`Recent SEC filings: ${allFilings.data.length}`);
3052
- *
3053
- * // Get specific filing type
3054
- * const form4Filings = await fmp.sec.getRSSFeed({ type: '4' });
3055
- * console.log(`Form 4 filings: ${form4Filings.data.length}`);
3056
- *
3057
- * // Get filings with date range
3058
- * const recentFilings = await fmp.sec.getRSSFeed({
3059
- * from: '2024-01-01',
3060
- * to: '2024-01-31'
3061
- * });
3062
- * console.log(`Recent filings: ${recentFilings.data.length}`);
3063
- *
3064
- * // Get limited results
3065
- * const limitedFilings = await fmp.sec.getRSSFeed({ limit: 10 });
3066
- * console.log(`Limited filings: ${limitedFilings.data.length}`);
3067
- * ```
3068
- *
3069
- * @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed Documentation}
3070
- */
3071
- async getRSSFeed(params) {
3072
- return this.client.get("/rss_feed", "v4", params);
3073
- }
3074
- /**
3075
- * Get comprehensive RSS feed of all SEC filings
3076
- *
3077
- * Provides a comprehensive real-time feed of all SEC filings from publicly
3078
- * traded companies in the latest RSS feed format. This endpoint offers the
3079
- * most complete overview of SEC filings with enhanced metadata and formatting.
3080
- *
3081
- * @param params - RSS feed all parameters (optional)
3082
- * @returns Promise resolving to array of comprehensive RSS feed items with enhanced SEC filing information
3083
- *
3084
- * @example
3085
- * ```typescript
3086
- * // Get all comprehensive SEC filings
3087
- * const allFilings = await fmp.sec.getRSSFeedAll();
3088
- * console.log(`Comprehensive SEC filings: ${allFilings.data.length}`);
3089
- *
3090
- * // Get paginated results
3091
- * const page2Filings = await fmp.sec.getRSSFeedAll({ page: 1 });
3092
- * console.log(`Page 2 filings: ${page2Filings.data.length}`);
3093
- *
3094
- * // Get specific data type
3095
- * const specificData = await fmp.sec.getRSSFeedAll({ datatype: 'json' });
3096
- * console.log(`Specific data type filings: ${specificData.data.length}`);
3097
- * ```
3098
- *
3099
- * @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-all-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed All Documentation}
3100
- */
3101
- async getRSSFeedAll(params) {
3102
- return this.client.get("/rss_feed_all", "v4", params);
3103
- }
3104
- /**
3105
- * Get RSS feed V3 of SEC filings
3106
- *
3107
- * Provides a real-time feed of SEC filings from publicly traded companies
3108
- * in the V3 RSS feed format. This version offers enhanced metadata and
3109
- * improved structure for better parsing and analysis of SEC filings.
3110
- *
3111
- * @param params - RSS feed V3 parameters (optional)
3112
- * @returns Promise resolving to array of V3 RSS feed items with enhanced SEC filing information
3113
- *
3114
- * @example
3115
- * ```typescript
3116
- * // Get V3 format SEC filings
3117
- * const v3Filings = await fmp.sec.getRSSFeedV3();
3118
- * console.log(`V3 SEC filings: ${v3Filings.data.length}`);
3119
- *
3120
- * // Get paginated V3 results
3121
- * const page2V3 = await fmp.sec.getRSSFeedV3({ page: 1 });
3122
- * console.log(`Page 2 V3 filings: ${page2V3.data.length}`);
3123
- *
3124
- * // Get specific data type
3125
- * const specificV3 = await fmp.sec.getRSSFeedV3({ datatype: 'json' });
3126
- * console.log(`Specific V3 data type: ${specificV3.data.length}`);
3127
- * ```
3128
- *
3129
- * @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-v3-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed V3 Documentation}
3130
- */
3131
- async getRSSFeedV3(params) {
3132
- return this.client.get("/rss_feed", "v3", params);
3133
- }
3134
- /**
3135
- * Get RSS feed of 8-K SEC filings
3136
- *
3137
- * Provides a real-time feed specifically for 8-K SEC filings from publicly
3138
- * traded companies. 8-K filings are used to announce major events that
3139
- * shareholders should know about, such as earnings releases, mergers,
3140
- * acquisitions, and other material events.
3141
- *
3142
- * @param params - RSS feed 8-K parameters (optional)
3143
- * @returns Promise resolving to array of 8-K RSS feed items with material event information
3144
- *
3145
- * @example
3146
- * ```typescript
3147
- * // Get all 8-K filings
3148
- * const form8KFilings = await fmp.sec.getRSSFeed8K();
3149
- * console.log(`8-K filings: ${form8KFilings.data.length}`);
3150
- *
3151
- * // Get 8-K filings with date range
3152
- * const recent8K = await fmp.sec.getRSSFeed8K({
3153
- * from: '2024-01-01',
3154
- * to: '2024-01-31'
3155
- * });
3156
- * console.log(`Recent 8-K filings: ${recent8K.data.length}`);
3157
- *
3158
- * // Get 8-K filings with financials
3159
- * const financial8K = await fmp.sec.getRSSFeed8K({ hasFinancial: true });
3160
- * console.log(`8-K filings with financials: ${financial8K.data.length}`);
3161
- *
3162
- * // Get limited 8-K results
3163
- * const limited8K = await fmp.sec.getRSSFeed8K({ limit: 10 });
3164
- * console.log(`Limited 8-K filings: ${limited8K.data.length}`);
3165
- * ```
3166
- *
3167
- * @see {@link https://site.financialmodelingprep.com/developer/docs#rss-feed-8-k-securities-and-exchange-commission-(s.e.c)|FMP RSS Feed 8-K Documentation}
3168
- */
3169
- async getRSSFeed8K(params) {
3170
- return this.client.get("/rss_feed_8k", "v4", params);
3171
- }
3172
- /**
3173
- * Get SEC filings for a specific company
3174
- *
3175
- * Provides direct access to SEC filings for a specific company, including
3176
- * filing types, links to SEC pages, and direct links to specific filings.
3177
- * Essential for monitoring a company's regulatory compliance and staying
3178
- * informed about important corporate events and disclosures.
3179
- *
3180
- * @param symbol - The stock symbol to get SEC filings for (e.g., 'AAPL', 'MSFT', 'GOOGL')
3181
- * @param params - SEC filings parameters (optional)
3182
- * @returns Promise resolving to array of SEC filings with detailed filing information
3183
- *
3184
- * @example
3185
- * ```typescript
3186
- * // Get all SEC filings for Apple
3187
- * const appleFilings = await fmp.sec.getSECFilings({ symbol: 'AAPL' });
3188
- * console.log(`Apple SEC filings: ${appleFilings.data.length}`);
3189
- *
3190
- * // Get specific filing type for Microsoft
3191
- * const msftForm4 = await fmp.sec.getSECFilings({
3192
- * symbol: 'MSFT',
3193
- * params: { type: '4' }
3194
- * });
3195
- * console.log(`Microsoft Form 4 filings: ${msftForm4.data.length}`);
3196
- * ```
3197
- *
3198
- * @see {@link https://site.financialmodelingprep.com/developer/docs#sec-filings-securities-and-exchange-commission-(s.e.c)|FMP SEC Filings Documentation}
3199
- */
3200
- async getSECFilings({
3201
- symbol,
3202
- params
3203
- }) {
3204
- return this.client.get(`/sec_filings/${symbol}`, "v3", params);
3205
- }
3206
- /**
3207
- * Get individual industry classification for a company
3208
- *
3209
- * Provides the industry classification for a specific company based on the
3210
- * Standard Industrial Classification (SIC) system. Essential for understanding
3211
- * a company's business sector, industry peers, and market positioning.
3212
- *
3213
- * @param params - Industry classification parameters
3214
- * @returns Promise resolving to industry classification data with SIC code and description
3215
- *
3216
- * @example
3217
- * ```typescript
3218
- * // Get Apple's industry classification by symbol
3219
- * const appleIndustry = await fmp.sec.getIndividualIndustryClassification({ symbol: 'AAPL' });
3220
- * console.log(`Apple Industry: ${appleIndustry.data.industryTitle}`);
3221
- * console.log(`SIC Code: ${appleIndustry.data.sicCode}`);
3222
- *
3223
- * // Get industry classification by CIK
3224
- * const cikIndustry = await fmp.sec.getIndividualIndustryClassification({ cik: 320193 });
3225
- * console.log(`CIK Industry: ${cikIndustry.data.industryTitle}`);
3226
- *
3227
- * // Get industry classification by SIC code
3228
- * const sicIndustry = await fmp.sec.getIndividualIndustryClassification({ sicCode: 3571 });
3229
- * console.log(`SIC Industry: ${sicIndustry.data.industryTitle}`);
3230
- * ```
3231
- *
3232
- * @see {@link https://site.financialmodelingprep.com/developer/docs#individual-industry-classification-standard-industrial-classification|FMP Individual Industry Classification Documentation}
3233
- */
3234
- async getIndividualIndustryClassification(params) {
3235
- return this.client.getSingle("/standard_industrial_classification", "v4", params);
3236
- }
3237
- /**
3238
- * Get all industry classifications
3239
- *
3240
- * Provides a comprehensive overview of all industries classified according
3241
- * to the Standard Industrial Classification (SIC) system. Essential for
3242
- * understanding industry categories, sector analysis, and market research.
3243
- *
3244
- * @returns Promise resolving to array of all industry classifications with SIC codes and descriptions
3245
- *
3246
- * @example
3247
- * ```typescript
3248
- * // Get all industry classifications
3249
- * const allIndustries = await fmp.sec.getAllIndustryClassifications();
3250
- * console.log(`Total industries: ${allIndustries.data.length}`);
3251
- *
3252
- * allIndustries.data.forEach((industry, index) => {
3253
- * console.log(`${index + 1}. ${industry.industryTitle}`);
3254
- * console.log(` SIC Code: ${industry.sicCode}`);
3255
- * });
3256
- *
3257
- * // Find specific industry
3258
- * const techIndustry = allIndustries.data.find(industry =>
3259
- * industry.industryTitle.toLowerCase().includes('computer')
3260
- * );
3261
- * console.log(`Tech Industry: ${techIndustry?.industryTitle}`);
3262
- * ```
3263
- *
3264
- * @see {@link https://site.financialmodelingprep.com/developer/docs#all-industry-classification-standard-industrial-classification|FMP All Industry Classifications Documentation}
3265
- */
3266
- async getAllIndustryClassifications() {
3267
- return this.client.get("/standard_industrial_classification/all", "v4");
3268
- }
3269
- /**
3270
- * Get industry classification codes
3271
- *
3272
- * Provides detailed information about the Standard Industrial Classification
3273
- * (SIC) system and helps identify SIC codes for specific industries.
3274
- * Essential for understanding industry categorization and sector analysis.
3275
- *
3276
- * @param params - Industry classification codes parameters
3277
- * @returns Promise resolving to array of industry classification codes with detailed information
3278
- *
3279
- * @example
3280
- * ```typescript
3281
- * // Get all industry classification codes
3282
- * const allCodes = await fmp.sec.getIndustryClassificationCodes({});
3283
- * console.log(`Total SIC codes: ${allCodes.data.length}`);
3284
- *
3285
- * // Search for specific SIC code
3286
- * const code3571 = await fmp.sec.getIndustryClassificationCodes({ sicCode: 3571 });
3287
- * console.log(`SIC 3571: ${code3571.data[0]?.industryTitle}`);
3288
- *
3289
- * // Search for industry by title
3290
- * const computerIndustry = await fmp.sec.getIndustryClassificationCodes({ industryTitle: 'Computer' });
3291
- * console.log(`Computer-related industries: ${computerIndustry.data.length}`);
3292
- * ```
3293
- *
3294
- * @see {@link https://site.financialmodelingprep.com/developer/docs#industry-classification-codes-standard-industrial-classification|FMP Industry Classification Codes Documentation}
3295
- */
3296
- async getIndustryClassificationCodes(params) {
3297
- return this.client.get("/standard_industrial_classification_list", "v4", params);
3298
- }
3299
- };
3300
-
3301
- // src/endpoints/mutual-fund.ts
3302
- var MutualFundEndpoints = class {
3303
- constructor(client) {
3304
- this.client = client;
3305
- }
3306
- /**
3307
- * Get mutual fund holders of a specific stock
3308
- *
3309
- * Provides data on mutual funds that hold shares in a specific stock.
3310
- * Essential for understanding mutual fund ownership patterns and
3311
- * which mutual funds are invested in particular companies.
3312
- *
3313
- * @param symbol - The stock symbol to get mutual fund holders for (e.g., 'AAPL', 'MSFT', 'GOOGL')
3314
- *
3315
- * @returns Promise resolving to array of mutual fund holders with position details
3316
- *
3317
- * @example
3318
- * ```typescript
3319
- * // Get mutual funds that hold Apple stock
3320
- * const appleHolders = await fmp.mutualFund.getHolders('AAPL');
3321
- * console.log(`${appleHolders.data.length} mutual funds hold AAPL`);
3322
- *
3323
- * appleHolders.data.forEach((holder, index) => {
3324
- * console.log(`${index + 1}. ${holder.holder}`);
3325
- * console.log(` Shares: ${holder.shares?.toLocaleString() || 'N/A'}`);
3326
- * console.log(` Weight: ${holder.weightPercent}% | Change: ${holder.change}`);
3327
- * });
3328
- *
3329
- * // Get mutual funds that hold Microsoft stock
3330
- * const msftHolders = await fmp.mutualFund.getHolders('MSFT');
3331
- *
3332
- * // Find top mutual fund holders by shares
3333
- * const topHolders = msftHolders.data
3334
- * .sort((a, b) => (b.shares || 0) - (a.shares || 0))
3335
- * .slice(0, 10);
3336
- * console.log('Top 10 mutual fund holders by shares:');
3337
- * topHolders.forEach((holder, index) => {
3338
- * console.log(`${index + 1}. ${holder.holder}: ${holder.shares.toLocaleString()} shares`);
3339
- * });
3340
- *
3341
- * // Get mutual funds that hold Google stock
3342
- * const googlHolders = await fmp.mutualFund.getHolders('GOOGL');
3343
- *
3344
- * // Analyze mutual fund concentration
3345
- * const totalShares = googlHolders.data.reduce((sum, holder) => sum + (holder.shares || 0), 0);
3346
- * console.log(`Total shares held by mutual funds: ${totalShares.toLocaleString()}`);
3347
- *
3348
- * googlHolders.data.forEach(holder => {
3349
- * const percentage = ((holder.shares || 0) / totalShares * 100).toFixed(2);
3350
- * console.log(`${holder.holder}: ${percentage}% of total mutual fund holdings`);
3351
- * });
3352
- * ```
3353
- *
3354
- * @see {@link https://site.financialmodelingprep.com/developer/docs#mutual-fund-holder-mutual-funds-holdings|FMP Mutual Fund Holders Documentation}
3355
- */
3356
- async getHolders(symbol) {
3357
- return this.client.get(`/mutual-fund-holder/${symbol}`, "v3");
3358
- }
3359
- };
3360
-
3361
- // src/fmp.ts
3362
- var FMP = class {
3363
- constructor(config = {}) {
3364
- const apiKey = config.apiKey || process.env.FMP_API_KEY;
3365
- if (!apiKey) {
3366
- throw new Error(
3367
- "FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable."
3368
- );
3369
- }
3370
- if (!FMPValidation.isValidApiKey(apiKey)) {
3371
- throw new Error("Invalid API key format");
3372
- }
3373
- const client = new FMPClient({ ...config, apiKey });
3374
- this.stock = new StockEndpoints(client);
3375
- this.financial = new FinancialEndpoints(client);
3376
- this.etf = new ETFEndpoints(client);
3377
- this.economic = new EconomicEndpoints(client);
3378
- this.market = new MarketEndpoints(client);
3379
- this.list = new ListEndpoints(client);
3380
- this.calendar = new CalendarEndpoints(client);
3381
- this.company = new CompanyEndpoints(client);
3382
- this.quote = new QuoteEndpoints(client);
3383
- this.senateHouse = new SenateHouseEndpoints(client);
3384
- this.institutional = new InstitutionalEndpoints(client);
3385
- this.insider = new InsiderEndpoints(client);
3386
- this.sec = new SECEndpoints(client);
3387
- this.mutualFund = new MutualFundEndpoints(client);
3388
- }
3389
- /**
3390
- * Get the underlying client instance for advanced usage
3391
- */
3392
- getClient() {
3393
- return this.stock["client"];
3394
- }
3395
- };
3396
-
3397
- // src/types/common.ts
3398
- var Period = /* @__PURE__ */ ((Period2) => {
3399
- Period2["ANNUAL"] = "annual";
3400
- Period2["QUARTER"] = "quarter";
3401
- return Period2;
3402
- })(Period || {});
3403
- var Exchange = /* @__PURE__ */ ((Exchange2) => {
3404
- Exchange2["NYSE"] = "NYSE";
3405
- Exchange2["NASDAQ"] = "NASDAQ";
3406
- Exchange2["AMEX"] = "AMEX";
3407
- Exchange2["TSX"] = "TSX";
3408
- Exchange2["LSE"] = "LSE";
3409
- Exchange2["ASX"] = "ASX";
3410
- Exchange2["NSE"] = "NSE";
3411
- Exchange2["BSE"] = "BSE";
3412
- return Exchange2;
3413
- })(Exchange || {});
3414
-
3415
- // src/types/insider.ts
3416
- var TransactionType = /* @__PURE__ */ ((TransactionType2) => {
3417
- TransactionType2["AWARD"] = "A-Award";
3418
- TransactionType2["CONVERSION"] = "C-Conversion";
3419
- TransactionType2["RETURN"] = "D-Return";
3420
- TransactionType2["EXPIRE_SHORT"] = "E-ExpireShort";
3421
- TransactionType2["IN_KIND"] = "F-InKind";
3422
- TransactionType2["GIFT"] = "G-Gift";
3423
- TransactionType2["EXPIRE_LONG"] = "H-ExpireLong";
3424
- TransactionType2["DISCRETIONARY"] = "I-Discretionary";
3425
- TransactionType2["OTHER"] = "J-Other";
3426
- TransactionType2["SMALL"] = "L-Small";
3427
- TransactionType2["EXEMPT"] = "M-Exempt";
3428
- TransactionType2["OUT_OF_THE_MONEY"] = "O-OutOfTheMoney";
3429
- TransactionType2["PURCHASE"] = "P-Purchase";
3430
- TransactionType2["SALE"] = "S-Sale";
3431
- TransactionType2["TENDER"] = "U-Tender";
3432
- TransactionType2["WILL"] = "W-Will";
3433
- TransactionType2["IN_THE_MONEY"] = "X-InTheMoney";
3434
- TransactionType2["TRUST"] = "Z-Trust";
3435
- return TransactionType2;
3436
- })(TransactionType || {});
3437
-
3438
- // src/utils/constants.ts
3439
- var DEFAULT_TIMEOUT = 1e4;
3440
- var DEFAULT_LIMIT = 100;
3441
- var MAX_LIMIT = 1e3;
3442
- var PERIODS = {
3443
- ANNUAL: "annual",
3444
- QUARTER: "quarter"
3445
- };
3446
- var EXCHANGES = {
3447
- NYSE: "NYSE",
3448
- NASDAQ: "NASDAQ",
3449
- AMEX: "AMEX",
3450
- TSX: "TSX",
3451
- LSE: "LSE",
3452
- ASX: "ASX",
3453
- NSE: "NSE",
3454
- BSE: "BSE"
3455
- };
3456
- var SECTORS = {
3457
- TECHNOLOGY: "Technology",
3458
- HEALTHCARE: "Healthcare",
3459
- FINANCIAL: "Financial",
3460
- CONSUMER_DISCRETIONARY: "Consumer Discretionary",
3461
- CONSUMER_STAPLES: "Consumer Staples",
3462
- INDUSTRIALS: "Industrials",
3463
- ENERGY: "Energy",
3464
- MATERIALS: "Materials",
3465
- UTILITIES: "Utilities",
3466
- REAL_ESTATE: "Real Estate",
3467
- COMMUNICATION_SERVICES: "Communication Services"
3468
- };
3469
- var COUNTRIES = {
3470
- US: "US",
3471
- CA: "CA",
3472
- GB: "GB",
3473
- AU: "AU",
3474
- IN: "IN",
3475
- DE: "DE",
3476
- FR: "FR",
3477
- JP: "JP",
3478
- CN: "CN",
3479
- BR: "BR"
3480
- };
3481
- var ERROR_MESSAGES = {
3482
- API_KEY_REQUIRED: "API key is required",
3483
- SYMBOL_REQUIRED: "Symbol is required",
3484
- INVALID_SYMBOL: "Invalid symbol format",
3485
- INVALID_DATE: "Invalid date format. Use YYYY-MM-DD",
3486
- INVALID_PERIOD: 'Period must be either "annual" or "quarter"',
3487
- INVALID_LIMIT: "Limit must be between 1 and 1000",
3488
- INVALID_PAGE: "Page must be a non-negative number",
3489
- REQUEST_FAILED: "Request failed",
3490
- RATE_LIMIT_EXCEEDED: "Rate limit exceeded",
3491
- UNAUTHORIZED: "Unauthorized - Invalid API key",
3492
- NOT_FOUND: "Resource not found"
3493
- };
3494
- var HTTP_STATUS = {
3495
- OK: 200,
3496
- CREATED: 201,
3497
- BAD_REQUEST: 400,
3498
- UNAUTHORIZED: 401,
3499
- FORBIDDEN: 403,
3500
- NOT_FOUND: 404,
3501
- TOO_MANY_REQUESTS: 429,
3502
- INTERNAL_SERVER_ERROR: 500
3503
- };
3504
-
3505
- // src/utils/formatting.ts
3506
- function formatCurrency(value, currency = "USD") {
3507
- return new Intl.NumberFormat("en-US", {
3508
- style: "currency",
3509
- currency
3510
- }).format(value);
3511
- }
3512
- function formatPercentage(value, decimals = 2) {
3513
- return `${value.toFixed(decimals)}%`;
3514
- }
3515
- function formatLargeNumber(value) {
3516
- if (value >= 1e12) {
3517
- return `${(value / 1e12).toFixed(2)}T`;
3518
- } else if (value >= 1e9) {
3519
- return `${(value / 1e9).toFixed(2)}B`;
3520
- } else if (value >= 1e6) {
3521
- return `${(value / 1e6).toFixed(2)}M`;
3522
- } else if (value >= 1e3) {
3523
- return `${(value / 1e3).toFixed(2)}K`;
3524
- }
3525
- return value.toString();
3526
- }
3527
- function formatDate(date) {
3528
- const d = typeof date === "string" ? new Date(date) : date;
3529
- return d.toISOString().split("T")[0];
3530
- }
3531
- function formatReadableDate(date) {
3532
- const d = typeof date === "string" ? new Date(date) : date;
3533
- return d.toLocaleDateString("en-US", {
3534
- year: "numeric",
3535
- month: "long",
3536
- day: "numeric"
3537
- });
3538
- }
3539
- function formatTimestamp(timestamp) {
3540
- const date = new Date(timestamp * 1e3);
3541
- return date.toLocaleString("en-US");
3542
- }
3543
- function formatNumber(value, decimals = 2) {
3544
- return value.toFixed(decimals);
3545
- }
3546
- function formatVolume(volume) {
3547
- if (volume >= 1e9) {
3548
- return `${(volume / 1e9).toFixed(2)}B`;
3549
- } else if (volume >= 1e6) {
3550
- return `${(volume / 1e6).toFixed(2)}M`;
3551
- } else if (volume >= 1e3) {
3552
- return `${(volume / 1e3).toFixed(2)}K`;
3553
- }
3554
- return volume.toString();
3555
- }
3556
-
3557
- // src/utils/helpers.ts
3558
- var FMPHelpers = class {
3559
- /**
3560
- * Get all available endpoint categories from the FMP client
3561
- * @param fmp - The FMP client instance
3562
- * @returns Array of endpoint category names
3563
- */
3564
- static getEndpointCategories(fmp) {
3565
- return Object.keys(fmp).filter(
3566
- (key) => typeof fmp[key] === "object" && fmp[key] !== null && key !== "constructor"
3567
- );
3568
- }
3569
- /**
3570
- * Get all methods for a specific endpoint category
3571
- * @param fmp - The FMP client instance
3572
- * @param endpoint - The endpoint category name
3573
- * @returns Array of method names
3574
- */
3575
- static getEndpointMethods(fmp, endpoint) {
3576
- const endpointObj = fmp[endpoint];
3577
- if (!endpointObj || typeof endpointObj !== "object") {
3578
- return [];
3579
- }
3580
- return Object.getOwnPropertyNames(endpointObj).filter(
3581
- (name) => typeof endpointObj[name] === "function" && name !== "constructor"
3582
- );
3583
- }
3584
- /**
3585
- * Get all available methods across all endpoint categories
3586
- * @param fmp - The FMP client instance
3587
- * @returns Object mapping endpoint categories to their methods
3588
- */
3589
- static getAllMethods(fmp) {
3590
- const methods = {};
3591
- const categories = this.getEndpointCategories(fmp);
3592
- categories.forEach((category) => {
3593
- methods[category] = this.getEndpointMethods(fmp, category);
3594
- });
3595
- return methods;
3596
- }
3597
- /**
3598
- * Get a summary of the API structure
3599
- * @param fmp - The FMP client instance
3600
- * @returns Summary object with endpoint and method counts
3601
- */
3602
- static getApiSummary(fmp) {
3603
- const categories = this.getEndpointCategories(fmp);
3604
- const allMethods = this.getAllMethods(fmp);
3605
- const totalMethods = Object.values(allMethods).reduce(
3606
- (sum, methods) => sum + methods.length,
3607
- 0
3608
- );
3609
- const methodCounts = {};
3610
- categories.forEach((category) => {
3611
- methodCounts[category] = allMethods[category]?.length || 0;
3612
- });
3613
- return {
3614
- totalEndpoints: categories.length,
3615
- totalMethods,
3616
- categories,
3617
- methodCounts
3618
- };
3619
- }
3620
- /**
3621
- * Check if a specific method exists on an endpoint
3622
- * @param fmp - The FMP client instance
3623
- * @param endpoint - The endpoint category name
3624
- * @param method - The method name
3625
- * @returns True if the method exists
3626
- */
3627
- static hasMethod(fmp, endpoint, method) {
3628
- const methods = this.getEndpointMethods(fmp, endpoint);
3629
- return methods.includes(method);
3630
- }
3631
- /**
3632
- * Get method signature information (basic introspection)
3633
- * @param fmp - The FMP client instance
3634
- * @param endpoint - The endpoint category name
3635
- * @param method - The method name
3636
- * @returns Method information or null if not found
3637
- */
3638
- static getMethodInfo(fmp, endpoint, method) {
3639
- const endpointObj = fmp[endpoint];
3640
- if (!endpointObj || typeof endpointObj !== "object") {
3641
- return null;
3642
- }
3643
- const methodFn = endpointObj[method];
3644
- if (typeof methodFn !== "function") {
3645
- return null;
3646
- }
3647
- return {
3648
- name: method,
3649
- type: "function",
3650
- async: methodFn.constructor.name === "AsyncFunction"
3651
- };
3652
- }
3653
- };
3654
-
3655
- // src/utils/utils.ts
3656
- var FMPUtils = class {
3657
- /**
3658
- * Format currency values
3659
- * @param value - The numeric value to format
3660
- * @param currency - The currency code (default: USD)
3661
- * @param locale - The locale for formatting (default: en-US)
3662
- * @returns Formatted currency string
3663
- */
3664
- static formatCurrency(value, currency = "USD", locale = "en-US") {
3665
- if (typeof value !== "number" || isNaN(value)) {
3666
- return "N/A";
3667
- }
3668
- try {
3669
- return new Intl.NumberFormat(locale, {
3670
- style: "currency",
3671
- currency,
3672
- minimumFractionDigits: 2,
3673
- maximumFractionDigits: 2
3674
- }).format(value);
3675
- } catch (error) {
3676
- return `${currency} ${value.toFixed(2)}`;
3677
- }
3678
- }
3679
- /**
3680
- * Format percentages
3681
- * @param value - The percentage value (as decimal, e.g., 0.15 for 15%)
3682
- * @param decimals - Number of decimal places (default: 2)
3683
- * @returns Formatted percentage string
3684
- */
3685
- static formatPercentage(value, decimals = 2) {
3686
- if (typeof value !== "number" || isNaN(value)) {
3687
- return "N/A";
3688
- }
3689
- return `${value.toFixed(decimals)}%`;
3690
- }
3691
- /**
3692
- * Format large numbers with abbreviations (K, M, B, T)
3693
- * @param value - The numeric value to format
3694
- * @param decimals - Number of decimal places (default: 1)
3695
- * @returns Formatted number string
3696
- */
3697
- static formatLargeNumber(value, decimals = 1) {
3698
- if (typeof value !== "number" || isNaN(value)) {
3699
- return "N/A";
3700
- }
3701
- const absValue = Math.abs(value);
3702
- const sign = value < 0 ? "-" : "";
3703
- if (absValue >= 1e12) {
3704
- return `${sign}${(absValue / 1e12).toFixed(decimals)}T`;
3705
- } else if (absValue >= 1e9) {
3706
- return `${sign}${(absValue / 1e9).toFixed(decimals)}B`;
3707
- } else if (absValue >= 1e6) {
3708
- return `${sign}${(absValue / 1e6).toFixed(decimals)}M`;
3709
- } else if (absValue >= 1e3) {
3710
- return `${sign}${(absValue / 1e3).toFixed(decimals)}K`;
3711
- } else {
3712
- return `${sign}${absValue.toFixed(decimals)}`;
3713
- }
3714
- }
3715
- /**
3716
- * Convert date string to Date object
3717
- * @param dateString - The date string in YYYY-MM-DD format
3718
- * @returns Date object or null if invalid
3719
- */
3720
- static parseDate(dateString) {
3721
- if (!dateString || typeof dateString !== "string") {
3722
- return null;
3723
- }
3724
- const [year, month, day] = dateString.split("-").map(Number);
3725
- if (isNaN(year) || isNaN(month) || isNaN(day)) {
3726
- return null;
3727
- }
3728
- if (month < 1 || month > 12) {
3729
- return null;
3730
- }
3731
- const date = new Date(Date.UTC(year, month - 1, day));
3732
- if (isNaN(date.getTime())) {
3733
- return null;
3734
- }
3735
- const parsedYear = date.getUTCFullYear();
3736
- const parsedMonth = date.getUTCMonth() + 1;
3737
- const parsedDay = date.getUTCDate();
3738
- if (parsedYear !== year || parsedMonth !== month || parsedDay !== day) {
3739
- return null;
3740
- }
3741
- return date;
3742
- }
3743
- /**
3744
- * Format date to readable string
3745
- * @param date - Date object or date string
3746
- * @param format - Format style ('short', 'long', 'iso')
3747
- * @returns Formatted date string
3748
- */
3749
- static formatDate(date, format = "short") {
3750
- const dateObj = typeof date === "string" ? this.parseDate(date) : date;
3751
- if (!dateObj) {
3752
- return "Invalid Date";
3753
- }
3754
- switch (format) {
3755
- case "long":
3756
- return dateObj.toLocaleDateString("en-US", {
3757
- weekday: "long",
3758
- year: "numeric",
3759
- month: "long",
3760
- day: "numeric"
3761
- });
3762
- case "iso":
3763
- return dateObj.toISOString().split("T")[0];
3764
- case "short":
3765
- default:
3766
- return dateObj.toLocaleDateString("en-US", {
3767
- year: "numeric",
3768
- month: "short",
3769
- day: "numeric"
3770
- });
3771
- }
3772
- }
3773
- /**
3774
- * Calculate working days between two dates (excluding weekends)
3775
- * @param from - Start date
3776
- * @param to - End date
3777
- * @returns Number of working days
3778
- */
3779
- static getWorkingDays(from, to) {
3780
- const startDate = typeof from === "string" ? this.parseDate(from) : from;
3781
- const endDate = typeof to === "string" ? this.parseDate(to) : to;
3782
- if (!startDate || !endDate) {
3783
- return 0;
3784
- }
3785
- let workingDays = 0;
3786
- const currentDate = new Date(startDate);
3787
- const endDateNormalized = new Date(
3788
- Date.UTC(endDate.getUTCFullYear(), endDate.getUTCMonth(), endDate.getUTCDate())
3789
- );
3790
- while (currentDate <= endDateNormalized) {
3791
- const dayOfWeek = currentDate.getUTCDay();
3792
- if (dayOfWeek !== 0 && dayOfWeek !== 6) {
3793
- workingDays++;
3794
- }
3795
- currentDate.setUTCDate(currentDate.getUTCDate() + 1);
3796
- }
3797
- return workingDays;
3798
- }
3799
- /**
3800
- * Calculate percentage change between two values
3801
- * @param oldValue - The original value
3802
- * @param newValue - The new value
3803
- * @param decimals - Number of decimal places (default: 2)
3804
- * @returns Percentage change as a number
3805
- */
3806
- static calculatePercentageChange(oldValue, newValue, decimals = 2) {
3807
- if (typeof oldValue !== "number" || typeof newValue !== "number" || isNaN(oldValue) || isNaN(newValue) || oldValue === 0) {
3808
- return 0;
3809
- }
3810
- const change = (newValue - oldValue) / oldValue * 100;
3811
- return Number(change.toFixed(decimals));
3812
- }
3813
- /**
3814
- * Batch API calls with rate limiting
3815
- * @param calls - Array of async functions to execute
3816
- * @param delayMs - Delay between calls in milliseconds (default: 100)
3817
- * @param maxConcurrent - Maximum concurrent calls (default: 1)
3818
- * @returns Array of results
3819
- */
3820
- static async batchCalls(calls, delayMs = 100, maxConcurrent = 1) {
3821
- const results = [];
3822
- if (maxConcurrent === 1) {
3823
- for (const call of calls) {
3824
- results.push(await call());
3825
- if (delayMs > 0) {
3826
- await new Promise((resolve) => setTimeout(resolve, delayMs));
3827
- }
3828
- }
3829
- } else {
3830
- const chunks = this.chunkArray(calls, maxConcurrent);
3831
- for (const chunk of chunks) {
3832
- const chunkResults = await Promise.all(chunk.map((call) => call()));
3833
- results.push(...chunkResults);
3834
- if (delayMs > 0) {
3835
- await new Promise((resolve) => setTimeout(resolve, delayMs));
3836
- }
3837
- }
3838
- }
3839
- return results;
3840
- }
3841
- /**
3842
- * Split array into chunks
3843
- * @param array - The array to split
3844
- * @param chunkSize - Size of each chunk
3845
- * @returns Array of chunks
3846
- */
3847
- static chunkArray(array, chunkSize) {
3848
- const chunks = [];
3849
- for (let i = 0; i < array.length; i += chunkSize) {
3850
- chunks.push(array.slice(i, i + chunkSize));
3851
- }
3852
- return chunks;
3853
- }
3854
- /**
3855
- * Retry a function with exponential backoff
3856
- * @param fn - The function to retry
3857
- * @param maxRetries - Maximum number of retries (default: 3)
3858
- * @param baseDelay - Base delay in milliseconds (default: 1000)
3859
- * @returns Function result
3860
- */
3861
- static async retryWithBackoff(fn, maxRetries = 3, baseDelay = 1e3) {
3862
- let lastError;
3863
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
3864
- try {
3865
- return await fn();
3866
- } catch (error) {
3867
- lastError = error;
3868
- if (attempt === maxRetries) {
3869
- throw lastError;
3870
- }
3871
- const delay = baseDelay * Math.pow(2, attempt);
3872
- await new Promise((resolve) => setTimeout(resolve, delay));
3873
- }
3874
- }
3875
- throw lastError;
3876
- }
3877
- /**
3878
- * Debounce a function
3879
- * @param func - The function to debounce
3880
- * @param wait - Wait time in milliseconds
3881
- * @returns Debounced function
3882
- */
3883
- static debounce(func, wait) {
3884
- let timeout;
3885
- return (...args) => {
3886
- clearTimeout(timeout);
3887
- timeout = setTimeout(() => func(...args), wait);
3888
- };
3889
- }
3890
- /**
3891
- * Throttle a function
3892
- * @param func - The function to throttle
3893
- * @param limit - Time limit in milliseconds
3894
- * @returns Throttled function
3895
- */
3896
- static throttle(func, limit) {
3897
- let inThrottle;
3898
- return (...args) => {
3899
- if (!inThrottle) {
3900
- func(...args);
3901
- inThrottle = true;
3902
- setTimeout(() => inThrottle = false, limit);
3903
- }
3904
- };
3905
- }
3906
- };
3907
-
3908
- // src/utils/debug.ts
3909
- var _FMPDebug = class _FMPDebug {
3910
- /**
3911
- * Log API calls for debugging (only in development)
3912
- * @param endpoint - The endpoint being called
3913
- * @param params - The parameters passed to the endpoint
3914
- * @param response - The response received
3915
- * @param duration - The duration of the call in milliseconds
3916
- */
3917
- static logApiCall(endpoint, params, response, duration) {
3918
- if (!this.isDevelopment && !this.isDebugEnabled) {
3919
- return;
3920
- }
3921
- const logData = {
3922
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3923
- endpoint,
3924
- params,
3925
- success: response?.success,
3926
- status: response?.status,
3927
- duration: duration ? `${duration}ms` : void 0
3928
- };
3929
- console.log("\u{1F50D} FMP API Call:", logData);
3930
- }
3931
- /**
3932
- * Log API errors for debugging
3933
- * @param endpoint - The endpoint that failed
3934
- * @param params - The parameters that were passed
3935
- * @param error - The error that occurred
3936
- */
3937
- static logApiError(endpoint, params, error) {
3938
- if (!this.isDevelopment && !this.isDebugEnabled) {
3939
- return;
3940
- }
3941
- console.error("\u274C FMP API Error:", {
3942
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3943
- endpoint,
3944
- params,
3945
- error: error?.message || error,
3946
- stack: error?.stack
3947
- });
3948
- }
3949
- /**
3950
- * Get comprehensive API usage statistics
3951
- * @param fmp - The FMP client instance
3952
- * @returns Detailed API statistics
3953
- */
3954
- static getApiStats(fmp) {
3955
- const summary = FMPHelpers.getApiSummary(fmp);
3956
- const estimatedApiCalls = Object.values(summary.methodCounts).reduce(
3957
- (total, count) => total + count * 2,
3958
- // Assume 2 calls per method on average
3959
- 0
3960
- );
3961
- return {
3962
- ...summary,
3963
- estimatedApiCalls
3964
- };
3965
- }
3966
- /**
3967
- * Validate API key format and provide feedback
3968
- * @param apiKey - The API key to validate
3969
- * @returns Validation result with details
3970
- */
3971
- static validateApiKey(apiKey) {
3972
- const length = apiKey?.length || 0;
3973
- const format = apiKey?.match(/^[a-zA-Z0-9]+$/) ? "alphanumeric" : "invalid";
3974
- const isValid = length >= 32 && format === "alphanumeric";
3975
- const suggestions = [];
3976
- if (length < 32) {
3977
- suggestions.push("API key should be at least 32 characters long");
3978
- }
3979
- if (format !== "alphanumeric") {
3980
- suggestions.push("API key should contain only letters and numbers");
3981
- }
3982
- if (!apiKey) {
3983
- suggestions.push("API key is required");
3984
- }
3985
- return {
3986
- isValid,
3987
- length,
3988
- format,
3989
- suggestions
3990
- };
3991
- }
3992
- /**
3993
- * Check API key environment variable
3994
- * @returns Environment check result
3995
- */
3996
- static checkApiKeyEnvironment() {
3997
- const envVarName = "FMP_API_KEY";
3998
- const apiKey = process.env[envVarName];
3999
- const hasEnvVar = !!apiKey;
4000
- const validation = this.validateApiKey(apiKey || "");
4001
- const suggestions = [];
4002
- if (!hasEnvVar) {
4003
- suggestions.push(`Set ${envVarName} environment variable`);
4004
- suggestions.push("Add to your .env file: FMP_API_KEY=your_api_key_here");
4005
- } else if (!validation.isValid) {
4006
- suggestions.push(...validation.suggestions);
4007
- }
4008
- return {
4009
- hasEnvVar,
4010
- envVarName,
4011
- isValid: validation.isValid,
4012
- suggestions
4013
- };
4014
- }
4015
- /**
4016
- * Get performance metrics for API calls
4017
- * @param fmp - The FMP client instance
4018
- * @returns Performance information
4019
- */
4020
- static getPerformanceInfo() {
4021
- return {
4022
- nodeVersion: process.version,
4023
- platform: process.platform,
4024
- memoryUsage: process.memoryUsage(),
4025
- uptime: process.uptime()
4026
- };
4027
- }
4028
- /**
4029
- * Create a debug configuration object
4030
- * @param fmp - The FMP client instance
4031
- * @returns Debug configuration
4032
- */
4033
- static createDebugConfig(fmp) {
4034
- return {
4035
- apiStats: this.getApiStats(fmp),
4036
- envCheck: this.checkApiKeyEnvironment(),
4037
- performance: this.getPerformanceInfo(),
4038
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
4039
- };
4040
- }
4041
- /**
4042
- * Print debug information to console
4043
- * @param fmp - The FMP client instance
4044
- */
4045
- static printDebugInfo(fmp) {
4046
- if (!this.isDevelopment && !this.isDebugEnabled) {
4047
- return;
4048
- }
4049
- const config = this.createDebugConfig(fmp);
4050
- console.log("\u{1F527} FMP Debug Information:");
4051
- console.log("\u{1F4CA} API Stats:", config.apiStats);
4052
- console.log("\u{1F511} Environment Check:", config.envCheck);
4053
- console.log("\u26A1 Performance:", config.performance);
4054
- console.log("\u{1F552} Timestamp:", config.timestamp);
4055
- }
4056
- /**
4057
- * Enable debug mode programmatically
4058
- */
4059
- static enableDebugMode() {
4060
- process.env.FMP_DEBUG = "true";
4061
- this.isDebugEnabled = true;
4062
- console.log("\u{1F527} FMP Debug mode enabled");
4063
- }
4064
- /**
4065
- * Disable debug mode programmatically
4066
- */
4067
- static disableDebugMode() {
4068
- process.env.FMP_DEBUG = "false";
4069
- this.isDebugEnabled = false;
4070
- console.log("\u{1F527} FMP Debug mode disabled");
4071
- }
4072
- /**
4073
- * Check if debug mode is enabled
4074
- * @returns True if debug mode is enabled
4075
- */
4076
- static isDebugMode() {
4077
- return this.isDevelopment || this.isDebugEnabled;
4078
- }
4079
- /**
4080
- * Create a debug wrapper for API calls
4081
- * @param fmp - The FMP client instance
4082
- * @returns FMP client with debug logging
4083
- */
4084
- static createDebugWrapper(fmp) {
4085
- if (!this.isDebugMode()) {
4086
- return fmp;
4087
- }
4088
- return new Proxy(fmp, {
4089
- get(target, prop) {
4090
- const value = target[prop];
4091
- if (typeof value === "object" && value !== null) {
4092
- return new Proxy(value, {
4093
- get(endpointTarget, methodName) {
4094
- const method = endpointTarget[methodName];
4095
- if (typeof method === "function") {
4096
- return async (...args) => {
4097
- const startTime = Date.now();
4098
- const endpoint = `${String(prop)}.${String(methodName)}`;
4099
- let params;
4100
- if (methodName === "getQuote" && args.length === 1 && typeof args[0] === "string") {
4101
- params = { symbol: args[0] };
4102
- } else if (args.length === 1 && typeof args[0] === "object" && args[0] !== null) {
4103
- params = args[0];
4104
- } else {
4105
- params = args;
4106
- }
4107
- try {
4108
- _FMPDebug.logApiCall(endpoint, params, null);
4109
- const result = await method.apply(
4110
- endpointTarget,
4111
- args
4112
- );
4113
- const duration = Date.now() - startTime;
4114
- _FMPDebug.logApiCall(endpoint, params, result, duration);
4115
- return result;
4116
- } catch (error) {
4117
- _FMPDebug.logApiError(endpoint, params, error);
4118
- throw error;
4119
- }
4120
- };
4121
- }
4122
- return method;
4123
- }
4124
- });
4125
- }
4126
- return value;
4127
- }
4128
- });
4129
- }
4130
- };
4131
- _FMPDebug.isDevelopment = process.env.NODE_ENV === "development";
4132
- _FMPDebug.isDebugEnabled = process.env.FMP_DEBUG === "true";
4133
- var FMPDebug = _FMPDebug;
4134
-
4135
- export { COUNTRIES, CalendarEndpoints, CompanyEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient, FMPDebug, FMPHelpers, FMPUtils, FMPValidation, FinancialEndpoints, HTTP_STATUS, InsiderEndpoints, InstitutionalEndpoints, ListEndpoints, MAX_LIMIT, MarketEndpoints, MutualFundEndpoints, PERIODS, Period, QuoteEndpoints, SECEndpoints, SECTORS, SenateHouseEndpoints, StockEndpoints, TransactionType, formatCurrency, formatDate, formatLargeNumber, formatNumber, formatPercentage, formatReadableDate, formatTimestamp, formatVolume };
4136
- //# sourceMappingURL=index.mjs.map
4137
- //# sourceMappingURL=index.mjs.map
1
+ import {a}from'./chunk-RM7ETDL3.mjs';export{a as FMPValidation}from'./chunk-RM7ETDL3.mjs';import E from'axios';function b(i){return Array.isArray(i)&&i.length===1?i[0]:i}function F(i){return Array.isArray(i)?i:i??[]}function v(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=E.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=E.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=E.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=F(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:v(b(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{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 m=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 p=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 u=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 d=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 f=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 P=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 R=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 h=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 S=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 A=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(!a.isValidApiKey(t))throw new Error("Invalid API key format");let r=new l({...e,apiKey:t});this.stock=new c(r),this.financial=new m(r),this.etf=new p(r),this.economic=new g(r),this.market=new u(r),this.list=new d(r),this.calendar=new y(r),this.company=new f(r),this.quote=new P(r),this.senateHouse=new R(r),this.institutional=new I(r),this.insider=new h(r),this.sec=new S(r),this.mutualFund=new A(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 x(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 D(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,H=1e3,$={ANNUAL:"annual",QUARTER:"quarter"},N={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},U={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
+ export{y as CalendarEndpoints,f as CompanyEndpoints,_ as DEFAULT_LIMIT,L as DEFAULT_TIMEOUT,p as ETFEndpoints,N as EXCHANGES,g as EconomicEndpoints,T as FMP,l as FMPClient,m as FinancialEndpoints,h as InsiderEndpoints,I as InstitutionalEndpoints,d as ListEndpoints,H as MAX_LIMIT,u as MarketEndpoints,A as MutualFundEndpoints,$ as PERIODS,P as QuoteEndpoints,S as SECEndpoints,U as SECTORS,R as SenateHouseEndpoints,c as StockEndpoints,k as formatCurrency,D as formatDate,x as formatLargeNumber,M as formatPercentage,w as formatVolume};