fmp-node-api 0.0.2 → 0.0.3

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,34 +1,42 @@
1
1
  import axios from 'axios';
2
2
 
3
3
  // src/client.ts
4
+ function unwrapSingleObject(data) {
5
+ if (Array.isArray(data) && data.length === 1) {
6
+ return data[0];
7
+ }
8
+ return data;
9
+ }
4
10
  var FMPClient = class {
5
11
  constructor(config) {
6
12
  this.apiKey = config.apiKey;
7
- this.baseURL = config.baseURL || "https://financialmodelingprep.com/api/v3";
8
- this.client = axios.create({
9
- baseURL: this.baseURL,
10
- timeout: config.timeout || 1e4,
11
- headers: {
12
- "Content-Type": "application/json"
13
- }
13
+ this.v3Client = this.createClient("https://financialmodelingprep.com/api/v3", config.timeout);
14
+ this.v4Client = this.createClient("https://financialmodelingprep.com/api/v4", config.timeout);
15
+ this.stableClient = this.createClient(
16
+ "https://financialmodelingprep.com/api/stable",
17
+ config.timeout
18
+ );
19
+ }
20
+ createClient(baseURL, timeout) {
21
+ const client = axios.create({
22
+ baseURL,
23
+ timeout: timeout || 1e4,
24
+ headers: { "Content-Type": "application/json" }
14
25
  });
15
- this.client.interceptors.request.use((config2) => {
16
- config2.params = {
17
- ...config2.params,
18
- apikey: this.apiKey
19
- };
20
- return config2;
26
+ client.interceptors.request.use((config) => {
27
+ config.params = { ...config.params, apikey: this.apiKey };
28
+ return config;
21
29
  });
30
+ return client;
22
31
  }
23
- /**
24
- * Make a GET request to the API
25
- */
26
- async get(endpoint, params) {
32
+ // Smart routing method
33
+ async get(endpoint, version = "v3", params) {
34
+ const client = this.getClientForVersion(version);
27
35
  try {
28
- const response = await this.client.get(endpoint, { params });
36
+ const response = await client.get(endpoint, { params });
29
37
  return {
30
38
  success: true,
31
- data: response.data,
39
+ data: unwrapSingleObject(response.data),
32
40
  status: response.status
33
41
  };
34
42
  } catch (error) {
@@ -39,31 +47,18 @@ var FMPClient = class {
39
47
  };
40
48
  }
41
49
  }
42
- /**
43
- * Make a POST request to the API
44
- */
45
- async post(endpoint, data, config) {
46
- try {
47
- const response = await this.client.post(endpoint, data, config);
48
- return {
49
- success: true,
50
- data: response.data,
51
- status: response.status
52
- };
53
- } catch (error) {
54
- return {
55
- success: false,
56
- error: error.message || "Unknown error occurred",
57
- status: error.response?.status || 500
58
- };
50
+ getClientForVersion(version) {
51
+ switch (version) {
52
+ case "v3":
53
+ return this.v3Client;
54
+ case "v4":
55
+ return this.v4Client;
56
+ case "stable":
57
+ return this.stableClient;
58
+ default:
59
+ return this.v3Client;
59
60
  }
60
61
  }
61
- /**
62
- * Get the underlying axios instance for advanced usage
63
- */
64
- getAxiosInstance() {
65
- return this.client;
66
- }
67
62
  };
68
63
 
69
64
  // src/shared.ts
@@ -75,36 +70,22 @@ var FMPError = class extends Error {
75
70
  this.name = "FMPError";
76
71
  }
77
72
  };
73
+
74
+ // src/utils/validation.ts
78
75
  function validateApiKey(apiKey) {
79
- if (!apiKey || typeof apiKey !== "string") {
80
- throw new FMPError("API key is required and must be a string");
76
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
77
+ throw new FMPError("API key is required and must be a non-empty string");
81
78
  }
82
79
  }
83
80
  function validateSymbol(symbol) {
84
- if (!symbol || typeof symbol !== "string") {
85
- throw new FMPError("Symbol is required and must be a string");
81
+ if (!symbol || typeof symbol !== "string" || symbol.trim().length === 0) {
82
+ throw new FMPError("Symbol is required and must be a non-empty string");
86
83
  }
87
- }
88
- var FMP_BASE_URL = "https://financialmodelingprep.com/api/v3";
89
- var FMP_BASE_URL_V4 = "https://financialmodelingprep.com/api/v4";
90
- var Period = /* @__PURE__ */ ((Period2) => {
91
- Period2["ANNUAL"] = "annual";
92
- Period2["QUARTER"] = "quarter";
93
- return Period2;
94
- })(Period || {});
95
- var Exchange = /* @__PURE__ */ ((Exchange2) => {
96
- Exchange2["NYSE"] = "NYSE";
97
- Exchange2["NASDAQ"] = "NASDAQ";
98
- Exchange2["AMEX"] = "AMEX";
99
- Exchange2["TSX"] = "TSX";
100
- Exchange2["LSE"] = "LSE";
101
- return Exchange2;
102
- })(Exchange || {});
103
-
104
- // src/utils/validation.ts
105
- function validateApiKey2(apiKey) {
106
- if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
107
- throw new FMPError("API key is required and must be a non-empty string");
84
+ const symbolRegex = /^[A-Z0-9.-]+$/;
85
+ if (!symbolRegex.test(symbol.toUpperCase())) {
86
+ throw new FMPError(
87
+ "Invalid symbol format. Symbols should contain only letters, numbers, dots, and hyphens"
88
+ );
108
89
  }
109
90
  }
110
91
  function validateDate(date) {
@@ -143,68 +124,63 @@ var StockEndpoints = class {
143
124
  }
144
125
  /**
145
126
  * Get real-time stock quote
127
+ * https://site.financialmodelingprep.com/developer/docs#full-quote-quote
128
+ * @param symbol - The stock symbol to get the quote for
129
+ * @returns This endpoint gives you the latest bid and ask prices for a stock, as well as the volume and last trade price in real time.
146
130
  */
147
131
  async getQuote({ symbol }) {
148
- return this.client.get(`/quote/${symbol}`);
149
- }
150
- /**
151
- * Get company profile
152
- */
153
- async getCompanyProfile({ symbol }) {
154
- return this.client.get(`/profile/${symbol}`);
132
+ return this.client.get(`/quote/${symbol}`, "v3");
155
133
  }
156
134
  /**
157
135
  * Get historical stock prices
136
+ * https://site.financialmodelingprep.com/developer/docs#daily-chart-charts
137
+ * @param symbol - The stock symbol to get the historical prices for
138
+ * @param from - The start date to get the historical prices for
139
+ * @param to - The end date to get the historical prices for
140
+ * @returns The FMP Daily Chart endpoint provides daily stock data for a specified company, including opening, high, low, and closing prices, with a default limit of 5 years of historical data. To access data beyond this limit, use the from and to parameters for custom date ranges, each with a 5-year limit
158
141
  */
159
142
  async getHistoricalPrice({
160
143
  symbol,
161
144
  from,
162
145
  to
163
146
  }) {
164
- const params = new URLSearchParams();
165
- if (from) params.append("from", from);
166
- if (to) params.append("to", to);
167
- const queryString = params.toString();
168
- return this.client.get(
169
- `/historical-price-full/${symbol}${queryString ? `?${queryString}` : ""}`
170
- );
171
- }
172
- /**
173
- * Get list of all stocks
174
- */
175
- async getStockList() {
176
- return this.client.get("/stock/list");
147
+ const params = {};
148
+ if (from) params.from = from;
149
+ if (to) params.to = to;
150
+ return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
177
151
  }
178
152
  /**
179
- * Get market capitalization
153
+ * Get market cap
154
+ * https://site.financialmodelingprep.com/developer/docs#market-cap-company-information
155
+ * @param symbol - The stock symbol to get the market cap for
156
+ * @returns The FMP Market Cap endpoint provides the current market capitalization of a company. Market cap is a measure of the size and relative importance of a company in the stock market. It is calculated by multiplying the current share price by the number of outstanding shares.
180
157
  */
181
- async getMarketCap({ symbol }) {
182
- return this.client.get(`/market-capitalization/${symbol}`);
183
- }
184
- /**
185
- * Get earnings calendar
186
- */
187
- async getEarningsCalendar(params) {
188
- const queryParams = {};
189
- if (params.from) queryParams.from = params.from;
190
- if (params.to) queryParams.to = params.to;
191
- return this.client.get("/earning_calendar", queryParams);
158
+ async getMarketCap({
159
+ symbol
160
+ }) {
161
+ return this.client.get(`/market-capitalization/${symbol}`, "v3");
192
162
  }
193
163
  /**
194
164
  * Get stock splits
165
+ * https://site.financialmodelingprep.com/developer/docs#splits-historical-splits
166
+ * @param symbol - The stock symbol to get the splits for
167
+ * @returns A list of historical stock splits for publicly traded companies, including the date of the stock split, the split ratio, and the type of stock split.
195
168
  */
196
- async getStockSplits({ symbol }) {
197
- return this.client.get(`/stock_split_calendar/${symbol}`);
169
+ async getStockSplits({
170
+ symbol
171
+ }) {
172
+ return this.client.get(`/stock-split-calendar/${symbol}`, "v3");
198
173
  }
199
174
  /**
200
175
  * Get dividend history
176
+ * https://site.financialmodelingprep.com/developer/docs#dividends-historical-dividends
177
+ * @param symbol - The stock symbol to get the dividend history for
178
+ * @returns A list of historical dividend payments for publicly traded companies, including the date of the dividend payment, the ex-dividend date, and the dividend per share.
201
179
  */
202
- async getDividendHistory({ symbol }) {
203
- const response = await this.client.get(`/historical-price-full/stock_dividend/${symbol}`);
204
- return {
205
- ...response,
206
- data: response.success && response.data && Array.isArray(response.data.historical) ? response.data.historical : []
207
- };
180
+ async getDividendHistory({
181
+ symbol
182
+ }) {
183
+ return this.client.get(`/historical-price-full/stock_dividend/${symbol}`, "v3");
208
184
  }
209
185
  };
210
186
 
@@ -215,63 +191,165 @@ var FinancialEndpoints = class {
215
191
  }
216
192
  /**
217
193
  * Get income statement
194
+ * https://site.financialmodelingprep.com/developer/docs#income-statements-financial-statements
195
+ * @param symbol - The stock symbol to get the income statement for
196
+ * @param period - The period to get the income statement for (annual or quarter)
197
+ * @param limit - The number of periods to get
198
+ * @returns FMP's Income Statement API provides access to real-time income statement data for a wide range of companies, including public companies, private companies, and ETFs. This data can be used to track a company's profitability over time, to compare a company to its competitors, and to identify trends in a company's business.
218
199
  */
219
200
  async getIncomeStatement({
220
201
  symbol,
221
202
  period = "annual",
222
203
  limit = 5
223
204
  }) {
224
- return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`);
205
+ return this.client.get(`/income-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
225
206
  }
226
207
  /**
227
208
  * Get balance sheet
209
+ * https://site.financialmodelingprep.com/developer/docs#balance-sheet-statements-financial-statements
210
+ * @param symbol - The stock symbol to get the balance sheet for
211
+ * @param period - The period to get the balance sheet for (annual or quarter)
212
+ * @param limit - The number of periods to get
213
+ * @returns The balance sheet is a financial statement that displays a company’s total assets, liabilities, and shareholder equity over a specific timeframe (quarterly or yearly). Investors can use this statement to determine if the company can fund its operations, meet its debt obligations, and pay a dividend.
228
214
  */
229
215
  async getBalanceSheet({
230
216
  symbol,
231
217
  period = "annual",
232
218
  limit = 5
233
219
  }) {
234
- return this.client.get(`/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`);
220
+ return this.client.get(
221
+ `/balance-sheet-statement/${symbol}?period=${period}&limit=${limit}`,
222
+ "v3"
223
+ );
235
224
  }
236
225
  /**
237
226
  * Get cash flow statement
227
+ * https://site.financialmodelingprep.com/developer/docs#cashflow-statements-financial-statements
228
+ * @param symbol - The stock symbol to get the cash flow statement for
229
+ * @param period - The period to get the cash flow statement for (annual or quarter)
230
+ * @param limit - The number of periods to get
231
+ * @returns The cash flow statement is a financial statement that highlights how cash moves through the company, including both cash inflows and outflows. This statement shows the cash flows in 3 main categories “Operating Cash Flows”, “Investing Cash Flows”, and “Financing Cash Flows”, which help investors to understand if the company is making money or losing money by conducting business.
238
232
  */
239
233
  async getCashFlowStatement({
240
234
  symbol,
241
235
  period = "annual",
242
236
  limit = 5
243
237
  }) {
244
- return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`);
238
+ return this.client.get(`/cash-flow-statement/${symbol}?period=${period}&limit=${limit}`, "v3");
245
239
  }
246
240
  /**
247
241
  * Get key metrics
242
+ * https://site.financialmodelingprep.com/developer/docs#key-metrics-statement-analysis
243
+ * @param symbol - The stock symbol to get the key metrics for
244
+ * @param period - The period to get the key metrics for (annual or quarter)
245
+ * @param limit - The number of periods to get
246
+ * @returns Get key financial metrics for a company, including revenue, net income, and price-to-earnings ratio (P/E ratio). Assess a company's financial performance and compare it to its competitors.
248
247
  */
249
248
  async getKeyMetrics({
250
249
  symbol,
251
250
  period = "annual",
252
251
  limit = 5
253
252
  }) {
254
- return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`);
253
+ return this.client.get(`/key-metrics/${symbol}?period=${period}&limit=${limit}`, "v3");
255
254
  }
256
255
  /**
257
256
  * Get financial ratios
257
+ * https://site.financialmodelingprep.com/developer/docs#ratios-statement-analysis
258
+ * @param symbol - The stock symbol to get the financial ratios for
259
+ * @param period - The period to get the financial ratios for (annual or quarter)
260
+ * @param limit - The number of periods to get
261
+ * @returns Get financial ratios for a company, such as the P/B ratio and the ROE. Assess a company's financial health and compare it to its competitors.
258
262
  */
259
263
  async getFinancialRatios({
260
264
  symbol,
261
265
  period = "annual",
262
266
  limit = 5
263
267
  }) {
264
- return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`);
268
+ return this.client.get(`/ratios/${symbol}?period=${period}&limit=${limit}`, "v3");
265
269
  }
266
270
  /**
267
271
  * Get enterprise value
272
+ * https://site.financialmodelingprep.com/developer/docs#enterprise-values-statement-analysis
273
+ * @param symbol - The stock symbol to get the enterprise value for
274
+ * @param period - The period to get the enterprise value for (annual or quarter)
275
+ * @param limit - The number of periods to get
276
+ * @returns Get the enterprise value of a company, which is the total value of a company, including its equity and debt. Assess a company's overall value and compare it to its peers.
268
277
  */
269
278
  async getEnterpriseValue({
270
279
  symbol,
271
280
  period = "annual",
272
281
  limit = 5
273
282
  }) {
274
- return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`);
283
+ return this.client.get(`/enterprise-value/${symbol}?period=${period}&limit=${limit}`, "v3");
284
+ }
285
+ /**
286
+ * Get cashflow growth
287
+ * https://site.financialmodelingprep.com/developer/docs#cashflow-growth-statement-analysis
288
+ * @param symbol - The stock symbol to get the cashflow growth for
289
+ * @param period - The period to get the cashflow growth for (annual or quarter)
290
+ * @param limit - The number of periods to get
291
+ * @returns Get the cash flow growth rate for a company. Measure how quickly a company's cash flow is growing.
292
+ */
293
+ async getCashflowGrowth({
294
+ symbol,
295
+ period = "annual",
296
+ limit = 5
297
+ }) {
298
+ return this.client.get(
299
+ `/cash-flow-statement-growth/${symbol}?period=${period}&limit=${limit}`,
300
+ "v3"
301
+ );
302
+ }
303
+ /**
304
+ * Get income growth
305
+ * https://site.financialmodelingprep.com/developer/docs#income-growth-statement-analysis
306
+ * @param symbol - The stock symbol to get the income growth for
307
+ * @param period - The period to get the income growth for (annual or quarter)
308
+ * @param limit - The number of periods to get
309
+ * @returns Get the income growth rate for a company. Measure how quickly a company's income is growing.
310
+ */
311
+ async getIncomeGrowth({
312
+ symbol,
313
+ period = "annual",
314
+ limit = 5
315
+ }) {
316
+ return this.client.get(
317
+ `/income-statement-growth/${symbol}?period=${period}&limit=${limit}`,
318
+ "v3"
319
+ );
320
+ }
321
+ /**
322
+ * Get balance sheet growth
323
+ * https://site.financialmodelingprep.com/developer/docs#balance-sheet-growth-statement-analysis
324
+ * @param symbol - The stock symbol to get the balance sheet growth for
325
+ * @param period - The period to get the balance sheet growth for (annual or quarter)
326
+ * @param limit - The number of periods to get
327
+ * @returns Get the balance sheet growth rate for a company. Measure how quickly a company's assets and liabilities are growing.
328
+ */
329
+ async getBalanceSheetGrowth({
330
+ symbol,
331
+ period = "annual",
332
+ limit = 5
333
+ }) {
334
+ return this.client.get(
335
+ `/balance-sheet-statement-growth/${symbol}?period=${period}&limit=${limit}`,
336
+ "v3"
337
+ );
338
+ }
339
+ /**
340
+ * Get financial growth
341
+ * https://site.financialmodelingprep.com/developer/docs#financial-growth-statement-analysis
342
+ * @param symbol - The stock symbol to get the financial growth for
343
+ * @param period - The period to get the financial growth for (annual or quarter)
344
+ * @param limit - The number of periods to get
345
+ * @returns Financial Growth Get the financial growth rate for a company. Measure how quickly a company's overall financial performance is improving.
346
+ */
347
+ async getFinancialGrowth({
348
+ symbol,
349
+ period = "annual",
350
+ limit = 5
351
+ }) {
352
+ return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
275
353
  }
276
354
  };
277
355
 
@@ -281,59 +359,35 @@ var ForexEndpoints = class {
281
359
  this.client = client;
282
360
  }
283
361
  /**
284
- * Get real-time forex quote
362
+ * Get forex quote
285
363
  */
286
364
  async getQuote(params) {
287
- return this.client.get(`/quote/${params.symbol}`);
365
+ return this.client.get("/quote", "v3", params);
288
366
  }
289
367
  /**
290
- * Get historical forex data
368
+ * Get historical forex prices
291
369
  */
292
- async getHistoricalPrice(params) {
293
- const queryParams = {};
294
- if (params.from) queryParams.from = params.from;
295
- if (params.to) queryParams.to = params.to;
296
- if (params.timeseries) queryParams.timeseries = params.timeseries;
297
- return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
298
- }
299
- /**
300
- * Get list of all forex pairs
301
- * Using the forex-specific endpoint
302
- */
303
- async getForexList() {
304
- try {
305
- const response = await this.client.get("/forex-list");
306
- if (!response.success || !response.data) {
307
- const fallbackResponse = await this.client.get("/forex");
308
- return {
309
- ...fallbackResponse,
310
- data: Array.isArray(fallbackResponse.data) ? fallbackResponse.data : Array.isArray(fallbackResponse.data?.forexList) ? fallbackResponse.data.forexList : []
311
- };
312
- }
313
- return {
314
- ...response,
315
- data: Array.isArray(response.data) ? response.data : Array.isArray(response.data?.forexList) ? response.data.forexList : []
316
- };
317
- } catch (error) {
318
- return {
319
- success: false,
320
- error: "Failed to fetch forex pairs",
321
- status: 500,
322
- data: []
323
- };
324
- }
370
+ async getHistoricalPrice({
371
+ symbol,
372
+ from,
373
+ to
374
+ }) {
375
+ const params = {};
376
+ if (from) params.from = from;
377
+ if (to) params.to = to;
378
+ return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
325
379
  }
326
380
  /**
327
- * Get forex rates for a specific currency
381
+ * Get forex rates for a specific base currency
328
382
  */
329
383
  async getForexRates(baseCurrency = "USD") {
330
- return this.client.get(`/forex/${baseCurrency}`);
384
+ return this.client.get(`/forex/${baseCurrency}`, "v3");
331
385
  }
332
386
  /**
333
- * Get forex rates for all currencies
387
+ * Get all forex rates
334
388
  */
335
389
  async getAllForexRates() {
336
- return this.client.get("/forex");
390
+ return this.client.get("/forex", "v3");
337
391
  }
338
392
  };
339
393
 
@@ -343,26 +397,23 @@ var CryptoEndpoints = class {
343
397
  this.client = client;
344
398
  }
345
399
  /**
346
- * Get real-time crypto quote
400
+ * Get crypto quote
347
401
  */
348
402
  async getQuote(params) {
349
- return this.client.get(`/quote/${params.symbol}`);
350
- }
351
- /**
352
- * Get historical crypto data
353
- */
354
- async getHistoricalPrice(params) {
355
- const queryParams = {};
356
- if (params.from) queryParams.from = params.from;
357
- if (params.to) queryParams.to = params.to;
358
- if (params.timeseries) queryParams.timeseries = params.timeseries;
359
- return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
403
+ return this.client.get("/quote", "v3", params);
360
404
  }
361
405
  /**
362
- * Get list of all cryptocurrencies
406
+ * Get historical crypto prices
363
407
  */
364
- async getCryptoList() {
365
- return this.client.get("/cryptocurrency");
408
+ async getHistoricalPrice({
409
+ symbol,
410
+ from,
411
+ to
412
+ }) {
413
+ const params = {};
414
+ if (from) params.from = from;
415
+ if (to) params.to = to;
416
+ return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
366
417
  }
367
418
  };
368
419
 
@@ -372,31 +423,22 @@ var ETFEndpoints = class {
372
423
  this.client = client;
373
424
  }
374
425
  /**
375
- * Get real-time ETF quote
426
+ * Get ETF quote
376
427
  */
377
428
  async getQuote(params) {
378
- return this.client.get(`/quote/${params.symbol}`);
429
+ return this.client.get("/quote", "v3", params);
379
430
  }
380
431
  /**
381
432
  * Get ETF profile
382
433
  */
383
434
  async getProfile(params) {
384
- return this.client.get(`/profile/${params.symbol}`);
435
+ return this.client.get("/profile", "v3", params);
385
436
  }
386
437
  /**
387
438
  * Get ETF holdings
388
439
  */
389
440
  async getHoldings(params) {
390
- const queryParams = {};
391
- if (params.limit) queryParams.limit = params.limit;
392
- if (params.page) queryParams.page = params.page;
393
- return this.client.get(`/etf-holder/${params.symbol}`, queryParams);
394
- }
395
- /**
396
- * Get list of all ETFs
397
- */
398
- async getETFList() {
399
- return this.client.get("/etf/list");
441
+ return this.client.get("/holdings", "v3", params);
400
442
  }
401
443
  };
402
444
 
@@ -406,31 +448,22 @@ var MutualFundEndpoints = class {
406
448
  this.client = client;
407
449
  }
408
450
  /**
409
- * Get real-time mutual fund quote
451
+ * Get mutual fund quote
410
452
  */
411
453
  async getQuote(params) {
412
- return this.client.get(`/quote/${params.symbol}`);
454
+ return this.client.get("/quote", "v3", params);
413
455
  }
414
456
  /**
415
457
  * Get mutual fund profile
416
458
  */
417
459
  async getProfile(params) {
418
- return this.client.get(`/profile/${params.symbol}`);
460
+ return this.client.get("/profile", "v3", params);
419
461
  }
420
462
  /**
421
463
  * Get mutual fund holdings
422
464
  */
423
465
  async getHoldings(params) {
424
- const queryParams = {};
425
- if (params.limit) queryParams.limit = params.limit;
426
- if (params.page) queryParams.page = params.page;
427
- return this.client.get(`/mutual-fund-holder/${params.symbol}`, queryParams);
428
- }
429
- /**
430
- * Get list of all mutual funds
431
- */
432
- async getMutualFundList() {
433
- return this.client.get("/mutual-fund/list");
466
+ return this.client.get("/holdings", "v3", params);
434
467
  }
435
468
  };
436
469
 
@@ -440,26 +473,23 @@ var BondEndpoints = class {
440
473
  this.client = client;
441
474
  }
442
475
  /**
443
- * Get real-time bond quote
476
+ * Get bond quote
444
477
  */
445
478
  async getQuote(params) {
446
- return this.client.get(`/quote/${params.symbol}`);
447
- }
448
- /**
449
- * Get historical bond data
450
- */
451
- async getHistoricalPrice(params) {
452
- const queryParams = {};
453
- if (params.from) queryParams.from = params.from;
454
- if (params.to) queryParams.to = params.to;
455
- if (params.timeseries) queryParams.timeseries = params.timeseries;
456
- return this.client.get(`/historical-price-full/${params.symbol}`, queryParams);
479
+ return this.client.get("/quote", "v3", params);
457
480
  }
458
481
  /**
459
- * Get list of all bonds
482
+ * Get historical bond prices
460
483
  */
461
- async getBondList() {
462
- return this.client.get("/bond/list");
484
+ async getHistoricalPrice({
485
+ symbol,
486
+ from,
487
+ to
488
+ }) {
489
+ const params = {};
490
+ if (from) params.from = from;
491
+ if (to) params.to = to;
492
+ return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
463
493
  }
464
494
  };
465
495
 
@@ -472,46 +502,31 @@ var EconomicEndpoints = class {
472
502
  * Get treasury rates
473
503
  */
474
504
  async getTreasuryRates(params = {}) {
475
- const queryParams = {};
476
- if (params.from) queryParams.from = params.from;
477
- if (params.to) queryParams.to = params.to;
478
- return this.client.get("/treasury-rates", queryParams);
505
+ return this.client.get("/treasury-rates", "v3", params);
479
506
  }
480
507
  /**
481
508
  * Get federal funds rate
482
509
  */
483
510
  async getFederalFundsRate(params = {}) {
484
- const queryParams = {};
485
- if (params.from) queryParams.from = params.from;
486
- if (params.to) queryParams.to = params.to;
487
- return this.client.get("/federal-funds-rate", queryParams);
511
+ return this.client.get("/federal-funds-rate", "v3", params);
488
512
  }
489
513
  /**
490
514
  * Get CPI data
491
515
  */
492
516
  async getCPI(params = {}) {
493
- const queryParams = {};
494
- if (params.from) queryParams.from = params.from;
495
- if (params.to) queryParams.to = params.to;
496
- return this.client.get("/economic-indicator/cpi", queryParams);
517
+ return this.client.get("/economic/cpi", "v3", params);
497
518
  }
498
519
  /**
499
520
  * Get GDP data
500
521
  */
501
522
  async getGDP(params = {}) {
502
- const queryParams = {};
503
- if (params.from) queryParams.from = params.from;
504
- if (params.to) queryParams.to = params.to;
505
- return this.client.get("/economic-indicator/gdp", queryParams);
523
+ return this.client.get("/economic/gdp", "v3", params);
506
524
  }
507
525
  /**
508
526
  * Get unemployment data
509
527
  */
510
528
  async getUnemployment(params = {}) {
511
- const queryParams = {};
512
- if (params.from) queryParams.from = params.from;
513
- if (params.to) queryParams.to = params.to;
514
- return this.client.get("/economic-indicator/unemployment", queryParams);
529
+ return this.client.get("/economic/unemployment", "v3", params);
515
530
  }
516
531
  };
517
532
 
@@ -524,53 +539,263 @@ var MarketEndpoints = class {
524
539
  * Get market hours
525
540
  */
526
541
  async getMarketHours() {
527
- return this.client.get("/market-hours");
542
+ return this.client.get("/market-hours", "v3");
528
543
  }
529
544
  /**
530
545
  * Get market performance
531
546
  */
532
547
  async getMarketPerformance() {
533
- return this.client.get("/market-performance");
548
+ return this.client.get("/market-performance", "v3");
534
549
  }
535
550
  /**
536
- * Get market gainers
551
+ * Get top gainers
537
552
  */
538
553
  async getGainers() {
539
- return this.client.get("/gainers");
554
+ return this.client.get("/gainers", "v3");
540
555
  }
541
556
  /**
542
- * Get market losers
557
+ * Get top losers
543
558
  */
544
559
  async getLosers() {
545
- return this.client.get("/losers");
560
+ return this.client.get("/losers", "v3");
546
561
  }
547
562
  /**
548
563
  * Get most active stocks
549
564
  */
550
565
  async getMostActive() {
551
- return this.client.get("/most-active");
566
+ return this.client.get("/most-active", "v3");
552
567
  }
553
568
  /**
554
569
  * Get sector performance
555
570
  */
556
571
  async getSectorPerformance() {
557
- return this.client.get("/sector-performance");
572
+ return this.client.get("/sector-performance", "v3");
558
573
  }
559
574
  /**
560
- * Get market index data
575
+ * Get market indices
561
576
  */
562
577
  async getMarketIndex(params = {}) {
563
- const queryParams = {};
564
- if (params.from) queryParams.from = params.from;
565
- if (params.to) queryParams.to = params.to;
566
- return this.client.get("/market-index", queryParams);
578
+ return this.client.get("/market-index", "v3", params);
579
+ }
580
+ };
581
+
582
+ // src/endpoints/list.ts
583
+ var ListEndpoints = class {
584
+ constructor(client) {
585
+ this.client = client;
586
+ }
587
+ /**
588
+ * Get stock list
589
+ * https://site.financialmodelingprep.com/developer/docs#symbol-list-stock-list
590
+ * @returns The stock list
591
+ */
592
+ async getStockList() {
593
+ return this.client.get("/stock/list");
594
+ }
595
+ /**
596
+ * Get ETF list
597
+ * https://site.financialmodelingprep.com/developer/docs#exchange-traded-fund-search-stock-list
598
+ * @returns The ETF list
599
+ */
600
+ async getETFList() {
601
+ return this.client.get("/etf/list");
602
+ }
603
+ /**
604
+ * Get crypto list
605
+ * https://site.financialmodelingprep.com/developer/docs#cryptocurrencies-list-crypto
606
+ * @returns The crypto list
607
+ */
608
+ async getCryptoList() {
609
+ return this.client.get("/symbol/available-cryptocurrencies");
610
+ }
611
+ /**
612
+ * Get forex list
613
+ * https://site.financialmodelingprep.com/developer/docs#forex-list-forex
614
+ * @returns The forex list
615
+ */
616
+ async getForexList() {
617
+ return this.client.get("/symbol/available-forex-currency-pairs");
618
+ }
619
+ /**
620
+ * Get available indexes list
621
+ * https://site.financialmodelingprep.com/developer/docs#available-indexes
622
+ * @returns The available indexes list
623
+ */
624
+ async getAvailableIndexes() {
625
+ return this.client.get("/symbol/available-indexes");
626
+ }
627
+ };
628
+
629
+ // src/endpoints/calendar.ts
630
+ var CalendarEndpoints = class {
631
+ constructor(client) {
632
+ this.client = client;
633
+ }
634
+ /**
635
+ * Get earnings calendar
636
+ * https://site.financialmodelingprep.com/developer/docs#earnings-calendar-earnings
637
+ * @param from - The start date to get the earnings calendar for
638
+ * @param to - The end date to get the earnings calendar for
639
+ * @returns The earnings calendar
640
+ */
641
+ async getEarningsCalendar({ from, to } = {}) {
642
+ const params = {};
643
+ if (from) params.from = from;
644
+ if (to) params.to = to;
645
+ return this.client.get("/earning_calendar", "v3", params);
646
+ }
647
+ /**
648
+ * Get dividends calendar
649
+ * https://site.financialmodelingprep.com/developer/docs#dividends-calendar-dividends
650
+ * @param from - The start date to get the dividends calendar for
651
+ * @param to - The end date to get the dividends calendar for
652
+ * @returns The dividends calendar
653
+ */
654
+ async getDividendsCalendar({ from, to } = {}) {
655
+ const params = {};
656
+ if (from) params.from = from;
657
+ if (to) params.to = to;
658
+ return this.client.get("/stock_dividend_calendar", "v3", params);
659
+ }
660
+ /**
661
+ * Get economics calendar
662
+ * https://site.financialmodelingprep.com/developer/docs#economics-calendar-economics-data
663
+ * @param from - The start date to get the economics calendar for
664
+ * @param to - The end date to get the economics calendar for
665
+ * @returns The economics calendar
666
+ */
667
+ async getEconomicsCalendar({ from, to } = {}) {
668
+ const params = {};
669
+ if (from) params.from = from;
670
+ if (to) params.to = to;
671
+ return this.client.get("/economic_calendar", "v3", params);
672
+ }
673
+ /**
674
+ * Get IPO calendar
675
+ * https://site.financialmodelingprep.com/developer/docs#ipo-calender-by-ipo-calendar
676
+ * @param from - The start date to get the IPO calendar for
677
+ * @param to - The end date to get the IPO calendar for
678
+ * @returns The IPO calendar
679
+ */
680
+ async getIPOCalendar({ from, to } = {}) {
681
+ const params = {};
682
+ if (from) params.from = from;
683
+ if (to) params.to = to;
684
+ return this.client.get("/ipo_calendar", "v3", params);
685
+ }
686
+ /**
687
+ * Get stock splits calendar
688
+ * https://site.financialmodelingprep.com/developer/docs#splits-calendar-splits
689
+ * @param from - The start date to get the stock splits calendar for
690
+ * @param to - The end date to get the stock splits calendar for
691
+ * @returns The stock splits calendar
692
+ */
693
+ async getSplitsCalendar({ from, to } = {}) {
694
+ const params = {};
695
+ if (from) params.from = from;
696
+ if (to) params.to = to;
697
+ return this.client.get("/stock_split_calendar", "v3", params);
698
+ }
699
+ };
700
+
701
+ // src/endpoints/company.ts
702
+ var CompanyEndpoints = class {
703
+ constructor(client) {
704
+ this.client = client;
705
+ }
706
+ /**
707
+ * Get company profile
708
+ * https://site.financialmodelingprep.com/developer/docs#company-profile-company-information
709
+ * @param symbol - The stock symbol to get the profile for
710
+ * @returns Get a comprehensive overview of a company with our Company Profile endpoint. This endpoint provides key information such as price, beta, market capitalization, description, headquarters, and more.
711
+ */
712
+ async getCompanyProfile({
713
+ symbol
714
+ }) {
715
+ return this.client.get(`/profile/${symbol}`, "v3");
716
+ }
717
+ /**
718
+ * Get executive compensation
719
+ * https://site.financialmodelingprep.com/developer/docs#executive-compensation-company-information
720
+ * @param symbol - The stock symbol to get the executive compensation for
721
+ * @returns Understand how a company compensates its executives with our Executive Compensation endpoint. This endpoint provides information such as salary, bonus, and stock options for each executive.
722
+ */
723
+ async getExecutiveCompensation({
724
+ symbol
725
+ }) {
726
+ const params = { symbol };
727
+ return this.client.get(`/governance/executive_compensation`, "v4", params);
728
+ }
729
+ /**
730
+ * Get company notes
731
+ * https://site.financialmodelingprep.com/developer/docs#company-notes-company-information
732
+ * @param symbol - The stock symbol to get the notes for
733
+ * @returns Stay up-to-date on a company's financial condition, operations, and risks with our Company Notes endpoint. This endpoint provides information about notes reported by a company in their financial statements.
734
+ */
735
+ async getCompanyNotes({
736
+ symbol
737
+ }) {
738
+ const params = { symbol };
739
+ return this.client.get(`/company-notes`, "v4", params);
740
+ }
741
+ /**
742
+ * Get historical employee count
743
+ * https://site.financialmodelingprep.com/developer/docs#historical-employee-company-information
744
+ * @param symbol - The stock symbol to get the historical employee count for
745
+ * @returns Track a company's employee count over time with our Historical Employee Count endpoint. This endpoint provides information about the number of employees a company has had each year.
746
+ */
747
+ async getHistoricalEmployeeCount({
748
+ symbol
749
+ }) {
750
+ const params = { symbol };
751
+ return this.client.get(`/historical/employee_count`, "v4", params);
752
+ }
753
+ /**
754
+ * Get shares float
755
+ * https://site.financialmodelingprep.com/developer/docs#company-share-float-share-float
756
+ * @param symbol - The stock symbol to get the shares float for
757
+ * @returns The FMP Company Share Float endpoint provides the total number of shares that are publicly traded for a given company. This is also known as the company's float. The float is calculated by subtracting the number of restricted shares from the total number of outstanding shares.
758
+ */
759
+ async getSharesFloat({
760
+ symbol
761
+ }) {
762
+ const params = { symbol };
763
+ return this.client.get(`/shares_float`, "v4", params);
764
+ }
765
+ /**
766
+ * Get historical shares float
767
+ * https://site.financialmodelingprep.com/developer/docs#company-historical-share-float
768
+ * @param symbol - The stock symbol to get the historical shares float for
769
+ * @returns The FMP Historical Share Float endpoint provides historical data on the number of shares that are publicly traded for a given company. This is also known as the company's float. The float is calculated by subtracting the number of restricted shares from the total number of outstanding shares.
770
+ */
771
+ async getHistoricalSharesFloat({
772
+ symbol
773
+ }) {
774
+ const params = { symbol };
775
+ return this.client.get(`/historical/shares_float`, "v4", params);
776
+ }
777
+ /**
778
+ * Get earnings call transcript
779
+ * https://site.financialmodelingprep.com/developer/docs#earnings-transcript-earnings-transcripts
780
+ * @param symbol - The stock symbol to get the earnings call transcript for
781
+ * @param year - The year of the earnings call
782
+ * @param quarter - The quarter of the earnings call
783
+ * @returns The FMP Earnings Call Transcript endpoint provides the transcript of a company's earnings call.
784
+ */
785
+ async getEarningsCallTranscript({
786
+ symbol,
787
+ year,
788
+ quarter
789
+ }) {
790
+ const params = { year, quarter };
791
+ return this.client.get(`/earning_call_transcript/${symbol}`, "v3", params);
567
792
  }
568
793
  };
569
794
 
570
795
  // src/fmp.ts
571
796
  var FMP = class {
572
797
  constructor(config) {
573
- validateApiKey2(config.apiKey);
798
+ validateApiKey(config.apiKey);
574
799
  const client = new FMPClient(config);
575
800
  this.stock = new StockEndpoints(client);
576
801
  this.financial = new FinancialEndpoints(client);
@@ -581,6 +806,9 @@ var FMP = class {
581
806
  this.bond = new BondEndpoints(client);
582
807
  this.economic = new EconomicEndpoints(client);
583
808
  this.market = new MarketEndpoints(client);
809
+ this.list = new ListEndpoints(client);
810
+ this.calendar = new CalendarEndpoints(client);
811
+ this.company = new CompanyEndpoints(client);
584
812
  }
585
813
  /**
586
814
  * Get the underlying client instance for advanced usage
@@ -591,7 +819,22 @@ var FMP = class {
591
819
  };
592
820
 
593
821
  // src/types/common.ts
594
- var FMP_STABLE_URL = "https://financialmodelingprep.com/stable";
822
+ var Period = /* @__PURE__ */ ((Period2) => {
823
+ Period2["ANNUAL"] = "annual";
824
+ Period2["QUARTER"] = "quarter";
825
+ return Period2;
826
+ })(Period || {});
827
+ var Exchange = /* @__PURE__ */ ((Exchange2) => {
828
+ Exchange2["NYSE"] = "NYSE";
829
+ Exchange2["NASDAQ"] = "NASDAQ";
830
+ Exchange2["AMEX"] = "AMEX";
831
+ Exchange2["TSX"] = "TSX";
832
+ Exchange2["LSE"] = "LSE";
833
+ Exchange2["ASX"] = "ASX";
834
+ Exchange2["NSE"] = "NSE";
835
+ Exchange2["BSE"] = "BSE";
836
+ return Exchange2;
837
+ })(Exchange || {});
595
838
 
596
839
  // src/utils/formatting.ts
597
840
  function formatCurrency(value, currency = "USD") {
@@ -712,6 +955,6 @@ var HTTP_STATUS = {
712
955
  INTERNAL_SERVER_ERROR: 500
713
956
  };
714
957
 
715
- export { BondEndpoints, COUNTRIES, CryptoEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient, FMPError, FMP_BASE_URL, FMP_BASE_URL_V4, FMP_STABLE_URL, FinancialEndpoints, ForexEndpoints, HTTP_STATUS, MAX_LIMIT, MarketEndpoints, MutualFundEndpoints, PERIODS, Period, SECTORS, StockEndpoints, formatCurrency, formatDate, formatLargeNumber, formatNumber, formatPercentage, formatReadableDate, formatTimestamp, formatVolume, validateApiKey, validateDate, validateLimit, validatePage, validatePeriod, validateSymbol };
958
+ export { BondEndpoints, COUNTRIES, CalendarEndpoints, CompanyEndpoints, CryptoEndpoints, DEFAULT_LIMIT, DEFAULT_TIMEOUT, ERROR_MESSAGES, ETFEndpoints, EXCHANGES, EconomicEndpoints, Exchange, FMP, FMPClient, FinancialEndpoints, ForexEndpoints, HTTP_STATUS, ListEndpoints, MAX_LIMIT, MarketEndpoints, MutualFundEndpoints, PERIODS, Period, SECTORS, StockEndpoints, formatCurrency, formatDate, formatLargeNumber, formatNumber, formatPercentage, formatReadableDate, formatTimestamp, formatVolume, validateApiKey, validateDate, validateLimit, validatePage, validatePeriod, validateSymbol };
716
959
  //# sourceMappingURL=index.mjs.map
717
960
  //# sourceMappingURL=index.mjs.map