fmp-node-api 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -29,8 +29,26 @@ var FMPClient = class {
29
29
  });
30
30
  return client;
31
31
  }
32
- // Smart routing method
32
+ // Standard get method - returns raw API response
33
33
  async get(endpoint, version = "v3", params) {
34
+ const client = this.getClientForVersion(version);
35
+ try {
36
+ const response = await client.get(endpoint, { params });
37
+ return {
38
+ success: true,
39
+ data: response.data,
40
+ status: response.status
41
+ };
42
+ } catch (error) {
43
+ return {
44
+ success: false,
45
+ error: error.message || "Unknown error occurred",
46
+ status: error.response?.status || 500
47
+ };
48
+ }
49
+ }
50
+ // Get method for single-object endpoints - unwraps single-item arrays
51
+ async getSingle(endpoint, version = "v3", params) {
34
52
  const client = this.getClientForVersion(version);
35
53
  try {
36
54
  const response = await client.get(endpoint, { params });
@@ -129,7 +147,7 @@ var StockEndpoints = class {
129
147
  * @returns This endpoint gives you the latest bid and ask prices for a stock, as well as the volume and last trade price in real time.
130
148
  */
131
149
  async getQuote({ symbol }) {
132
- return this.client.get(`/quote/${symbol}`, "v3");
150
+ return this.client.getSingle(`/quote/${symbol}`, "v3");
133
151
  }
134
152
  /**
135
153
  * Get historical stock prices
@@ -147,7 +165,7 @@ var StockEndpoints = class {
147
165
  const params = {};
148
166
  if (from) params.from = from;
149
167
  if (to) params.to = to;
150
- return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
168
+ return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
151
169
  }
152
170
  /**
153
171
  * Get market cap
@@ -155,10 +173,8 @@ var StockEndpoints = class {
155
173
  * @param symbol - The stock symbol to get the market cap for
156
174
  * @returns The FMP Market Cap endpoint provides the current market capitalization of a company. Market cap is a measure of the size and relative importance of a company in the stock market. It is calculated by multiplying the current share price by the number of outstanding shares.
157
175
  */
158
- async getMarketCap({
159
- symbol
160
- }) {
161
- return this.client.get(`/market-capitalization/${symbol}`, "v3");
176
+ async getMarketCap({ symbol }) {
177
+ return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
162
178
  }
163
179
  /**
164
180
  * Get stock splits
@@ -166,10 +182,8 @@ var StockEndpoints = class {
166
182
  * @param symbol - The stock symbol to get the splits for
167
183
  * @returns A list of historical stock splits for publicly traded companies, including the date of the stock split, the split ratio, and the type of stock split.
168
184
  */
169
- async getStockSplits({
170
- symbol
171
- }) {
172
- return this.client.get(`/stock-split-calendar/${symbol}`, "v3");
185
+ async getStockSplits({ symbol }) {
186
+ return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
173
187
  }
174
188
  /**
175
189
  * Get dividend history
@@ -180,7 +194,7 @@ var StockEndpoints = class {
180
194
  async getDividendHistory({
181
195
  symbol
182
196
  }) {
183
- return this.client.get(`/historical-price-full/stock_dividend/${symbol}`, "v3");
197
+ return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
184
198
  }
185
199
  };
186
200
 
@@ -210,7 +224,7 @@ var FinancialEndpoints = class {
210
224
  * @param symbol - The stock symbol to get the balance sheet for
211
225
  * @param period - The period to get the balance sheet for (annual or quarter)
212
226
  * @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.
227
+ * @returns The balance sheet is a financial statement that displays a company's total assets, liabilities, and shareholder equity over a specific timeframe (quarterly or yearly). Investors can use this statement to determine if the company can fund its operations, meet its debt obligations, and pay a dividend.
214
228
  */
215
229
  async getBalanceSheet({
216
230
  symbol,
@@ -228,7 +242,7 @@ var FinancialEndpoints = class {
228
242
  * @param symbol - The stock symbol to get the cash flow statement for
229
243
  * @param period - The period to get the cash flow statement for (annual or quarter)
230
244
  * @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.
245
+ * @returns The cash flow statement is a financial statement that highlights how cash moves through the company, including both cash inflows and outflows. This statement shows the cash flows in 3 main categories "Operating Cash Flows", "Investing Cash Flows", and "Financing Cash Flows", which help investors to understand if the company is making money or losing money by conducting business.
232
246
  */
233
247
  async getCashFlowStatement({
234
248
  symbol,
@@ -351,6 +365,31 @@ var FinancialEndpoints = class {
351
365
  }) {
352
366
  return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
353
367
  }
368
+ /**
369
+ * Get earnings historical
370
+ * https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings
371
+ * @param symbol - The stock symbol to get the earnings historical for
372
+ * @param limit - The number of periods to get
373
+ * @returns A list of historical & upcoming earnings announcements for a specific company, including the date, estimated EPS, and actual EPS.
374
+ */
375
+ async getEarningsHistorical({
376
+ symbol,
377
+ limit = 5
378
+ }) {
379
+ return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
380
+ }
381
+ /**
382
+ * Get earnings surprises
383
+ * https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings
384
+ * @param symbol - The stock symbol to get the earnings surprises for
385
+ * @param limit - The number of periods to get
386
+ * @returns A list of earnings announcements for publicly traded companies that were either positive or negative surprises. This endpoint includes the date of the earnings announcement, the estimated EPS, the actual EPS, and the earnings surprise.
387
+ */
388
+ async getEarningsSurprises({
389
+ symbol
390
+ }) {
391
+ return this.client.get(`/earnings-surprises/${symbol}`, "v3");
392
+ }
354
393
  };
355
394
 
356
395
  // src/endpoints/forex.ts
@@ -360,12 +399,18 @@ var ForexEndpoints = class {
360
399
  }
361
400
  /**
362
401
  * Get forex quote
402
+ * @param params - Parameters for the forex quote request
403
+ * @returns Forex quote data
363
404
  */
364
405
  async getQuote(params) {
365
406
  return this.client.get("/quote", "v3", params);
366
407
  }
367
408
  /**
368
409
  * Get historical forex prices
410
+ * @param symbol - The forex symbol to get the historical prices for
411
+ * @param from - The start date to get the historical prices for
412
+ * @param to - The end date to get the historical prices for
413
+ * @returns Historical forex price data
369
414
  */
370
415
  async getHistoricalPrice({
371
416
  symbol,
@@ -379,12 +424,15 @@ var ForexEndpoints = class {
379
424
  }
380
425
  /**
381
426
  * Get forex rates for a specific base currency
427
+ * @param baseCurrency - The base currency to get forex rates for
428
+ * @returns Forex rates data
382
429
  */
383
430
  async getForexRates(baseCurrency = "USD") {
384
431
  return this.client.get(`/forex/${baseCurrency}`, "v3");
385
432
  }
386
433
  /**
387
434
  * Get all forex rates
435
+ * @returns All forex rates data
388
436
  */
389
437
  async getAllForexRates() {
390
438
  return this.client.get("/forex", "v3");
@@ -398,12 +446,20 @@ var CryptoEndpoints = class {
398
446
  }
399
447
  /**
400
448
  * Get crypto quote
449
+ * https://site.financialmodelingprep.com/developer/docs#full-quote-crypto
450
+ * @param symbol - The crypto symbol to get the quote for
451
+ * @returns Crypto quote data
401
452
  */
402
- async getQuote(params) {
403
- return this.client.get("/quote", "v3", params);
453
+ async getQuote({ symbol }) {
454
+ return this.client.getSingle(`/quote/${symbol}`, "v3");
404
455
  }
405
456
  /**
406
457
  * Get historical crypto prices
458
+ * https://site.financialmodelingprep.com/developer/docs#cryptocurrency-daily-crypto
459
+ * @param symbol - The crypto symbol to get the historical prices for
460
+ * @param from - The start date to get the historical prices for
461
+ * @param to - The end date to get the historical prices for
462
+ * @returns Provides daily price data for all cryptocurrencies that are traded on exchanges around the world.
407
463
  */
408
464
  async getHistoricalPrice({
409
465
  symbol,
@@ -413,7 +469,7 @@ var CryptoEndpoints = class {
413
469
  const params = {};
414
470
  if (from) params.from = from;
415
471
  if (to) params.to = to;
416
- return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
472
+ return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
417
473
  }
418
474
  };
419
475
 
@@ -423,22 +479,78 @@ var ETFEndpoints = class {
423
479
  this.client = client;
424
480
  }
425
481
  /**
426
- * Get ETF quote
482
+ * Get ETF holding dates
483
+ * https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings
484
+ * @param symbol - The symbol of the ETF to get the holding dates for
485
+ * @returns The FMP ETF Holding Dates endpoint provides a list of the dates on which ETF holdings are updated. For example, an investor may want to know when an ETF's holdings are updated in order to make sure that they are still aligned with their investment goals.
427
486
  */
428
- async getQuote(params) {
429
- return this.client.get("/quote", "v3", params);
487
+ async getHoldingDates({ symbol }) {
488
+ const params = {};
489
+ if (symbol) params.symbol = symbol;
490
+ return this.client.get("/etf-holdings/portfolio-date", "v4", params);
491
+ }
492
+ /**
493
+ * Get ETF holdings
494
+ * https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings
495
+ * @param symbol - The symbol of the ETF to get the holdings for
496
+ * @param date - The date to get the holdings for
497
+ * @returns The FMP ETF Holdings endpoint provides a list of all the institutional investors that own shares of an ETF. For example, an investor may want to know which ETF has the highest exposure to a particular industry or sector.
498
+ */
499
+ async getHoldings({
500
+ symbol,
501
+ date
502
+ }) {
503
+ const params = {};
504
+ if (symbol) params.symbol = symbol;
505
+ if (date) params.date = date;
506
+ return this.client.get("/etf-holdings", "v4", params);
507
+ }
508
+ /**
509
+ * Get ETF holder
510
+ * https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings
511
+ * @param symbol - The symbol of the ETF to get the holder for
512
+ * @returns This endpoint returns all stocks held by a specific ETF. Assets, share number, and weight are among the fields returned. For example you can get components of SPY, VOO and more.
513
+ */
514
+ async getHolder({ symbol }) {
515
+ return this.client.get(`/etf-holder/${symbol}`, "v3");
430
516
  }
431
517
  /**
432
518
  * Get ETF profile
519
+ * https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings
520
+ * @param symbol - The symbol of the ETF to get the profile for
521
+ * @returns The FMP ETF Information endpoint provides basic information about an ETF, such as its ticker symbol, name, expense ratio, and asset under management. For example, an investor may want to compare the expense ratios of different ETFs to find the one that is most cost-effective.
433
522
  */
434
- async getProfile(params) {
435
- return this.client.get("/profile", "v3", params);
523
+ async getProfile({ symbol }) {
524
+ const params = {};
525
+ if (symbol) params.symbol = symbol;
526
+ return this.client.getSingle("/etf-info", "v4", params);
436
527
  }
437
528
  /**
438
- * Get ETF holdings
529
+ * Get ETF sector weighting
530
+ * https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings
531
+ * @param symbol - The symbol of the ETF to get the sector exposure for
532
+ * @returns The FMP ETF Sector Weighting endpoint provides a breakdown of the percentage of an ETF's assets that are invested in each sector. For example, an investor may want to invest in an ETF that has a high exposure to the technology sector if they believe that the technology sector is poised for growth.
439
533
  */
440
- async getHoldings(params) {
441
- return this.client.get("/holdings", "v3", params);
534
+ async getSectorWeighting({ symbol }) {
535
+ return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
536
+ }
537
+ /**
538
+ * Get ETF country weighting
539
+ * https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings
540
+ * @param symbol - The symbol of the ETF to get the country weighting for
541
+ * @returns The FMP ETF Country Weighting endpoint provides a breakdown of the percentage of an ETF's assets that are invested in each country. For example, an investor may want to invest in an ETF that has a high exposure to China if they believe that the Chinese economy is poised for growth.
542
+ */
543
+ async getCountryWeighting({ symbol }) {
544
+ return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
545
+ }
546
+ /**
547
+ * Get ETF Stock exposure
548
+ * https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings
549
+ * @param symbol - The symbol of the ETF to get the stock exposure for
550
+ * @returns This endpoint returns asset exposure from all ETFs that have it in their holdings. It has properties like market value, share number or weight percentage. It can be useful for looking up stock you like to check what ETF has it on their portfolio.
551
+ */
552
+ async getStockExposure({ symbol }) {
553
+ return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
442
554
  }
443
555
  };
444
556
 
@@ -449,6 +561,8 @@ var MutualFundEndpoints = class {
449
561
  }
450
562
  /**
451
563
  * Get mutual fund quote
564
+ * @param params - Parameters for the mutual fund quote request
565
+ * @returns Mutual fund quote data
452
566
  */
453
567
  async getQuote(params) {
454
568
  return this.client.get("/quote", "v3", params);
@@ -474,12 +588,18 @@ var BondEndpoints = class {
474
588
  }
475
589
  /**
476
590
  * Get bond quote
591
+ * @param params - Parameters for the bond quote request
592
+ * @returns Bond quote data
477
593
  */
478
594
  async getQuote(params) {
479
595
  return this.client.get("/quote", "v3", params);
480
596
  }
481
597
  /**
482
598
  * Get historical bond prices
599
+ * @param symbol - The bond symbol to get the historical prices for
600
+ * @param from - The start date to get the historical prices for
601
+ * @param to - The end date to get the historical prices for
602
+ * @returns Historical bond price data
483
603
  */
484
604
  async getHistoricalPrice({
485
605
  symbol,
@@ -549,33 +669,41 @@ var MarketEndpoints = class {
549
669
  }
550
670
  /**
551
671
  * Get top gainers
672
+ * https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview
673
+ * @returns The FMP Market Biggest Gainers endpoint provides a list of the stocks that have gained the most value on a given day. This information can be used by investors to identify stocks that are momentum and to potential investment opportunities.
552
674
  */
553
675
  async getGainers() {
554
- return this.client.get("/gainers", "v3");
676
+ return this.client.get("/stock_market/gainers", "v3");
555
677
  }
556
678
  /**
557
679
  * Get top losers
680
+ * https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview
681
+ * @returns The FMP Market Biggest Losers endpoint provides a list of the stocks that have lost the most value on a given day. This information can be used by investors to identify stocks that are underperforming and to potential trading opportunities.
558
682
  */
559
683
  async getLosers() {
560
- return this.client.get("/losers", "v3");
684
+ return this.client.get("/stock_market/losers", "v3");
561
685
  }
562
686
  /**
563
687
  * Get most active stocks
564
688
  */
565
689
  async getMostActive() {
566
- return this.client.get("/most-active", "v3");
690
+ return this.client.get("/stock_market/actives", "v3");
567
691
  }
568
692
  /**
569
693
  * Get sector performance
694
+ * https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview
695
+ * @returns The FMP Sector Performance endpoint provides the performance of each sector of the stock market over a specified period of time. This information can be used by investors to identify sectors that are outperforming or underperforming the market.
570
696
  */
571
697
  async getSectorPerformance() {
572
698
  return this.client.get("/sector-performance", "v3");
573
699
  }
574
700
  /**
575
701
  * Get market indices
702
+ * https://site.financialmodelingprep.com/developer/docs#market-index-market-overview
703
+ * @returns The FMP Market Index endpoint provides a list of all the major stock market indices, such as the S&P 500, the Dow Jones Industrial Average, and the Nasdaq Composite Index. This information can be used by investors to track the performance of the overall stock market and to identify sectors and industries that are outperforming or underperforming the market.
576
704
  */
577
- async getMarketIndex(params = {}) {
578
- return this.client.get("/market-index", "v3", params);
705
+ async getMarketIndex() {
706
+ return this.client.get("/quotes/index", "v3");
579
707
  }
580
708
  };
581
709
 
@@ -712,7 +840,7 @@ var CompanyEndpoints = class {
712
840
  async getCompanyProfile({
713
841
  symbol
714
842
  }) {
715
- return this.client.get(`/profile/${symbol}`, "v3");
843
+ return this.client.getSingle(`/profile/${symbol}`, "v3");
716
844
  }
717
845
  /**
718
846
  * Get executive compensation
@@ -756,11 +884,9 @@ var CompanyEndpoints = class {
756
884
  * @param symbol - The stock symbol to get the shares float for
757
885
  * @returns The FMP Company Share Float endpoint provides the total number of shares that are publicly traded for a given company. This is also known as the company's float. The float is calculated by subtracting the number of restricted shares from the total number of outstanding shares.
758
886
  */
759
- async getSharesFloat({
760
- symbol
761
- }) {
887
+ async getSharesFloat({ symbol }) {
762
888
  const params = { symbol };
763
- return this.client.get(`/shares_float`, "v4", params);
889
+ return this.client.getSingle(`/shares_float`, "v4", params);
764
890
  }
765
891
  /**
766
892
  * Get historical shares float
@@ -788,7 +914,7 @@ var CompanyEndpoints = class {
788
914
  quarter
789
915
  }) {
790
916
  const params = { year, quarter };
791
- return this.client.get(`/earning_call_transcript/${symbol}`, "v3", params);
917
+ return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", params);
792
918
  }
793
919
  };
794
920
 
@@ -799,16 +925,16 @@ var FMP = class {
799
925
  const client = new FMPClient(config);
800
926
  this.stock = new StockEndpoints(client);
801
927
  this.financial = new FinancialEndpoints(client);
802
- this.forex = new ForexEndpoints(client);
803
928
  this.crypto = new CryptoEndpoints(client);
804
929
  this.etf = new ETFEndpoints(client);
805
- this.mutualFund = new MutualFundEndpoints(client);
806
- this.bond = new BondEndpoints(client);
807
- this.economic = new EconomicEndpoints(client);
808
930
  this.market = new MarketEndpoints(client);
809
931
  this.list = new ListEndpoints(client);
810
932
  this.calendar = new CalendarEndpoints(client);
811
933
  this.company = new CompanyEndpoints(client);
934
+ this.forex = new ForexEndpoints(client);
935
+ this.economic = new EconomicEndpoints(client);
936
+ this.bond = new BondEndpoints(client);
937
+ this.mutualFund = new MutualFundEndpoints(client);
812
938
  }
813
939
  /**
814
940
  * Get the underlying client instance for advanced usage