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.js CHANGED
@@ -35,8 +35,26 @@ var FMPClient = class {
35
35
  });
36
36
  return client;
37
37
  }
38
- // Smart routing method
38
+ // Standard get method - returns raw API response
39
39
  async get(endpoint, version = "v3", params) {
40
+ const client = this.getClientForVersion(version);
41
+ try {
42
+ const response = await client.get(endpoint, { params });
43
+ return {
44
+ success: true,
45
+ data: response.data,
46
+ status: response.status
47
+ };
48
+ } catch (error) {
49
+ return {
50
+ success: false,
51
+ error: error.message || "Unknown error occurred",
52
+ status: error.response?.status || 500
53
+ };
54
+ }
55
+ }
56
+ // Get method for single-object endpoints - unwraps single-item arrays
57
+ async getSingle(endpoint, version = "v3", params) {
40
58
  const client = this.getClientForVersion(version);
41
59
  try {
42
60
  const response = await client.get(endpoint, { params });
@@ -135,7 +153,7 @@ var StockEndpoints = class {
135
153
  * @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.
136
154
  */
137
155
  async getQuote({ symbol }) {
138
- return this.client.get(`/quote/${symbol}`, "v3");
156
+ return this.client.getSingle(`/quote/${symbol}`, "v3");
139
157
  }
140
158
  /**
141
159
  * Get historical stock prices
@@ -153,7 +171,7 @@ var StockEndpoints = class {
153
171
  const params = {};
154
172
  if (from) params.from = from;
155
173
  if (to) params.to = to;
156
- return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
174
+ return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
157
175
  }
158
176
  /**
159
177
  * Get market cap
@@ -161,10 +179,8 @@ var StockEndpoints = class {
161
179
  * @param symbol - The stock symbol to get the market cap for
162
180
  * @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.
163
181
  */
164
- async getMarketCap({
165
- symbol
166
- }) {
167
- return this.client.get(`/market-capitalization/${symbol}`, "v3");
182
+ async getMarketCap({ symbol }) {
183
+ return this.client.getSingle(`/market-capitalization/${symbol}`, "v3");
168
184
  }
169
185
  /**
170
186
  * Get stock splits
@@ -172,10 +188,8 @@ var StockEndpoints = class {
172
188
  * @param symbol - The stock symbol to get the splits for
173
189
  * @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.
174
190
  */
175
- async getStockSplits({
176
- symbol
177
- }) {
178
- return this.client.get(`/stock-split-calendar/${symbol}`, "v3");
191
+ async getStockSplits({ symbol }) {
192
+ return this.client.get(`/historical-price-full/stock_split/${symbol}`, "v3");
179
193
  }
180
194
  /**
181
195
  * Get dividend history
@@ -186,7 +200,7 @@ var StockEndpoints = class {
186
200
  async getDividendHistory({
187
201
  symbol
188
202
  }) {
189
- return this.client.get(`/historical-price-full/stock_dividend/${symbol}`, "v3");
203
+ return this.client.getSingle(`/historical-price-full/stock_dividend/${symbol}`, "v3");
190
204
  }
191
205
  };
192
206
 
@@ -216,7 +230,7 @@ var FinancialEndpoints = class {
216
230
  * @param symbol - The stock symbol to get the balance sheet for
217
231
  * @param period - The period to get the balance sheet for (annual or quarter)
218
232
  * @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.
233
+ * @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.
220
234
  */
221
235
  async getBalanceSheet({
222
236
  symbol,
@@ -234,7 +248,7 @@ var FinancialEndpoints = class {
234
248
  * @param symbol - The stock symbol to get the cash flow statement for
235
249
  * @param period - The period to get the cash flow statement for (annual or quarter)
236
250
  * @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.
251
+ * @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
252
  */
239
253
  async getCashFlowStatement({
240
254
  symbol,
@@ -357,6 +371,31 @@ var FinancialEndpoints = class {
357
371
  }) {
358
372
  return this.client.get(`/financial-growth/${symbol}?period=${period}&limit=${limit}`, "v3");
359
373
  }
374
+ /**
375
+ * Get earnings historical
376
+ * https://site.financialmodelingprep.com/developer/docs#earnings-historical-earnings
377
+ * @param symbol - The stock symbol to get the earnings historical for
378
+ * @param limit - The number of periods to get
379
+ * @returns A list of historical & upcoming earnings announcements for a specific company, including the date, estimated EPS, and actual EPS.
380
+ */
381
+ async getEarningsHistorical({
382
+ symbol,
383
+ limit = 5
384
+ }) {
385
+ return this.client.get(`/historical/earning_calendar/${symbol}?limit=${limit}`, "v3");
386
+ }
387
+ /**
388
+ * Get earnings surprises
389
+ * https://site.financialmodelingprep.com/developer/docs#earnings-surprises-earnings
390
+ * @param symbol - The stock symbol to get the earnings surprises for
391
+ * @param limit - The number of periods to get
392
+ * @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.
393
+ */
394
+ async getEarningsSurprises({
395
+ symbol
396
+ }) {
397
+ return this.client.get(`/earnings-surprises/${symbol}`, "v3");
398
+ }
360
399
  };
361
400
 
362
401
  // src/endpoints/forex.ts
@@ -366,12 +405,18 @@ var ForexEndpoints = class {
366
405
  }
367
406
  /**
368
407
  * Get forex quote
408
+ * @param params - Parameters for the forex quote request
409
+ * @returns Forex quote data
369
410
  */
370
411
  async getQuote(params) {
371
412
  return this.client.get("/quote", "v3", params);
372
413
  }
373
414
  /**
374
415
  * Get historical forex prices
416
+ * @param symbol - The forex symbol to get the historical prices for
417
+ * @param from - The start date to get the historical prices for
418
+ * @param to - The end date to get the historical prices for
419
+ * @returns Historical forex price data
375
420
  */
376
421
  async getHistoricalPrice({
377
422
  symbol,
@@ -385,12 +430,15 @@ var ForexEndpoints = class {
385
430
  }
386
431
  /**
387
432
  * Get forex rates for a specific base currency
433
+ * @param baseCurrency - The base currency to get forex rates for
434
+ * @returns Forex rates data
388
435
  */
389
436
  async getForexRates(baseCurrency = "USD") {
390
437
  return this.client.get(`/forex/${baseCurrency}`, "v3");
391
438
  }
392
439
  /**
393
440
  * Get all forex rates
441
+ * @returns All forex rates data
394
442
  */
395
443
  async getAllForexRates() {
396
444
  return this.client.get("/forex", "v3");
@@ -404,12 +452,20 @@ var CryptoEndpoints = class {
404
452
  }
405
453
  /**
406
454
  * Get crypto quote
455
+ * https://site.financialmodelingprep.com/developer/docs#full-quote-crypto
456
+ * @param symbol - The crypto symbol to get the quote for
457
+ * @returns Crypto quote data
407
458
  */
408
- async getQuote(params) {
409
- return this.client.get("/quote", "v3", params);
459
+ async getQuote({ symbol }) {
460
+ return this.client.getSingle(`/quote/${symbol}`, "v3");
410
461
  }
411
462
  /**
412
463
  * Get historical crypto prices
464
+ * https://site.financialmodelingprep.com/developer/docs#cryptocurrency-daily-crypto
465
+ * @param symbol - The crypto symbol to get the historical prices for
466
+ * @param from - The start date to get the historical prices for
467
+ * @param to - The end date to get the historical prices for
468
+ * @returns Provides daily price data for all cryptocurrencies that are traded on exchanges around the world.
413
469
  */
414
470
  async getHistoricalPrice({
415
471
  symbol,
@@ -419,7 +475,7 @@ var CryptoEndpoints = class {
419
475
  const params = {};
420
476
  if (from) params.from = from;
421
477
  if (to) params.to = to;
422
- return this.client.get(`/historical-price-full/${symbol}`, "v3", params);
478
+ return this.client.getSingle(`/historical-price-full/${symbol}`, "v3", params);
423
479
  }
424
480
  };
425
481
 
@@ -429,22 +485,78 @@ var ETFEndpoints = class {
429
485
  this.client = client;
430
486
  }
431
487
  /**
432
- * Get ETF quote
488
+ * Get ETF holding dates
489
+ * https://site.financialmodelingprep.com/developer/docs#etf-holding-dates-etf-holdings
490
+ * @param symbol - The symbol of the ETF to get the holding dates for
491
+ * @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.
433
492
  */
434
- async getQuote(params) {
435
- return this.client.get("/quote", "v3", params);
493
+ async getHoldingDates({ symbol }) {
494
+ const params = {};
495
+ if (symbol) params.symbol = symbol;
496
+ return this.client.get("/etf-holdings/portfolio-date", "v4", params);
497
+ }
498
+ /**
499
+ * Get ETF holdings
500
+ * https://site.financialmodelingprep.com/developer/docs#etf-holdings-etf-holdings
501
+ * @param symbol - The symbol of the ETF to get the holdings for
502
+ * @param date - The date to get the holdings for
503
+ * @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.
504
+ */
505
+ async getHoldings({
506
+ symbol,
507
+ date
508
+ }) {
509
+ const params = {};
510
+ if (symbol) params.symbol = symbol;
511
+ if (date) params.date = date;
512
+ return this.client.get("/etf-holdings", "v4", params);
513
+ }
514
+ /**
515
+ * Get ETF holder
516
+ * https://site.financialmodelingprep.com/developer/docs#etf-holder-etf-holdings
517
+ * @param symbol - The symbol of the ETF to get the holder for
518
+ * @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.
519
+ */
520
+ async getHolder({ symbol }) {
521
+ return this.client.get(`/etf-holder/${symbol}`, "v3");
436
522
  }
437
523
  /**
438
524
  * Get ETF profile
525
+ * https://site.financialmodelingprep.com/developer/docs#etf-information-etf-holdings
526
+ * @param symbol - The symbol of the ETF to get the profile for
527
+ * @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.
439
528
  */
440
- async getProfile(params) {
441
- return this.client.get("/profile", "v3", params);
529
+ async getProfile({ symbol }) {
530
+ const params = {};
531
+ if (symbol) params.symbol = symbol;
532
+ return this.client.getSingle("/etf-info", "v4", params);
442
533
  }
443
534
  /**
444
- * Get ETF holdings
535
+ * Get ETF sector weighting
536
+ * https://site.financialmodelingprep.com/developer/docs#etf-sector-weighting-etf-holdings
537
+ * @param symbol - The symbol of the ETF to get the sector exposure for
538
+ * @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.
445
539
  */
446
- async getHoldings(params) {
447
- return this.client.get("/holdings", "v3", params);
540
+ async getSectorWeighting({ symbol }) {
541
+ return this.client.get(`/etf-sector-weightings/${symbol}`, "v3");
542
+ }
543
+ /**
544
+ * Get ETF country weighting
545
+ * https://site.financialmodelingprep.com/developer/docs#etf-country-weighting-etf-holdings
546
+ * @param symbol - The symbol of the ETF to get the country weighting for
547
+ * @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.
548
+ */
549
+ async getCountryWeighting({ symbol }) {
550
+ return this.client.get(`/etf-country-weightings/${symbol}`, "v3");
551
+ }
552
+ /**
553
+ * Get ETF Stock exposure
554
+ * https://site.financialmodelingprep.com/developer/docs#etf-sector-exposure-etf-holdings
555
+ * @param symbol - The symbol of the ETF to get the stock exposure for
556
+ * @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.
557
+ */
558
+ async getStockExposure({ symbol }) {
559
+ return this.client.get(`/etf-stock-exposure/${symbol}`, "v3");
448
560
  }
449
561
  };
450
562
 
@@ -455,6 +567,8 @@ var MutualFundEndpoints = class {
455
567
  }
456
568
  /**
457
569
  * Get mutual fund quote
570
+ * @param params - Parameters for the mutual fund quote request
571
+ * @returns Mutual fund quote data
458
572
  */
459
573
  async getQuote(params) {
460
574
  return this.client.get("/quote", "v3", params);
@@ -480,12 +594,18 @@ var BondEndpoints = class {
480
594
  }
481
595
  /**
482
596
  * Get bond quote
597
+ * @param params - Parameters for the bond quote request
598
+ * @returns Bond quote data
483
599
  */
484
600
  async getQuote(params) {
485
601
  return this.client.get("/quote", "v3", params);
486
602
  }
487
603
  /**
488
604
  * Get historical bond prices
605
+ * @param symbol - The bond symbol to get the historical prices for
606
+ * @param from - The start date to get the historical prices for
607
+ * @param to - The end date to get the historical prices for
608
+ * @returns Historical bond price data
489
609
  */
490
610
  async getHistoricalPrice({
491
611
  symbol,
@@ -555,33 +675,41 @@ var MarketEndpoints = class {
555
675
  }
556
676
  /**
557
677
  * Get top gainers
678
+ * https://site.financialmodelingprep.com/developer/docs#market-biggest-gainers-market-overview
679
+ * @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.
558
680
  */
559
681
  async getGainers() {
560
- return this.client.get("/gainers", "v3");
682
+ return this.client.get("/stock_market/gainers", "v3");
561
683
  }
562
684
  /**
563
685
  * Get top losers
686
+ * https://site.financialmodelingprep.com/developer/docs#market-biggest-losers-market-overview
687
+ * @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.
564
688
  */
565
689
  async getLosers() {
566
- return this.client.get("/losers", "v3");
690
+ return this.client.get("/stock_market/losers", "v3");
567
691
  }
568
692
  /**
569
693
  * Get most active stocks
570
694
  */
571
695
  async getMostActive() {
572
- return this.client.get("/most-active", "v3");
696
+ return this.client.get("/stock_market/actives", "v3");
573
697
  }
574
698
  /**
575
699
  * Get sector performance
700
+ * https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview
701
+ * @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.
576
702
  */
577
703
  async getSectorPerformance() {
578
704
  return this.client.get("/sector-performance", "v3");
579
705
  }
580
706
  /**
581
707
  * Get market indices
708
+ * https://site.financialmodelingprep.com/developer/docs#market-index-market-overview
709
+ * @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.
582
710
  */
583
- async getMarketIndex(params = {}) {
584
- return this.client.get("/market-index", "v3", params);
711
+ async getMarketIndex() {
712
+ return this.client.get("/quotes/index", "v3");
585
713
  }
586
714
  };
587
715
 
@@ -718,7 +846,7 @@ var CompanyEndpoints = class {
718
846
  async getCompanyProfile({
719
847
  symbol
720
848
  }) {
721
- return this.client.get(`/profile/${symbol}`, "v3");
849
+ return this.client.getSingle(`/profile/${symbol}`, "v3");
722
850
  }
723
851
  /**
724
852
  * Get executive compensation
@@ -762,11 +890,9 @@ var CompanyEndpoints = class {
762
890
  * @param symbol - The stock symbol to get the shares float for
763
891
  * @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
892
  */
765
- async getSharesFloat({
766
- symbol
767
- }) {
893
+ async getSharesFloat({ symbol }) {
768
894
  const params = { symbol };
769
- return this.client.get(`/shares_float`, "v4", params);
895
+ return this.client.getSingle(`/shares_float`, "v4", params);
770
896
  }
771
897
  /**
772
898
  * Get historical shares float
@@ -794,7 +920,7 @@ var CompanyEndpoints = class {
794
920
  quarter
795
921
  }) {
796
922
  const params = { year, quarter };
797
- return this.client.get(`/earning_call_transcript/${symbol}`, "v3", params);
923
+ return this.client.getSingle(`/earning_call_transcript/${symbol}`, "v3", params);
798
924
  }
799
925
  };
800
926
 
@@ -805,16 +931,16 @@ var FMP = class {
805
931
  const client = new FMPClient(config);
806
932
  this.stock = new StockEndpoints(client);
807
933
  this.financial = new FinancialEndpoints(client);
808
- this.forex = new ForexEndpoints(client);
809
934
  this.crypto = new CryptoEndpoints(client);
810
935
  this.etf = new ETFEndpoints(client);
811
- this.mutualFund = new MutualFundEndpoints(client);
812
- this.bond = new BondEndpoints(client);
813
- this.economic = new EconomicEndpoints(client);
814
936
  this.market = new MarketEndpoints(client);
815
937
  this.list = new ListEndpoints(client);
816
938
  this.calendar = new CalendarEndpoints(client);
817
939
  this.company = new CompanyEndpoints(client);
940
+ this.forex = new ForexEndpoints(client);
941
+ this.economic = new EconomicEndpoints(client);
942
+ this.bond = new BondEndpoints(client);
943
+ this.mutualFund = new MutualFundEndpoints(client);
818
944
  }
819
945
  /**
820
946
  * Get the underlying client instance for advanced usage