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