fmp-node-api 0.2.1 → 0.2.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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { FMPConfig, APIResponse, EarningsCalendar, EarningsConfirmed, DividendsCalendar, EconomicsCalendar, IPOCalendar, SplitsCalendar, CompanyProfile, ExecutiveCompensation, CompanyNotes, HistoricalEmployeeCount, SharesFloat, HistoricalSharesFloat, EarningsCallTranscript, CompanyTranscriptData, StockPeer, TreasuryRate, EconomicIndicator, ETFHoldingDates, ETFHolding, ETFHolder, ETFProfile, ETFWeighting, ETFCountryWeighting, ETFStockExposure, IncomeStatement, BalanceSheet, CashFlowStatement, KeyMetrics, FinancialRatios, EnterpriseValue, CashflowGrowth, IncomeGrowth, BalanceSheetGrowth, FinancialGrowth, EarningsHistorical, EarningsSurprises, FinancialScores, KeyMetricsTTM, FinancialRatiosTTM, RevenueProductSegmentation, RevenueGeographicSegmentation, InsiderTradingRSSResponse, InsiderTradingSearchResponse, TransactionTypesResponse, InsidersBySymbolResponse, InsiderTradeStatisticsResponse, CikMapperResponse, CikMapperBySymbolResponse, BeneficialOwnershipResponse, FailToDeliverResponse, TransactionType, Form13FResponse, InstitutionalHolderResponse, StockList, ETFList, CryptoList, ForexList, AvailableIndexesList, MarketHours, MarketIndex, MarketPerformance, MarketSectorPerformance, MutualFundHolding, Article, News, Quote, HistoricalPriceResponse, IntradayPrice, ScreenerParams, Screener, AvailableExchanges, AvailableSectors, AvailableIndustries, AvailableCountries, SearchResult, AnalystEstimate, PriceTargetConsensus, PriceTargetSummary, StockGrade, GradesConsensus, DCFValuation, CompanyRating, TechnicalIndicator, RSSFeedItem, RSSFeedAllItem, RSSFeedV3Item, RSSFeed8KItem, SECFiling, IndustryClassification, IndustryClassificationCode, SenateTradingResponse, SenateHouseTradingByNameResponse, HouseTradingResponse, MarketCap, StockSplitResponse, StockDividendResponse, StockRealTimePrice, StockRealTimePriceFull, FMPErrorType } from './types-only.js';
2
- export { AnalystEstimateSchema, ArticleSchema, AvailableCountriesSchema, AvailableExchangesSchema, AvailableIndexesListSchema, AvailableIndustriesSchema, AvailableSectorsSchema, BalanceSheetGrowthSchema, BalanceSheetSchema, BeneficialOwnershipResponseSchema, CashFlowStatementSchema, CashflowGrowthSchema, CikMapperBySymbolResponseSchema, CikMapperResponseSchema, CompaniesPriceListResponse, CompanyNotesSchema, CompanyProfileSchema, CompanyRatingSchema, CompanyTranscriptDataSchema, CryptoListSchema, DCFValuationSchema, DateRangeParams, DividendsCalendarSchema, ETFCountryWeightingSchema, ETFHolderSchema, ETFHoldingDatesSchema, ETFHoldingSchema, ETFListSchema, ETFProfileSchema, ETFStockExposureSchema, ETFWeightingSchema, EarningsCalendarSchema, EarningsCallTranscriptSchema, EarningsConfirmedSchema, EarningsHistoricalSchema, EarningsSurprisesSchema, EconomicIndicatorName, EconomicIndicatorNameSchema, EconomicIndicatorSchema, EconomicsCalendarSchema, EnterpriseValueSchema, Exchange, ExecutiveCompensationSchema, FailToDeliverResponseSchema, FinancialGrowthSchema, FinancialRatiosSchema, FinancialRatiosTTMSchema, FinancialScoresSchema, ForexListSchema, Form13FResponseSchema, GradesConsensusSchema, HistoricalEmployeeCountSchema, HistoricalPriceData, HistoricalPriceDataSchema, HistoricalPriceResponseSchema, HistoricalSharesFloatSchema, HouseTradingResponseSchema, IPOCalendarSchema, IncomeGrowthSchema, IncomeStatementSchema, IndividualIndustryClassificationParams, IndividualIndustryClassificationParamsSchema, IndustryClassificationCodeSchema, IndustryClassificationCodesParams, IndustryClassificationCodesParamsSchema, IndustryClassificationSchema, InsiderTradeStatisticsResponseSchema, InsiderTradingRSSResponseSchema, InsiderTradingSearchResponseSchema, InsidersBySymbolResponseSchema, InstitutionalHolderResponseSchema, IntradayPriceSchema, KeyMetricsSchema, KeyMetricsTTMSchema, MarketCapSchema, MarketHoliday, MarketHolidaySchema, MarketHoursSchema, MarketIndexSchema, MarketPerformanceSchema, MarketSectorPerformanceSchema, MutualFundHoldingSchema, NewsSchema, PaginationParams, Period, PeriodParams, PriceTargetConsensusSchema, PriceTargetSummarySchema, QueryParams, QuoteSchema, RSSFeed8KItemSchema, RSSFeed8KParams, RSSFeed8KParamsSchema, RSSFeedAllItemSchema, RSSFeedItemSchema, RSSFeedParams, RSSFeedParamsSchema, RSSFeedV3ItemSchema, RSSFeedV3Params, RSSFeedV3ParamsSchema, RevenueGeographicSegmentationSchema, RevenueProductSegmentationSchema, RevenueSegmentationSchema, SECFilingSchema, SECFilingsParams, SECFilingsParamsSchema, ScreenerParamsSchema, ScreenerSchema, SearchResultSchema, SenateHouseTradingByNameResponseSchema, SenateTradingResponseSchema, SharesFloatSchema, SplitsCalendarSchema, StockDividend, StockDividendResponseSchema, StockDividendSchema, StockGradeSchema, StockListResponse, StockListSchema, StockPeerSchema, StockRealTimePriceFullSchema, StockRealTimePriceSchema, StockSplit, StockSplitResponseSchema, StockSplitSchema, SymbolParams, TechnicalIndicatorSchema, TransactionTypeRecordSchema, TreasuryRateSchema } from './types-only.js';
1
+ import { FMPConfig, APIResponse, EarningsCalendar, EarningsConfirmed, DividendsCalendar, EconomicsCalendar, IPOCalendar, SplitsCalendar, CompanyProfile, ExecutiveCompensation, CompanyNotes, HistoricalEmployeeCount, SharesFloat, HistoricalSharesFloat, EarningsCallTranscript, CompanyTranscriptData, StockPeer, TreasuryRate, EconomicIndicator, ETFHoldingDates, ETFHolding, ETFHolder, ETFProfile, ETFWeighting, ETFCountryWeighting, ETFStockExposure, IncomeStatement, BalanceSheet, CashFlowStatement, KeyMetrics, FinancialRatios, EnterpriseValue, CashflowGrowth, IncomeGrowth, BalanceSheetGrowth, FinancialGrowth, EarningsHistorical, EarningsSurprises, FinancialScores, KeyMetricsTTM, FinancialRatiosTTM, RevenueProductSegmentation, RevenueGeographicSegmentation, InsiderTradingRSSResponse, InsiderTradingSearchResponse, TransactionTypesResponse, InsidersBySymbolResponse, InsiderTradeStatisticsResponse, CikMapperResponse, CikMapperBySymbolResponse, BeneficialOwnershipResponse, FailToDeliverResponse, TransactionType, Form13FResponse, InstitutionalHolderResponse, StockList, ETFList, CryptoList, ForexList, AvailableIndexesList, ExchangeMarketHours, MarketIndex, MarketPerformance, MarketSectorPerformance, IndustryPESnapshot, MutualFundHolding, Article, News, Quote, QuoteShort, HistoricalPriceResponse, IntradayPrice, ScreenerParams, Screener, AvailableExchanges, AvailableSectors, AvailableIndustries, AvailableCountries, SearchResult, AnalystEstimate, PriceTargetConsensus, PriceTargetSummary, StockGrade, GradesConsensus, DCFValuation, CompanyRating, TechnicalIndicator, RSSFeedItem, RSSFeedAllItem, RSSFeedV3Item, RSSFeed8KItem, SECFiling, IndustryClassification, IndustryClassificationCode, SenateTradingResponse, SenateHouseTradingByNameResponse, HouseTradingResponse, MarketCap, StockPriceChange, StockSplitResponse, StockDividendResponse, StockRealTimePrice, StockRealTimePriceFull, AftermarketTrade, AftermarketQuote, FMPErrorType } from './types-only.js';
2
+ export { AftermarketQuoteSchema, AftermarketTradeSchema, AnalystEstimateSchema, ArticleSchema, AvailableCountriesSchema, AvailableExchangesSchema, AvailableIndexesListSchema, AvailableIndustriesSchema, AvailableSectorsSchema, BalanceSheetGrowthSchema, BalanceSheetSchema, BeneficialOwnershipResponseSchema, CashFlowStatementSchema, CashflowGrowthSchema, CikMapperBySymbolResponseSchema, CikMapperResponseSchema, CompaniesPriceListResponse, CompanyNotesSchema, CompanyProfileSchema, CompanyRatingSchema, CompanyTranscriptDataSchema, CryptoListSchema, DCFValuationSchema, DateRangeParams, DividendsCalendarSchema, ETFCountryWeightingSchema, ETFHolderSchema, ETFHoldingDatesSchema, ETFHoldingSchema, ETFListSchema, ETFProfileSchema, ETFStockExposureSchema, ETFWeightingSchema, EarningsCalendarSchema, EarningsCallTranscriptSchema, EarningsConfirmedSchema, EarningsHistoricalSchema, EarningsSurprisesSchema, EconomicIndicatorName, EconomicIndicatorNameSchema, EconomicIndicatorSchema, EconomicsCalendarSchema, EnterpriseValueSchema, Exchange, ExchangeMarketHoursSchema, ExecutiveCompensationSchema, FailToDeliverResponseSchema, FinancialGrowthSchema, FinancialRatiosSchema, FinancialRatiosTTMSchema, FinancialScoresSchema, ForexListSchema, Form13FResponseSchema, GradesConsensusSchema, HistoricalEmployeeCountSchema, HistoricalPriceData, HistoricalPriceDataSchema, HistoricalPriceResponseSchema, HistoricalSharesFloatSchema, HouseTradingResponseSchema, IPOCalendarSchema, IncomeGrowthSchema, IncomeStatementSchema, IndividualIndustryClassificationParams, IndividualIndustryClassificationParamsSchema, IndustryClassificationCodeSchema, IndustryClassificationCodesParams, IndustryClassificationCodesParamsSchema, IndustryClassificationSchema, IndustryPESnapshotSchema, InsiderTradeStatisticsResponseSchema, InsiderTradingRSSResponseSchema, InsiderTradingSearchResponseSchema, InsidersBySymbolResponseSchema, InstitutionalHolderResponseSchema, IntradayPriceSchema, KeyMetricsSchema, KeyMetricsTTMSchema, MarketCapSchema, MarketIndexSchema, MarketPerformanceSchema, MarketSectorPerformanceSchema, MutualFundHoldingSchema, NewsSchema, PaginationParams, Period, PeriodParams, PriceTargetConsensusSchema, PriceTargetSummarySchema, QueryParams, QuoteSchema, QuoteShortSchema, RSSFeed8KItemSchema, RSSFeed8KParams, RSSFeed8KParamsSchema, RSSFeedAllItemSchema, RSSFeedItemSchema, RSSFeedParams, RSSFeedParamsSchema, RSSFeedV3ItemSchema, RSSFeedV3Params, RSSFeedV3ParamsSchema, RevenueGeographicSegmentationSchema, RevenueProductSegmentationSchema, RevenueSegmentationSchema, SECFilingSchema, SECFilingsParams, SECFilingsParamsSchema, ScreenerParamsSchema, ScreenerSchema, SearchResultSchema, SenateHouseTradingByNameResponseSchema, SenateTradingResponseSchema, SharesFloatSchema, SplitsCalendarSchema, StockDividend, StockDividendResponseSchema, StockDividendSchema, StockGradeSchema, StockListResponse, StockListSchema, StockPeerSchema, StockPriceChangeSchema, StockRealTimePriceFullSchema, StockRealTimePriceSchema, StockSplit, StockSplitResponseSchema, StockSplitSchema, SymbolParams, TechnicalIndicatorSchema, TransactionTypeRecordSchema, TreasuryRateSchema } from './types-only.js';
3
3
  export { FMPValidation } from './utils/validation.js';
4
4
  import 'zod';
5
5
 
@@ -1961,34 +1961,31 @@ declare class MarketEndpoints {
1961
1961
  private client;
1962
1962
  constructor(client: FMPClient);
1963
1963
  /**
1964
- * Get current market hours and trading status
1964
+ * Get trading hours and current open/closed status for all exchanges
1965
1965
  *
1966
- * Provides real-time information about market trading hours, including
1967
- * whether markets are currently open or closed, trading session times,
1968
- * and upcoming market holidays. Essential for determining trading
1969
- * availability and market status.
1966
+ * Returns one record per supported exchange (NYSE, NASDAQ, LSE, etc.) with its
1967
+ * opening/closing hours, timezone, and whether it is currently open. Essential
1968
+ * for determining trading availability across global markets.
1970
1969
  *
1971
- * @returns Promise resolving to market hours data with trading status and session information
1970
+ * @returns Promise resolving to an array of per-exchange market-hours records
1972
1971
  *
1973
1972
  * @example
1974
1973
  * ```typescript
1975
- * // Get current market status
1976
- * const marketHours = await fmp.market.getMarketHours();
1977
- * console.log(`Market is ${marketHours.data.isTheStockMarketOpen ? 'OPEN' : 'CLOSED'}`);
1978
- * console.log(`Current time: ${marketHours.data.currentTime}`);
1979
- * console.log(`Next trading day: ${marketHours.data.nextTradingDay}`);
1974
+ * // Get market status for every exchange
1975
+ * const hours = await fmp.market.getMarketHours();
1980
1976
  *
1981
- * // Check if it's a trading day
1982
- * if (marketHours.data.isTheStockMarketOpen) {
1983
- * console.log('Markets are currently open for trading');
1984
- * } else {
1985
- * console.log('Markets are closed');
1986
- * }
1977
+ * // Check whether the NASDAQ is currently open
1978
+ * const nasdaq = hours.data.find(e => e.exchange === 'NASDAQ');
1979
+ * console.log(`NASDAQ is ${nasdaq?.isMarketOpen ? 'OPEN' : 'CLOSED'}`);
1980
+ *
1981
+ * // List all currently-open exchanges
1982
+ * const open = hours.data.filter(e => e.isMarketOpen).map(e => e.exchange);
1983
+ * console.log(`Open now: ${open.join(', ')}`);
1987
1984
  * ```
1988
1985
  *
1989
- * @see {@link https://site.financialmodelingprep.com/developer/docs#market-hours|FMP Market Hours Documentation}
1986
+ * @see {@link https://site.financialmodelingprep.com/developer/docs/stable/all-exchange-market-hours|FMP Exchange Market Hours Documentation}
1990
1987
  */
1991
- getMarketHours(): Promise<APIResponse<MarketHours>>;
1988
+ getMarketHours(): Promise<APIResponse<ExchangeMarketHours[]>>;
1992
1989
  /**
1993
1990
  * Get overall market performance data
1994
1991
  *
@@ -2138,54 +2135,64 @@ declare class MarketEndpoints {
2138
2135
  */
2139
2136
  getMostActive(): Promise<APIResponse<MarketPerformance[]>>;
2140
2137
  /**
2141
- * Get sector performance data for the current trading day
2138
+ * Get a sector-performance snapshot for a given date
2139
+ *
2140
+ * Returns the average price change per sector for the requested date, broken
2141
+ * out by exchange. Essential for sector-rotation analysis and identifying
2142
+ * leading/lagging sectors. A `date` is required (YYYY-MM-DD).
2142
2143
  *
2143
- * Provides performance data for all major market sectors including
2144
- * technology, healthcare, financials, energy, and others. Essential for
2145
- * sector rotation analysis, identifying leading/lagging sectors, and
2146
- * understanding market breadth and sector-specific trends.
2144
+ * @param params - Snapshot parameters
2145
+ * @param params.date - The date to snapshot, in YYYY-MM-DD format (required)
2146
+ * @param params.exchange - Optional exchange filter (e.g. 'NASDAQ', 'NYSE')
2147
+ * @param params.sector - Optional sector filter (e.g. 'Technology')
2147
2148
  *
2148
- * @returns Promise resolving to array of sector performance data with percentage changes
2149
+ * @returns Promise resolving to an array of per-sector average changes
2149
2150
  *
2150
2151
  * @example
2151
2152
  * ```typescript
2152
- * // Get sector performance for the day
2153
- * const sectorPerformance = await fmp.market.getSectorPerformance();
2154
- * console.log(`Sector performance for ${sectorPerformance.data.length} sectors:`);
2155
- *
2156
- * sectorPerformance.data.forEach(sector => {
2157
- * const changeColor = sector.changesPercentage >= 0 ? 'green' : 'red';
2158
- * console.log(`${sector.sector}: ${sector.changesPercentage}%`);
2159
- * console.log(` Change: ${sector.changesPercentage >= 0 ? '+' : ''}${sector.changesPercentage}%`);
2153
+ * const snapshot = await fmp.market.getSectorPerformance({ date: '2024-06-10' });
2154
+ * snapshot.data.forEach(s => {
2155
+ * console.log(`${s.sector} (${s.exchange}): ${s.averageChange.toFixed(2)}%`);
2160
2156
  * });
2161
2157
  *
2162
- * // Find best performing sectors
2163
- * const topSectors = sectorPerformance.data
2164
- * .sort((a, b) => b.changesPercentage - a.changesPercentage)
2165
- * .slice(0, 3);
2166
- * console.log('Top 3 performing sectors:');
2167
- * topSectors.forEach((sector, index) => {
2168
- * console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
2169
- * });
2158
+ * // Filter to a single exchange
2159
+ * const nyse = await fmp.market.getSectorPerformance({ date: '2024-06-10', exchange: 'NYSE' });
2160
+ * ```
2170
2161
  *
2171
- * // Find worst performing sectors
2172
- * const bottomSectors = sectorPerformance.data
2173
- * .sort((a, b) => a.changesPercentage - b.changesPercentage)
2174
- * .slice(0, 3);
2175
- * console.log('Bottom 3 performing sectors:');
2176
- * bottomSectors.forEach((sector, index) => {
2177
- * console.log(`${index + 1}. ${sector.sector}: ${sector.changesPercentage}%`);
2178
- * });
2162
+ * @see {@link https://site.financialmodelingprep.com/developer/docs/stable/sector-performance-snapshot|FMP Sector Performance Snapshot Documentation}
2163
+ */
2164
+ getSectorPerformance(params: {
2165
+ date: string;
2166
+ exchange?: string;
2167
+ sector?: string;
2168
+ }): Promise<APIResponse<MarketSectorPerformance[]>>;
2169
+ /**
2170
+ * Get an industry P/E snapshot for a given date
2171
+ *
2172
+ * Returns the average price-to-earnings ratio per industry for the requested
2173
+ * date, broken out by exchange. Useful for relative-valuation analysis across
2174
+ * industries. A `date` is required (YYYY-MM-DD).
2175
+ *
2176
+ * @param params - Snapshot parameters
2177
+ * @param params.date - The date to snapshot, in YYYY-MM-DD format (required)
2178
+ * @param params.exchange - Optional exchange filter (e.g. 'NASDAQ', 'NYSE')
2179
+ * @param params.industry - Optional industry filter (e.g. 'Software')
2179
2180
  *
2180
- * // Check for sector rotation
2181
- * const gainingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage > 0);
2182
- * const losingSectors = sectorPerformance.data.filter(sector => sector.changesPercentage < 0);
2183
- * console.log(`Sectors gaining: ${gainingSectors.length}, Sectors losing: ${losingSectors.length}`);
2181
+ * @returns Promise resolving to an array of per-industry P/E ratios
2182
+ *
2183
+ * @example
2184
+ * ```typescript
2185
+ * const pe = await fmp.market.getIndustryPESnapshot({ date: '2024-06-10' });
2186
+ * pe.data.forEach(i => console.log(`${i.industry} (${i.exchange}): ${i.pe.toFixed(1)}`));
2184
2187
  * ```
2185
2188
  *
2186
- * @see {@link https://site.financialmodelingprep.com/developer/docs#sector-performance-market-overview|FMP Sector Performance Documentation}
2189
+ * @see {@link https://site.financialmodelingprep.com/developer/docs/stable/industry-pe-snapshot|FMP Industry PE Snapshot Documentation}
2187
2190
  */
2188
- getSectorPerformance(): Promise<APIResponse<MarketSectorPerformance[]>>;
2191
+ getIndustryPESnapshot(params: {
2192
+ date: string;
2193
+ exchange?: string;
2194
+ industry?: string;
2195
+ }): Promise<APIResponse<IndustryPESnapshot[]>>;
2189
2196
  /**
2190
2197
  * Get real-time data for major market indices
2191
2198
  *
@@ -2590,6 +2597,23 @@ declare class QuoteEndpoints {
2590
2597
  * ```
2591
2598
  */
2592
2599
  getQuote(symbol: string): Promise<APIResponse<Quote>>;
2600
+ /**
2601
+ * Get a short real-time quote for any asset type (stocks, crypto, forex, commodities, ETFs)
2602
+ *
2603
+ * A lean alternative to {@link getQuote} returning only price, change, and volume.
2604
+ * Lighter on bandwidth — useful for frequent polling or large symbol sweeps.
2605
+ *
2606
+ * @param symbol - The trading symbol (e.g., 'AAPL', 'BTCUSD', 'EURUSD')
2607
+ *
2608
+ * @returns Promise resolving to a short quote with price, change, and volume
2609
+ *
2610
+ * @example
2611
+ * ```typescript
2612
+ * const shortQuote = await fmp.quote.getQuoteShort('AAPL');
2613
+ * console.log(`${shortQuote.data.price} (${shortQuote.data.change})`);
2614
+ * ```
2615
+ */
2616
+ getQuoteShort(symbol: string): Promise<APIResponse<QuoteShort>>;
2593
2617
  /**
2594
2618
  * Get historical price data for any asset type with customizable date range
2595
2619
  *
@@ -3462,6 +3486,23 @@ declare class StockEndpoints {
3462
3486
  * @see {@link https://site.financialmodelingprep.com/developer/docs#market-cap-company-information|FMP Market Cap Documentation}
3463
3487
  */
3464
3488
  getMarketCap(symbol: string): Promise<APIResponse<MarketCap>>;
3489
+ /**
3490
+ * Get the percentage price change for a stock across standard horizons
3491
+ *
3492
+ * Returns price change percentages over 1D, 5D, 1M, 3M, 6M, YTD, 1Y, 3Y, 5Y,
3493
+ * 10Y, and max ranges in a single call. Handy for performance summaries.
3494
+ *
3495
+ * @param symbol - The stock symbol (e.g., 'AAPL')
3496
+ *
3497
+ * @returns Promise resolving to price-change percentages across horizons
3498
+ *
3499
+ * @example
3500
+ * ```typescript
3501
+ * const change = await fmp.stock.getPriceChange('AAPL');
3502
+ * console.log(`YTD: ${change.data.ytd}% | 1Y: ${change.data['1Y']}%`);
3503
+ * ```
3504
+ */
3505
+ getPriceChange(symbol: string): Promise<APIResponse<StockPriceChange>>;
3465
3506
  /**
3466
3507
  * Get historical stock splits for a company
3467
3508
  *
@@ -3576,6 +3617,45 @@ declare class StockEndpoints {
3576
3617
  getRealTimePriceForMultipleStocks(symbols: string[]): Promise<APIResponse<StockRealTimePriceFull[]>>;
3577
3618
  }
3578
3619
 
3620
+ declare class AftermarketEndpoints {
3621
+ private client;
3622
+ constructor(client: FMPClient);
3623
+ /**
3624
+ * Get the latest extended-hours (pre/post-market) trade for a symbol
3625
+ *
3626
+ * Returns the most recent aftermarket trade including price, trade size, and
3627
+ * timestamp. Useful for tracking price action outside regular trading hours.
3628
+ *
3629
+ * @param symbol - The stock symbol (e.g., 'AAPL')
3630
+ *
3631
+ * @returns Promise resolving to the latest aftermarket trade
3632
+ *
3633
+ * @example
3634
+ * ```typescript
3635
+ * const trade = await fmp.aftermarket.getTrade('AAPL');
3636
+ * console.log(`Last aftermarket trade: $${trade.data.price} x ${trade.data.tradeSize}`);
3637
+ * ```
3638
+ */
3639
+ getTrade(symbol: string): Promise<APIResponse<AftermarketTrade>>;
3640
+ /**
3641
+ * Get the latest extended-hours (pre/post-market) bid/ask quote for a symbol
3642
+ *
3643
+ * Returns the most recent aftermarket quote including bid/ask prices and sizes,
3644
+ * volume, and timestamp. Useful for monitoring extended-hours liquidity.
3645
+ *
3646
+ * @param symbol - The stock symbol (e.g., 'AAPL')
3647
+ *
3648
+ * @returns Promise resolving to the latest aftermarket quote
3649
+ *
3650
+ * @example
3651
+ * ```typescript
3652
+ * const quote = await fmp.aftermarket.getQuote('AAPL');
3653
+ * console.log(`Bid ${quote.data.bidPrice} / Ask ${quote.data.askPrice}`);
3654
+ * ```
3655
+ */
3656
+ getQuote(symbol: string): Promise<APIResponse<AftermarketQuote>>;
3657
+ }
3658
+
3579
3659
  /**
3580
3660
  * Main FMP API client that provides access to all endpoints
3581
3661
  *
@@ -3627,6 +3707,7 @@ declare class FMP {
3627
3707
  readonly sec: SECEndpoints;
3628
3708
  readonly senateHouse: SenateHouseEndpoints;
3629
3709
  readonly stock: StockEndpoints;
3710
+ readonly aftermarket: AftermarketEndpoints;
3630
3711
  constructor(config?: FMPConfig);
3631
3712
  /**
3632
3713
  * Get the underlying client instance for advanced usage
@@ -3706,4 +3787,4 @@ declare class FMPError extends Error {
3706
3787
  constructor(message: string, status?: number | undefined, code?: string | undefined);
3707
3788
  }
3708
3789
 
3709
- export { APIResponse, AnalystEndpoints, AnalystEstimate, Article, AvailableCountries, AvailableExchanges, AvailableIndexesList, AvailableIndustries, AvailableSectors, BalanceSheet, BalanceSheetGrowth, BeneficialOwnershipResponse, CalendarEndpoints, CashFlowStatement, CashflowGrowth, CikMapperBySymbolResponse, CikMapperResponse, type ClassifiedError, CompanyEndpoints, CompanyNotes, CompanyProfile, CompanyRating, CompanyTranscriptData, CryptoList, DCFValuation, DEFAULT_LIMIT, DEFAULT_TIMEOUT, DividendsCalendar, ETFCountryWeighting, ETFEndpoints, ETFHolder, ETFHolding, ETFHoldingDates, ETFList, ETFProfile, ETFStockExposure, ETFWeighting, EXCHANGES, EarningsCalendar, EarningsCallTranscript, EarningsConfirmed, EarningsHistorical, EarningsSurprises, EconomicEndpoints, EconomicIndicator, EconomicsCalendar, EnterpriseValue, ExecutiveCompensation, FMP, FMPClient, FMPConfig, FMPError, FMPErrorType, FailToDeliverResponse, FinancialEndpoints, FinancialGrowth, FinancialRatios, FinancialRatiosTTM, FinancialScores, ForexList, Form13FResponse, GradesConsensus, HistoricalEmployeeCount, HistoricalPriceResponse, HistoricalSharesFloat, HouseTradingResponse, IPOCalendar, IncomeGrowth, IncomeStatement, IndustryClassification, IndustryClassificationCode, InsiderEndpoints, InsiderTradeStatisticsResponse, InsiderTradingRSSResponse, InsiderTradingSearchResponse, InsidersBySymbolResponse, InstitutionalEndpoints, InstitutionalHolderResponse, IntradayPrice, KeyMetrics, KeyMetricsTTM, ListEndpoints, MAX_LIMIT, MarketCap, MarketEndpoints, MarketHours, MarketIndex, MarketPerformance, MarketSectorPerformance, MutualFundEndpoints, MutualFundHolding, News, NewsEndpoints, PERIODS, PriceTargetConsensus, PriceTargetSummary, Quote, QuoteEndpoints, RSSFeed8KItem, RSSFeedAllItem, RSSFeedItem, RSSFeedV3Item, RevenueGeographicSegmentation, RevenueProductSegmentation, SECEndpoints, SECFiling, SECTORS, Screener, ScreenerEndpoints, ScreenerParams, SearchEndpoints, SearchResult, SenateHouseEndpoints, SenateHouseTradingByNameResponse, SenateTradingResponse, SharesFloat, SplitsCalendar, StockDividendResponse, StockEndpoints, StockGrade, StockList, StockPeer, StockRealTimePrice, StockRealTimePriceFull, StockSplitResponse, TechnicalEndpoints, TechnicalIndicator, TransactionType, TransactionTypesResponse, TreasuryRate, ValuationEndpoints, classifyError, formatCurrency, formatDate, formatLargeNumber, formatPercentage, formatVolume };
3790
+ export { APIResponse, AftermarketEndpoints, AftermarketQuote, AftermarketTrade, AnalystEndpoints, AnalystEstimate, Article, AvailableCountries, AvailableExchanges, AvailableIndexesList, AvailableIndustries, AvailableSectors, BalanceSheet, BalanceSheetGrowth, BeneficialOwnershipResponse, CalendarEndpoints, CashFlowStatement, CashflowGrowth, CikMapperBySymbolResponse, CikMapperResponse, type ClassifiedError, CompanyEndpoints, CompanyNotes, CompanyProfile, CompanyRating, CompanyTranscriptData, CryptoList, DCFValuation, DEFAULT_LIMIT, DEFAULT_TIMEOUT, DividendsCalendar, ETFCountryWeighting, ETFEndpoints, ETFHolder, ETFHolding, ETFHoldingDates, ETFList, ETFProfile, ETFStockExposure, ETFWeighting, EXCHANGES, EarningsCalendar, EarningsCallTranscript, EarningsConfirmed, EarningsHistorical, EarningsSurprises, EconomicEndpoints, EconomicIndicator, EconomicsCalendar, EnterpriseValue, ExchangeMarketHours, ExecutiveCompensation, FMP, FMPClient, FMPConfig, FMPError, FMPErrorType, FailToDeliverResponse, FinancialEndpoints, FinancialGrowth, FinancialRatios, FinancialRatiosTTM, FinancialScores, ForexList, Form13FResponse, GradesConsensus, HistoricalEmployeeCount, HistoricalPriceResponse, HistoricalSharesFloat, HouseTradingResponse, IPOCalendar, IncomeGrowth, IncomeStatement, IndustryClassification, IndustryClassificationCode, IndustryPESnapshot, InsiderEndpoints, InsiderTradeStatisticsResponse, InsiderTradingRSSResponse, InsiderTradingSearchResponse, InsidersBySymbolResponse, InstitutionalEndpoints, InstitutionalHolderResponse, IntradayPrice, KeyMetrics, KeyMetricsTTM, ListEndpoints, MAX_LIMIT, MarketCap, MarketEndpoints, MarketIndex, MarketPerformance, MarketSectorPerformance, MutualFundEndpoints, MutualFundHolding, News, NewsEndpoints, PERIODS, PriceTargetConsensus, PriceTargetSummary, Quote, QuoteEndpoints, QuoteShort, RSSFeed8KItem, RSSFeedAllItem, RSSFeedItem, RSSFeedV3Item, RevenueGeographicSegmentation, RevenueProductSegmentation, SECEndpoints, SECFiling, SECTORS, Screener, ScreenerEndpoints, ScreenerParams, SearchEndpoints, SearchResult, SenateHouseEndpoints, SenateHouseTradingByNameResponse, SenateTradingResponse, SharesFloat, SplitsCalendar, StockDividendResponse, StockEndpoints, StockGrade, StockList, StockPeer, StockPriceChange, StockRealTimePrice, StockRealTimePriceFull, StockSplitResponse, TechnicalEndpoints, TechnicalIndicator, TransactionType, TransactionTypesResponse, TreasuryRate, ValuationEndpoints, classifyError, formatCurrency, formatDate, formatLargeNumber, formatPercentage, formatVolume };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var w=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);var $=[/exclusive endpoint/i,/not available under your current/i,/premium/i,/special endpoint/i,/upgrade your plan/i];function k(n,e){let t=e?.trim()||"Unknown error occurred",s=$.some(r=>r.test(t));return n===429?{errorType:"rate-limit",message:`FMP rate limit reached: ${t}`}:n===401?{errorType:"auth",message:`FMP authentication failed (check your FMP_API_KEY): ${t}`}:n===402||n===403||s?{errorType:"plan-restricted",message:`This endpoint is not available on your current FMP plan. (${n}: ${t})`}:n===404?{errorType:"not-found",message:`Not found: ${t}`}:n===400?{errorType:"bad-request",message:`Invalid request: ${t}`}:n===0?{errorType:"network",message:`Network error: ${t}`}:{errorType:"unknown",message:t}}function N(n){return Array.isArray(n)&&n.length===1?n[0]:n}function _(n){return Array.isArray(n)?n:n??[]}function q(n){return n==null?{}:Array.isArray(n)&&n.length===0?{}:n}var c=class{constructor(e){if(!e.apiKey)throw new Error("API key is required for FMPClient");this.apiKey=e.apiKey,this.v3Client=w__default.default.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=w__default.default.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=w__default.default.create({baseURL:"https://financialmodelingprep.com/stable",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),[this.v3Client,this.v4Client,this.stableClient].forEach(t=>{t.interceptors.request.use(s=>(s.params={...s.params,apikey:this.apiKey},s));});}async get(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s}),o=i.data;return (Array.isArray(o)||o==null)&&(o=_(o)),{success:!0,data:o,error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}async getSingle(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s});return {success:!0,data:q(N(i.data)),error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}buildErrorResponse(e){let t=e?.response?.data,s=t&&typeof t=="object"?t["Error Message"]??t.message??null:typeof t=="string"?t:null,r=e?.response?.status??0,{errorType:i,message:o}=k(r,s||e?.message||"");return {success:false,data:null,error:o,errorType:i,status:r||500}}getClientForVersion(e){switch(e){case "v3":return this.v3Client;case "v4":return this.v4Client;case "stable":return this.stableClient;default:return this.v3Client}}};var m=class{static isValidSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{1,5}$/.test(e)}static isValidCryptoSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(e)}static isValidForexPair(e){return !e||typeof e!="string"?false:/^[A-Z]{3}[A-Z]{3}$/.test(e)}static isValidDate(e){if(!e||typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return false;let s=new Date(e);return !isNaN(s.getTime())&&s.toISOString().split("T")[0]===e}static isValidDateRange(e,t){if(!this.isValidDate(e)||!this.isValidDate(t))return false;let s=new Date(e),r=new Date(t);return s<=r}static isValidResponse(e){return !!(e&&typeof e=="object"&&typeof e.success=="boolean")}static isValidApiKey(e){return !e||typeof e!="string"?false:/^[a-zA-Z0-9]{32,}$/.test(e)}static isValidPeriod(e){return !e||typeof e!="string"?false:["annual","quarter","fy"].includes(e.toLowerCase())}static isValidLimit(e){return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=1e3}static validateQuoteParams(e){let t=[];return e?(e.symbol?!this.isValidSymbol(e.symbol)&&!this.isValidCryptoSymbol(e.symbol)&&!this.isValidForexPair(e.symbol)&&t.push("Invalid symbol format"):t.push("Symbol is required"),e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static validateFinancialParams(e){let t=[];return e?(e.symbol?this.isValidSymbol(e.symbol)||t.push("Invalid symbol format"):t.push("Symbol is required"),e.period&&!this.isValidPeriod(e.period)&&t.push('Invalid period (must be "annual", "quarter", or "FY")'),e.limit&&!this.isValidLimit(e.limit)&&t.push("Invalid limit (must be a positive integer <= 1000)"),t):(t.push("Parameters object is required"),t)}static validateDateRangeParams(e){let t=[];return e?(e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static throwIfInvalid(e,t="Validation"){if(e.length>0)throw new Error(`${t} failed: ${e.join(", ")}`)}};var p=class{constructor(e){this._client=e;}async getEarningsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning_calendar","v3",r)}async getEarningsConfirmed(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning-calendar-confirmed","v4",r)}async getDividendsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_dividend_calendar","v3",r)}async getEconomicsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/economic_calendar","v3",r)}async getIPOCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/ipo_calendar","v3",r)}async getSplitsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_split_calendar","v3",r)}};var g=class{constructor(e){this.client=e;}async getCompanyProfile(e){return this.client.getSingle("/profile","stable",{symbol:e})}async getExecutiveCompensation(e){return this.client.get("/governance-executive-compensation","stable",{symbol:e})}async getCompanyNotes(e){return this.client.get("/company-notes","stable",{symbol:e})}async getHistoricalEmployeeCount(e){return this.client.get("/historical-employee-count","stable",{symbol:e})}async getSharesFloat(e){return this.client.getSingle("/shares-float","stable",{symbol:e})}async getHistoricalSharesFloat(e){return this.client.get("/historical/shares_float","v4",{symbol:e})}async getEarningsCallTranscript(e){let{symbol:t,year:s,quarter:r}=e;return this.client.getSingle(`/earning_call_transcript/${t}`,"v3",{year:s,quarter:r})}async getCompanyTranscriptData(e){return this.client.getSingle("/earning_call_transcript","v4",{symbol:e})}async getStockPeers(e){return this.client.get("/stock-peers","stable",{symbol:e})}};var u=class{constructor(e){this.client=e;}async getTreasuryRates(e){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this.client.get("/treasury-rates","stable",r)}async getEconomicIndicators(e){let{name:t,from:s,to:r}=e,i={name:t};return s&&(i.from=s),r&&(i.to=r),this.client.get("/economic-indicators","stable",i)}};var y=class{constructor(e){this.client=e;}async getHoldingDates(e){return this.client.get("/etf-holdings/portfolio-date","v4",{symbol:e})}async getHoldings(e){let{symbol:t,date:s}=e,r={};return t&&(r.symbol=t),s&&(r.date=s),this.client.get("/etf-holdings","v4",r)}async getHolder(e){return this.client.get(`/etf-holder/${e}`,"v3")}async getProfile(e){return this.client.getSingle("/etf/info","stable",{symbol:e})}async getSectorWeighting(e){return this.client.get("/etf/sector-weightings","stable",{symbol:e})}async getCountryWeighting(e){return this.client.get("/etf/country-weightings","stable",{symbol:e})}async getStockExposure(e){return this.client.get(`/etf-stock-exposure/${e}`,"v3")}};var d=class{constructor(e){this.client=e;}async getIncomeStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheet(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashFlowStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getKeyMetrics(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/key-metrics?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialRatios(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/ratios?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEnterpriseValue(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/enterprise-values?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashflowGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getIncomeGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheetGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/financial-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEarningsHistorical(e){let{symbol:t,limit:s=5}=e;return this.client.get(`/earnings?symbol=${t}&limit=${s}`,"stable")}async getEarningsSurprises(e){return this.client.get(`/earnings-surprises/${e}`,"v3")}async getFinancialScores(e){return this.client.getSingle("/financial-scores","stable",{symbol:e.symbol})}async getKeyMetricsTTM(e){return this.client.getSingle("/key-metrics-ttm","stable",{symbol:e.symbol})}async getFinancialRatiosTTM(e){return this.client.getSingle("/ratios-ttm","stable",{symbol:e.symbol})}async getRevenueProductSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-product-segmentation","stable",{symbol:t,period:s})}async getRevenueGeographicSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-geographic-segmentation","stable",{symbol:t,period:s})}};var f=class{constructor(e){this.client=e;}async getInsiderTradingRSS(e){let{page:t=0,limit:s=100}=e;return this.client.get("/insider-trading/latest","stable",{page:t,limit:s})}async searchInsiderTrading(e){let{symbol:t,reportingCik:s,companyCik:r,transactionType:i,page:o=0,limit:a=100}=e,l={page:o,limit:a};return t&&(l.symbol=t),s&&(l.reportingCik=s),r&&(l.companyCik=r),i&&(l.transactionType=i),this.client.get("/insider-trading/search","stable",l)}async getTransactionTypes(){return this.client.get("/insider-trading-transaction-type","stable")}async getInsidersBySymbol(e){let{symbol:t}=e;return this.client.get("/insider-roaster","v4",{symbol:t})}async getInsiderTradeStatistics(e){let{symbol:t}=e;return this.client.get("/insider-trading/statistics","stable",{symbol:t})}async getCikMapper(e){let{page:t=0}=e;return this.client.get("/mapper-cik-name","v4",{page:t})}async getCikMapperByName(e){let{name:t,page:s=0}=e;return this.client.get("/mapper-cik-name","v4",{name:t,page:s})}async getCikMapperBySymbol(e){let{symbol:t}=e;return this.client.getSingle(`/mapper-cik-company/${t}`,"v4")}async getBeneficialOwnership(e){let{symbol:t,limit:s=100}=e;return this.client.get("/acquisition-of-beneficial-ownership","stable",{symbol:t,limit:s})}async getFailToDeliver(e){let{symbol:t,page:s=0}=e;return this.client.get("/fail_to_deliver","v4",{symbol:t,page:s})}async getInsiderTradesBySymbol(e,t=0){return this.searchInsiderTrading({symbol:e,page:t})}async getInsiderTradesByType(e,t=0){return this.searchInsiderTrading({transactionType:e,page:t})}async getInsiderTradesByReportingCik(e,t=0){return this.searchInsiderTrading({reportingCik:e,page:t})}async getInsiderTradesByCompanyCik(e,t=0){return this.searchInsiderTrading({companyCik:e,page:t})}};var P=class{constructor(e){this.client=e;}async getForm13F(e){let{cik:t,date:s}=e,r={};return s&&(r.date=s),this.client.get(`/form-thirteen/${t}`,"v3",r)}async getForm13FDates(e){let{cik:t}=e;return this.client.get(`/form-thirteen-date/${t}`,"v3")}async getInstitutionalHolders(e){let{symbol:t}=e;return this.client.get(`/institutional-holder/${t}`,"v3")}};var b=class{constructor(e){this.client=e;}async getStockList(){return this.client.get("/stock/list")}async getETFList(){return this.client.get("/etf/list")}async getCryptoList(){return this.client.get("/symbol/available-cryptocurrencies")}async getForexList(){return this.client.get("/symbol/available-forex-currency-pairs")}async getAvailableIndexes(){return this.client.get("/symbol/available-indexes")}};var h=class{constructor(e){this.client=e;}async getMarketHours(){return this.client.get("/market-hours","v3")}async getMarketPerformance(){return this.client.get("/quotes/index","v3")}async getGainers(){return this.client.get("/biggest-gainers","stable")}async getLosers(){return this.client.get("/biggest-losers","stable")}async getMostActive(){return this.client.get("/most-actives","stable")}async getSectorPerformance(){return this.client.get("/sector-performance","v3")}async getMarketIndex(){return this.client.get("/quotes/index","v3")}};var R=class{constructor(e){this.client=e;}async getHolders(e){return this.client.get(`/mutual-fund-holder/${e}`,"v3")}};var I=class{constructor(e){this.client=e;}async getArticles(e={}){let{page:t=1,limit:s=100}=e;return this.client.get("/fmp-articles","stable",{page:t,limit:s})}async getStockNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/stock-latest","stable",o)}async getCryptoNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/crypto-latest","stable",o)}async getForexNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/forex-latest","stable",o)}async getStockNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/stock?symbols=${a}`,"stable",l)}async getCryptoNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/crypto?symbols=${a}`,"stable",l)}async getForexNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/forex?symbols=${a}`,"stable",l)}};var A=class{constructor(e){this.client=e;}async getQuote(e){return this.client.getSingle(`/quote/${e}`,"v3")}async getHistoricalPrice(e){let{symbol:t,from:s,to:r}=e,i={};return s&&(i.from=s),r&&(i.to=r),this.client.getSingle(`/historical-price-full/${t}`,"v3",i)}async getQuotes(e){let t=e.join(",");return this.client.get(`/quote/${t}`,"v3")}async getIntraday(e){let{symbol:t,interval:s,from:r,to:i}=e,o={};return r&&(o.from=r),i&&(o.to=i),this.client.get(`/historical-chart/${s}/${t}`,"v3",o)}};var S=class{constructor(e){this.client=e;}async getScreener(e){return this.client.get("/company-screener","stable",e)}async getAvailableExchanges(){return this.client.get("/available-exchanges","stable")}async getAvailableSectors(){return this.client.get("/available-sectors","stable")}async getAvailableIndustries(){return this.client.get("/available-industries","stable")}async getAvailableCountries(){return this.client.get("/available-countries","stable")}};var T=class{constructor(e){this.client=e;}async search(e){let{query:t,limit:s,exchange:r}=e;return this.client.get("/search","v3",{query:t,limit:s,exchange:r})}};var C=class{constructor(e){this.client=e;}async getEstimates(e){let{symbol:t,period:s="annual",limit:r}=e;return this.client.get("/analyst-estimates","stable",{symbol:t,period:s,limit:r})}async getPriceTargetConsensus(e){return this.client.getSingle("/price-target-consensus","stable",{symbol:e.symbol})}async getPriceTargetSummary(e){return this.client.getSingle("/price-target-summary","stable",{symbol:e.symbol})}async getGrades(e){return this.client.get("/grades","stable",{symbol:e.symbol})}async getGradesConsensus(e){return this.client.getSingle("/grades-consensus","stable",{symbol:e.symbol})}};var E=class{constructor(e){this.client=e;}async getDiscountedCashFlow(e){return this.client.getSingle("/discounted-cash-flow","stable",{symbol:e.symbol})}async getRatingSnapshot(e){return this.client.getSingle("/ratings-snapshot","stable",{symbol:e.symbol})}async getHistoricalRating(e){let{symbol:t,limit:s}=e;return this.client.get("/ratings-historical","stable",{symbol:t,limit:s})}};var F=class{constructor(e){this.client=e;}async getTechnicalIndicator(e){let{symbol:t,type:s,periodLength:r,timeframe:i}=e;return this.client.get(`/technical-indicators/${s}`,"stable",{symbol:t,periodLength:r,timeframe:i})}};var v=class{constructor(e){this.client=e;}async getRSSFeed(e){return this.client.get("/rss_feed","v4",e)}async getRSSFeedAll(e){return this.client.get("/rss_feed_all","v4",e)}async getRSSFeedV3(e){return this.client.get("/rss_feed","v3",e)}async getRSSFeed8K(e){return this.client.get("/rss_feed_8k","v4",e)}async getSECFilings({symbol:e,params:t}){return this.client.get(`/sec_filings/${e}`,"v3",t)}async getIndividualIndustryClassification(e){return this.client.getSingle("/standard_industrial_classification","v4",e)}async getAllIndustryClassifications(){return this.client.get("/standard_industrial_classification/all","v4")}async getIndustryClassificationCodes(e){return this.client.get("/standard_industrial_classification_list","v4",e)}};var M=class{constructor(e){this.client=e;}async getSenateTrading(e){let{symbol:t}=e;return this.client.get("/senate-trades","stable",{symbol:t})}async getSenateTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/senate-latest","stable",{page:t,limit:s??100})}async getSenateTradingByName(e){let{name:t}=e;return this.client.get("/senate-trades-by-name","stable",{name:t})}async getHouseTrading(e){let{symbol:t}=e;return this.client.get("/house-trades","stable",{symbol:t})}async getHouseTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/house-latest","stable",{page:t,limit:s??100})}async getHouseTradingByName(e){let{name:t}=e;return this.client.get("/house-trades-by-name","stable",{name:t})}};var x=class{constructor(e){this.client=e;}async getMarketCap(e){return this.client.getSingle(`/market-capitalization/${e}`,"v3")}async getStockSplits(e){return this.client.get(`/historical-price-full/stock_split/${e}`,"v3")}async getDividendHistory(e){return this.client.getSingle(`/historical-price-full/stock_dividend/${e}`,"v3")}async getRealTimePrice(e){let t=`stock/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}async getRealTimePriceForMultipleStocks(e){let t=`stock/full/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No full real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}};var D=class{constructor(e={}){let t=e.apiKey||process.env.FMP_API_KEY;if(!t)throw new Error("FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable.");if(!m.isValidApiKey(t))throw new Error("Invalid API key format");let s=new c({...e,apiKey:t});this.calendar=new p(s),this.company=new g(s),this.economic=new u(s),this.etf=new y(s),this.financial=new d(s),this.insider=new f(s),this.institutional=new P(s),this.list=new b(s),this.market=new h(s),this.mutualFund=new R(s),this.news=new I(s),this.quote=new A(s),this.screener=new S(s),this.search=new T(s),this.analyst=new C(s),this.valuation=new E(s),this.technical=new F(s),this.sec=new v(s),this.senateHouse=new M(s),this.stock=new x(s);}getClient(){return this.stock.client}};function H(n,e="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:e}).format(n)}function V(n,e=2){return `${n.toFixed(e)}%`}function U(n){return n>=1e12?`${(n/1e12).toFixed(2)}T`:n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}function O(n){return (typeof n=="string"?new Date(n):n).toISOString().split("T")[0]}function B(n){return n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}var Y=1e4,G=100,K=1e3,j={ANNUAL:"annual",QUARTER:"quarter"},Q={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},X={TECHNOLOGY:"Technology",HEALTHCARE:"Healthcare",FINANCIAL:"Financial",CONSUMER_DISCRETIONARY:"Consumer Discretionary",CONSUMER_STAPLES:"Consumer Staples",INDUSTRIALS:"Industrials",ENERGY:"Energy",MATERIALS:"Materials",UTILITIES:"Utilities",REAL_ESTATE:"Real Estate",COMMUNICATION_SERVICES:"Communication Services"};var L=class extends Error{constructor(t,s,r){super(t);this.status=s;this.code=r;this.name="FMPError";}};
2
- exports.AnalystEndpoints=C;exports.CalendarEndpoints=p;exports.CompanyEndpoints=g;exports.DEFAULT_LIMIT=G;exports.DEFAULT_TIMEOUT=Y;exports.ETFEndpoints=y;exports.EXCHANGES=Q;exports.EconomicEndpoints=u;exports.FMP=D;exports.FMPClient=c;exports.FMPError=L;exports.FMPValidation=m;exports.FinancialEndpoints=d;exports.InsiderEndpoints=f;exports.InstitutionalEndpoints=P;exports.ListEndpoints=b;exports.MAX_LIMIT=K;exports.MarketEndpoints=h;exports.MutualFundEndpoints=R;exports.NewsEndpoints=I;exports.PERIODS=j;exports.QuoteEndpoints=A;exports.SECEndpoints=v;exports.SECTORS=X;exports.ScreenerEndpoints=S;exports.SearchEndpoints=T;exports.SenateHouseEndpoints=M;exports.StockEndpoints=x;exports.TechnicalEndpoints=F;exports.ValuationEndpoints=E;exports.classifyError=k;exports.formatCurrency=H;exports.formatDate=O;exports.formatLargeNumber=U;exports.formatPercentage=V;exports.formatVolume=B;
1
+ 'use strict';var D=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var N=[/exclusive endpoint/i,/not available under your current/i,/premium/i,/special endpoint/i,/upgrade your plan/i];function w(n,e){let t=e?.trim()||"Unknown error occurred",s=N.some(r=>r.test(t));return n===429?{errorType:"rate-limit",message:`FMP rate limit reached: ${t}`}:n===401?{errorType:"auth",message:`FMP authentication failed (check your FMP_API_KEY): ${t}`}:n===402||n===403||s?{errorType:"plan-restricted",message:`This endpoint is not available on your current FMP plan. (${n}: ${t})`}:n===404?{errorType:"not-found",message:`Not found: ${t}`}:n===400?{errorType:"bad-request",message:`Invalid request: ${t}`}:n===0?{errorType:"network",message:`Network error: ${t}`}:{errorType:"unknown",message:t}}function _(n){return Array.isArray(n)&&n.length===1?n[0]:n}function q(n){return Array.isArray(n)?n:n??[]}function H(n){return n==null?{}:Array.isArray(n)&&n.length===0?{}:n}var c=class{constructor(e){if(!e.apiKey)throw new Error("API key is required for FMPClient");this.apiKey=e.apiKey,this.v3Client=D__default.default.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=D__default.default.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=D__default.default.create({baseURL:"https://financialmodelingprep.com/stable",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),[this.v3Client,this.v4Client,this.stableClient].forEach(t=>{t.interceptors.request.use(s=>(s.params={...s.params,apikey:this.apiKey},s));});}async get(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s}),o=i.data;return (Array.isArray(o)||o==null)&&(o=q(o)),{success:!0,data:o,error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}async getSingle(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s});return {success:!0,data:H(_(i.data)),error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}buildErrorResponse(e){let t=e?.response?.data,s=t&&typeof t=="object"?t["Error Message"]??t.message??null:typeof t=="string"?t:null,r=e?.response?.status??0,{errorType:i,message:o}=w(r,s||e?.message||"");return {success:false,data:null,error:o,errorType:i,status:r||500}}getClientForVersion(e){switch(e){case "v3":return this.v3Client;case "v4":return this.v4Client;case "stable":return this.stableClient;default:return this.v3Client}}};var m=class{static isValidSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{1,5}$/.test(e)}static isValidCryptoSymbol(e){return !e||typeof e!="string"?false:/^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(e)}static isValidForexPair(e){return !e||typeof e!="string"?false:/^[A-Z]{3}[A-Z]{3}$/.test(e)}static isValidDate(e){if(!e||typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return false;let s=new Date(e);return !isNaN(s.getTime())&&s.toISOString().split("T")[0]===e}static isValidDateRange(e,t){if(!this.isValidDate(e)||!this.isValidDate(t))return false;let s=new Date(e),r=new Date(t);return s<=r}static isValidResponse(e){return !!(e&&typeof e=="object"&&typeof e.success=="boolean")}static isValidApiKey(e){return !e||typeof e!="string"?false:/^[a-zA-Z0-9]{32,}$/.test(e)}static isValidPeriod(e){return !e||typeof e!="string"?false:["annual","quarter","fy"].includes(e.toLowerCase())}static isValidLimit(e){return typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=1e3}static validateQuoteParams(e){let t=[];return e?(e.symbol?!this.isValidSymbol(e.symbol)&&!this.isValidCryptoSymbol(e.symbol)&&!this.isValidForexPair(e.symbol)&&t.push("Invalid symbol format"):t.push("Symbol is required"),e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static validateFinancialParams(e){let t=[];return e?(e.symbol?this.isValidSymbol(e.symbol)||t.push("Invalid symbol format"):t.push("Symbol is required"),e.period&&!this.isValidPeriod(e.period)&&t.push('Invalid period (must be "annual", "quarter", or "FY")'),e.limit&&!this.isValidLimit(e.limit)&&t.push("Invalid limit (must be a positive integer <= 1000)"),t):(t.push("Parameters object is required"),t)}static validateDateRangeParams(e){let t=[];return e?(e.from&&!this.isValidDate(e.from)&&t.push("Invalid from date format (expected YYYY-MM-DD)"),e.to&&!this.isValidDate(e.to)&&t.push("Invalid to date format (expected YYYY-MM-DD)"),e.from&&e.to&&!this.isValidDateRange(e.from,e.to)&&t.push("From date must be before or equal to to date"),t):(t.push("Parameters object is required"),t)}static throwIfInvalid(e,t="Validation"){if(e.length>0)throw new Error(`${t} failed: ${e.join(", ")}`)}};var p=class{constructor(e){this._client=e;}async getEarningsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning_calendar","v3",r)}async getEarningsConfirmed(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning-calendar-confirmed","v4",r)}async getDividendsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_dividend_calendar","v3",r)}async getEconomicsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/economic_calendar","v3",r)}async getIPOCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/ipo_calendar","v3",r)}async getSplitsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_split_calendar","v3",r)}};var g=class{constructor(e){this.client=e;}async getCompanyProfile(e){return this.client.getSingle("/profile","stable",{symbol:e})}async getExecutiveCompensation(e){return this.client.get("/governance-executive-compensation","stable",{symbol:e})}async getCompanyNotes(e){return this.client.get("/company-notes","stable",{symbol:e})}async getHistoricalEmployeeCount(e){return this.client.get("/historical-employee-count","stable",{symbol:e})}async getSharesFloat(e){return this.client.getSingle("/shares-float","stable",{symbol:e})}async getHistoricalSharesFloat(e){return this.client.get("/historical/shares_float","v4",{symbol:e})}async getEarningsCallTranscript(e){let{symbol:t,year:s,quarter:r}=e;return this.client.getSingle(`/earning_call_transcript/${t}`,"v3",{year:s,quarter:r})}async getCompanyTranscriptData(e){return this.client.getSingle("/earning_call_transcript","v4",{symbol:e})}async getStockPeers(e){return this.client.get("/stock-peers","stable",{symbol:e})}};var u=class{constructor(e){this.client=e;}async getTreasuryRates(e){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this.client.get("/treasury-rates","stable",r)}async getEconomicIndicators(e){let{name:t,from:s,to:r}=e,i={name:t};return s&&(i.from=s),r&&(i.to=r),this.client.get("/economic-indicators","stable",i)}};var d=class{constructor(e){this.client=e;}async getHoldingDates(e){return this.client.get("/etf-holdings/portfolio-date","v4",{symbol:e})}async getHoldings(e){let{symbol:t,date:s}=e,r={};return t&&(r.symbol=t),s&&(r.date=s),this.client.get("/etf-holdings","v4",r)}async getHolder(e){return this.client.get(`/etf-holder/${e}`,"v3")}async getProfile(e){return this.client.getSingle("/etf/info","stable",{symbol:e})}async getSectorWeighting(e){return this.client.get("/etf/sector-weightings","stable",{symbol:e})}async getCountryWeighting(e){return this.client.get("/etf/country-weightings","stable",{symbol:e})}async getStockExposure(e){return this.client.get(`/etf-stock-exposure/${e}`,"v3")}};var y=class{constructor(e){this.client=e;}async getIncomeStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheet(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashFlowStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getKeyMetrics(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/key-metrics?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialRatios(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/ratios?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEnterpriseValue(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/enterprise-values?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashflowGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getIncomeGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheetGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/financial-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEarningsHistorical(e){let{symbol:t,limit:s=5}=e;return this.client.get(`/earnings?symbol=${t}&limit=${s}`,"stable")}async getEarningsSurprises(e){return this.client.get(`/earnings-surprises/${e}`,"v3")}async getFinancialScores(e){return this.client.getSingle("/financial-scores","stable",{symbol:e.symbol})}async getKeyMetricsTTM(e){return this.client.getSingle("/key-metrics-ttm","stable",{symbol:e.symbol})}async getFinancialRatiosTTM(e){return this.client.getSingle("/ratios-ttm","stable",{symbol:e.symbol})}async getRevenueProductSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-product-segmentation","stable",{symbol:t,period:s})}async getRevenueGeographicSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-geographic-segmentation","stable",{symbol:t,period:s})}};var f=class{constructor(e){this.client=e;}async getInsiderTradingRSS(e){let{page:t=0,limit:s=100}=e;return this.client.get("/insider-trading/latest","stable",{page:t,limit:s})}async searchInsiderTrading(e){let{symbol:t,reportingCik:s,companyCik:r,transactionType:i,page:o=0,limit:a=100}=e,l={page:o,limit:a};return t&&(l.symbol=t),s&&(l.reportingCik=s),r&&(l.companyCik=r),i&&(l.transactionType=i),this.client.get("/insider-trading/search","stable",l)}async getTransactionTypes(){return this.client.get("/insider-trading-transaction-type","stable")}async getInsidersBySymbol(e){let{symbol:t}=e;return this.client.get("/insider-roaster","v4",{symbol:t})}async getInsiderTradeStatistics(e){let{symbol:t}=e;return this.client.get("/insider-trading/statistics","stable",{symbol:t})}async getCikMapper(e){let{page:t=0}=e;return this.client.get("/mapper-cik-name","v4",{page:t})}async getCikMapperByName(e){let{name:t,page:s=0}=e;return this.client.get("/mapper-cik-name","v4",{name:t,page:s})}async getCikMapperBySymbol(e){let{symbol:t}=e;return this.client.getSingle(`/mapper-cik-company/${t}`,"v4")}async getBeneficialOwnership(e){let{symbol:t,limit:s=100}=e;return this.client.get("/acquisition-of-beneficial-ownership","stable",{symbol:t,limit:s})}async getFailToDeliver(e){let{symbol:t,page:s=0}=e;return this.client.get("/fail_to_deliver","v4",{symbol:t,page:s})}async getInsiderTradesBySymbol(e,t=0){return this.searchInsiderTrading({symbol:e,page:t})}async getInsiderTradesByType(e,t=0){return this.searchInsiderTrading({transactionType:e,page:t})}async getInsiderTradesByReportingCik(e,t=0){return this.searchInsiderTrading({reportingCik:e,page:t})}async getInsiderTradesByCompanyCik(e,t=0){return this.searchInsiderTrading({companyCik:e,page:t})}};var P=class{constructor(e){this.client=e;}async getForm13F(e){let{cik:t,date:s}=e,r={};return s&&(r.date=s),this.client.get(`/form-thirteen/${t}`,"v3",r)}async getForm13FDates(e){let{cik:t}=e;return this.client.get(`/form-thirteen-date/${t}`,"v3")}async getInstitutionalHolders(e){let{symbol:t}=e;return this.client.get(`/institutional-holder/${t}`,"v3")}};var b=class{constructor(e){this.client=e;}async getStockList(){return this.client.get("/stock/list")}async getETFList(){return this.client.get("/etf/list")}async getCryptoList(){return this.client.get("/symbol/available-cryptocurrencies")}async getForexList(){return this.client.get("/symbol/available-forex-currency-pairs")}async getAvailableIndexes(){return this.client.get("/symbol/available-indexes")}};var h=class{constructor(e){this.client=e;}async getMarketHours(){return this.client.get("/all-exchange-market-hours","stable")}async getMarketPerformance(){return this.client.get("/quotes/index","v3")}async getGainers(){return this.client.get("/biggest-gainers","stable")}async getLosers(){return this.client.get("/biggest-losers","stable")}async getMostActive(){return this.client.get("/most-actives","stable")}async getSectorPerformance(e){return this.client.get("/sector-performance-snapshot","stable",e)}async getIndustryPESnapshot(e){return this.client.get("/industry-pe-snapshot","stable",e)}async getMarketIndex(){return this.client.get("/quotes/index","v3")}};var R=class{constructor(e){this.client=e;}async getHolders(e){return this.client.get(`/mutual-fund-holder/${e}`,"v3")}};var I=class{constructor(e){this.client=e;}async getArticles(e={}){let{page:t=1,limit:s=100}=e;return this.client.get("/fmp-articles","stable",{page:t,limit:s})}async getStockNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/stock-latest","stable",o)}async getCryptoNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/crypto-latest","stable",o)}async getForexNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/forex-latest","stable",o)}async getStockNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/stock?symbols=${a}`,"stable",l)}async getCryptoNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/crypto?symbols=${a}`,"stable",l)}async getForexNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/forex?symbols=${a}`,"stable",l)}};var A=class{constructor(e){this.client=e;}async getQuote(e){return this.client.getSingle(`/quote/${e}`,"v3")}async getQuoteShort(e){return this.client.getSingle("/quote-short","stable",{symbol:e})}async getHistoricalPrice(e){let{symbol:t,from:s,to:r}=e,i={};return s&&(i.from=s),r&&(i.to=r),this.client.getSingle(`/historical-price-full/${t}`,"v3",i)}async getQuotes(e){let t=e.join(",");return this.client.get(`/quote/${t}`,"v3")}async getIntraday(e){let{symbol:t,interval:s,from:r,to:i}=e,o={};return r&&(o.from=r),i&&(o.to=i),this.client.get(`/historical-chart/${s}/${t}`,"v3",o)}};var S=class{constructor(e){this.client=e;}async getScreener(e){return this.client.get("/company-screener","stable",e)}async getAvailableExchanges(){return this.client.get("/available-exchanges","stable")}async getAvailableSectors(){return this.client.get("/available-sectors","stable")}async getAvailableIndustries(){return this.client.get("/available-industries","stable")}async getAvailableCountries(){return this.client.get("/available-countries","stable")}};var T=class{constructor(e){this.client=e;}async search(e){let{query:t,limit:s,exchange:r}=e;return this.client.get("/search","v3",{query:t,limit:s,exchange:r})}};var C=class{constructor(e){this.client=e;}async getEstimates(e){let{symbol:t,period:s="annual",limit:r}=e;return this.client.get("/analyst-estimates","stable",{symbol:t,period:s,limit:r})}async getPriceTargetConsensus(e){return this.client.getSingle("/price-target-consensus","stable",{symbol:e.symbol})}async getPriceTargetSummary(e){return this.client.getSingle("/price-target-summary","stable",{symbol:e.symbol})}async getGrades(e){return this.client.get("/grades","stable",{symbol:e.symbol})}async getGradesConsensus(e){return this.client.getSingle("/grades-consensus","stable",{symbol:e.symbol})}};var E=class{constructor(e){this.client=e;}async getDiscountedCashFlow(e){return this.client.getSingle("/discounted-cash-flow","stable",{symbol:e.symbol})}async getRatingSnapshot(e){return this.client.getSingle("/ratings-snapshot","stable",{symbol:e.symbol})}async getHistoricalRating(e){let{symbol:t,limit:s}=e;return this.client.get("/ratings-historical","stable",{symbol:t,limit:s})}};var F=class{constructor(e){this.client=e;}async getTechnicalIndicator(e){let{symbol:t,type:s,periodLength:r,timeframe:i}=e;return this.client.get(`/technical-indicators/${s}`,"stable",{symbol:t,periodLength:r,timeframe:i})}};var v=class{constructor(e){this.client=e;}async getRSSFeed(e){return this.client.get("/rss_feed","v4",e)}async getRSSFeedAll(e){return this.client.get("/rss_feed_all","v4",e)}async getRSSFeedV3(e){return this.client.get("/rss_feed","v3",e)}async getRSSFeed8K(e){return this.client.get("/rss_feed_8k","v4",e)}async getSECFilings({symbol:e,params:t}){return this.client.get(`/sec_filings/${e}`,"v3",t)}async getIndividualIndustryClassification(e){return this.client.getSingle("/standard_industrial_classification","v4",e)}async getAllIndustryClassifications(){return this.client.get("/standard_industrial_classification/all","v4")}async getIndustryClassificationCodes(e){return this.client.get("/standard_industrial_classification_list","v4",e)}};var M=class{constructor(e){this.client=e;}async getSenateTrading(e){let{symbol:t}=e;return this.client.get("/senate-trades","stable",{symbol:t})}async getSenateTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/senate-latest","stable",{page:t,limit:s??100})}async getSenateTradingByName(e){let{name:t}=e;return this.client.get("/senate-trades-by-name","stable",{name:t})}async getHouseTrading(e){let{symbol:t}=e;return this.client.get("/house-trades","stable",{symbol:t})}async getHouseTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/house-latest","stable",{page:t,limit:s??100})}async getHouseTradingByName(e){let{name:t}=e;return this.client.get("/house-trades-by-name","stable",{name:t})}};var x=class{constructor(e){this.client=e;}async getMarketCap(e){return this.client.getSingle(`/market-capitalization/${e}`,"v3")}async getPriceChange(e){return this.client.getSingle("/stock-price-change","stable",{symbol:e})}async getStockSplits(e){return this.client.get(`/historical-price-full/stock_split/${e}`,"v3")}async getDividendHistory(e){return this.client.getSingle(`/historical-price-full/stock_dividend/${e}`,"v3")}async getRealTimePrice(e){let t=`stock/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}async getRealTimePriceForMultipleStocks(e){let t=`stock/full/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No full real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}};var k=class{constructor(e){this.client=e;}async getTrade(e){return this.client.getSingle("/aftermarket-trade","stable",{symbol:e})}async getQuote(e){return this.client.getSingle("/aftermarket-quote","stable",{symbol:e})}};var L=class{constructor(e={}){let t=e.apiKey||process.env.FMP_API_KEY;if(!t)throw new Error("FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable.");if(!m.isValidApiKey(t))throw new Error("Invalid API key format");let s=new c({...e,apiKey:t});this.calendar=new p(s),this.company=new g(s),this.economic=new u(s),this.etf=new d(s),this.financial=new y(s),this.insider=new f(s),this.institutional=new P(s),this.list=new b(s),this.market=new h(s),this.mutualFund=new R(s),this.news=new I(s),this.quote=new A(s),this.screener=new S(s),this.search=new T(s),this.analyst=new C(s),this.valuation=new E(s),this.technical=new F(s),this.sec=new v(s),this.senateHouse=new M(s),this.stock=new x(s),this.aftermarket=new k(s);}getClient(){return this.stock.client}};function V(n,e="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:e}).format(n)}function U(n,e=2){return `${n.toFixed(e)}%`}function O(n){return n>=1e12?`${(n/1e12).toFixed(2)}T`:n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}function B(n){return (typeof n=="string"?new Date(n):n).toISOString().split("T")[0]}function Y(n){return n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}var G=1e4,K=100,j=1e3,Q={ANNUAL:"annual",QUARTER:"quarter"},X={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},Z={TECHNOLOGY:"Technology",HEALTHCARE:"Healthcare",FINANCIAL:"Financial",CONSUMER_DISCRETIONARY:"Consumer Discretionary",CONSUMER_STAPLES:"Consumer Staples",INDUSTRIALS:"Industrials",ENERGY:"Energy",MATERIALS:"Materials",UTILITIES:"Utilities",REAL_ESTATE:"Real Estate",COMMUNICATION_SERVICES:"Communication Services"};var $=class extends Error{constructor(t,s,r){super(t);this.status=s;this.code=r;this.name="FMPError";}};
2
+ exports.AftermarketEndpoints=k;exports.AnalystEndpoints=C;exports.CalendarEndpoints=p;exports.CompanyEndpoints=g;exports.DEFAULT_LIMIT=K;exports.DEFAULT_TIMEOUT=G;exports.ETFEndpoints=d;exports.EXCHANGES=X;exports.EconomicEndpoints=u;exports.FMP=L;exports.FMPClient=c;exports.FMPError=$;exports.FMPValidation=m;exports.FinancialEndpoints=y;exports.InsiderEndpoints=f;exports.InstitutionalEndpoints=P;exports.ListEndpoints=b;exports.MAX_LIMIT=j;exports.MarketEndpoints=h;exports.MutualFundEndpoints=R;exports.NewsEndpoints=I;exports.PERIODS=Q;exports.QuoteEndpoints=A;exports.SECEndpoints=v;exports.SECTORS=Z;exports.ScreenerEndpoints=S;exports.SearchEndpoints=T;exports.SenateHouseEndpoints=M;exports.StockEndpoints=x;exports.TechnicalEndpoints=F;exports.ValuationEndpoints=E;exports.classifyError=w;exports.formatCurrency=V;exports.formatDate=B;exports.formatLargeNumber=O;exports.formatPercentage=U;exports.formatVolume=Y;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-RM7ETDL3.mjs';export{a as FMPValidation}from'./chunk-RM7ETDL3.mjs';import w from'axios';var N=[/exclusive endpoint/i,/not available under your current/i,/premium/i,/special endpoint/i,/upgrade your plan/i];function k(n,e){let t=e?.trim()||"Unknown error occurred",s=N.some(r=>r.test(t));return n===429?{errorType:"rate-limit",message:`FMP rate limit reached: ${t}`}:n===401?{errorType:"auth",message:`FMP authentication failed (check your FMP_API_KEY): ${t}`}:n===402||n===403||s?{errorType:"plan-restricted",message:`This endpoint is not available on your current FMP plan. (${n}: ${t})`}:n===404?{errorType:"not-found",message:`Not found: ${t}`}:n===400?{errorType:"bad-request",message:`Invalid request: ${t}`}:n===0?{errorType:"network",message:`Network error: ${t}`}:{errorType:"unknown",message:t}}function _(n){return Array.isArray(n)&&n.length===1?n[0]:n}function $(n){return Array.isArray(n)?n:n??[]}function H(n){return n==null?{}:Array.isArray(n)&&n.length===0?{}:n}var c=class{constructor(e){if(!e.apiKey)throw new Error("API key is required for FMPClient");this.apiKey=e.apiKey,this.v3Client=w.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=w.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=w.create({baseURL:"https://financialmodelingprep.com/stable",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),[this.v3Client,this.v4Client,this.stableClient].forEach(t=>{t.interceptors.request.use(s=>(s.params={...s.params,apikey:this.apiKey},s));});}async get(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s}),o=i.data;return (Array.isArray(o)||o==null)&&(o=$(o)),{success:!0,data:o,error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}async getSingle(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s});return {success:!0,data:H(_(i.data)),error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}buildErrorResponse(e){let t=e?.response?.data,s=t&&typeof t=="object"?t["Error Message"]??t.message??null:typeof t=="string"?t:null,r=e?.response?.status??0,{errorType:i,message:o}=k(r,s||e?.message||"");return {success:false,data:null,error:o,errorType:i,status:r||500}}getClientForVersion(e){switch(e){case "v3":return this.v3Client;case "v4":return this.v4Client;case "stable":return this.stableClient;default:return this.v3Client}}};var m=class{constructor(e){this._client=e;}async getEarningsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning_calendar","v3",r)}async getEarningsConfirmed(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning-calendar-confirmed","v4",r)}async getDividendsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_dividend_calendar","v3",r)}async getEconomicsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/economic_calendar","v3",r)}async getIPOCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/ipo_calendar","v3",r)}async getSplitsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_split_calendar","v3",r)}};var p=class{constructor(e){this.client=e;}async getCompanyProfile(e){return this.client.getSingle("/profile","stable",{symbol:e})}async getExecutiveCompensation(e){return this.client.get("/governance-executive-compensation","stable",{symbol:e})}async getCompanyNotes(e){return this.client.get("/company-notes","stable",{symbol:e})}async getHistoricalEmployeeCount(e){return this.client.get("/historical-employee-count","stable",{symbol:e})}async getSharesFloat(e){return this.client.getSingle("/shares-float","stable",{symbol:e})}async getHistoricalSharesFloat(e){return this.client.get("/historical/shares_float","v4",{symbol:e})}async getEarningsCallTranscript(e){let{symbol:t,year:s,quarter:r}=e;return this.client.getSingle(`/earning_call_transcript/${t}`,"v3",{year:s,quarter:r})}async getCompanyTranscriptData(e){return this.client.getSingle("/earning_call_transcript","v4",{symbol:e})}async getStockPeers(e){return this.client.get("/stock-peers","stable",{symbol:e})}};var g=class{constructor(e){this.client=e;}async getTreasuryRates(e){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this.client.get("/treasury-rates","stable",r)}async getEconomicIndicators(e){let{name:t,from:s,to:r}=e,i={name:t};return s&&(i.from=s),r&&(i.to=r),this.client.get("/economic-indicators","stable",i)}};var u=class{constructor(e){this.client=e;}async getHoldingDates(e){return this.client.get("/etf-holdings/portfolio-date","v4",{symbol:e})}async getHoldings(e){let{symbol:t,date:s}=e,r={};return t&&(r.symbol=t),s&&(r.date=s),this.client.get("/etf-holdings","v4",r)}async getHolder(e){return this.client.get(`/etf-holder/${e}`,"v3")}async getProfile(e){return this.client.getSingle("/etf/info","stable",{symbol:e})}async getSectorWeighting(e){return this.client.get("/etf/sector-weightings","stable",{symbol:e})}async getCountryWeighting(e){return this.client.get("/etf/country-weightings","stable",{symbol:e})}async getStockExposure(e){return this.client.get(`/etf-stock-exposure/${e}`,"v3")}};var y=class{constructor(e){this.client=e;}async getIncomeStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheet(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashFlowStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getKeyMetrics(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/key-metrics?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialRatios(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/ratios?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEnterpriseValue(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/enterprise-values?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashflowGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getIncomeGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheetGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/financial-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEarningsHistorical(e){let{symbol:t,limit:s=5}=e;return this.client.get(`/earnings?symbol=${t}&limit=${s}`,"stable")}async getEarningsSurprises(e){return this.client.get(`/earnings-surprises/${e}`,"v3")}async getFinancialScores(e){return this.client.getSingle("/financial-scores","stable",{symbol:e.symbol})}async getKeyMetricsTTM(e){return this.client.getSingle("/key-metrics-ttm","stable",{symbol:e.symbol})}async getFinancialRatiosTTM(e){return this.client.getSingle("/ratios-ttm","stable",{symbol:e.symbol})}async getRevenueProductSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-product-segmentation","stable",{symbol:t,period:s})}async getRevenueGeographicSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-geographic-segmentation","stable",{symbol:t,period:s})}};var d=class{constructor(e){this.client=e;}async getInsiderTradingRSS(e){let{page:t=0,limit:s=100}=e;return this.client.get("/insider-trading/latest","stable",{page:t,limit:s})}async searchInsiderTrading(e){let{symbol:t,reportingCik:s,companyCik:r,transactionType:i,page:o=0,limit:a=100}=e,l={page:o,limit:a};return t&&(l.symbol=t),s&&(l.reportingCik=s),r&&(l.companyCik=r),i&&(l.transactionType=i),this.client.get("/insider-trading/search","stable",l)}async getTransactionTypes(){return this.client.get("/insider-trading-transaction-type","stable")}async getInsidersBySymbol(e){let{symbol:t}=e;return this.client.get("/insider-roaster","v4",{symbol:t})}async getInsiderTradeStatistics(e){let{symbol:t}=e;return this.client.get("/insider-trading/statistics","stable",{symbol:t})}async getCikMapper(e){let{page:t=0}=e;return this.client.get("/mapper-cik-name","v4",{page:t})}async getCikMapperByName(e){let{name:t,page:s=0}=e;return this.client.get("/mapper-cik-name","v4",{name:t,page:s})}async getCikMapperBySymbol(e){let{symbol:t}=e;return this.client.getSingle(`/mapper-cik-company/${t}`,"v4")}async getBeneficialOwnership(e){let{symbol:t,limit:s=100}=e;return this.client.get("/acquisition-of-beneficial-ownership","stable",{symbol:t,limit:s})}async getFailToDeliver(e){let{symbol:t,page:s=0}=e;return this.client.get("/fail_to_deliver","v4",{symbol:t,page:s})}async getInsiderTradesBySymbol(e,t=0){return this.searchInsiderTrading({symbol:e,page:t})}async getInsiderTradesByType(e,t=0){return this.searchInsiderTrading({transactionType:e,page:t})}async getInsiderTradesByReportingCik(e,t=0){return this.searchInsiderTrading({reportingCik:e,page:t})}async getInsiderTradesByCompanyCik(e,t=0){return this.searchInsiderTrading({companyCik:e,page:t})}};var P=class{constructor(e){this.client=e;}async getForm13F(e){let{cik:t,date:s}=e,r={};return s&&(r.date=s),this.client.get(`/form-thirteen/${t}`,"v3",r)}async getForm13FDates(e){let{cik:t}=e;return this.client.get(`/form-thirteen-date/${t}`,"v3")}async getInstitutionalHolders(e){let{symbol:t}=e;return this.client.get(`/institutional-holder/${t}`,"v3")}};var f=class{constructor(e){this.client=e;}async getStockList(){return this.client.get("/stock/list")}async getETFList(){return this.client.get("/etf/list")}async getCryptoList(){return this.client.get("/symbol/available-cryptocurrencies")}async getForexList(){return this.client.get("/symbol/available-forex-currency-pairs")}async getAvailableIndexes(){return this.client.get("/symbol/available-indexes")}};var b=class{constructor(e){this.client=e;}async getMarketHours(){return this.client.get("/market-hours","v3")}async getMarketPerformance(){return this.client.get("/quotes/index","v3")}async getGainers(){return this.client.get("/biggest-gainers","stable")}async getLosers(){return this.client.get("/biggest-losers","stable")}async getMostActive(){return this.client.get("/most-actives","stable")}async getSectorPerformance(){return this.client.get("/sector-performance","v3")}async getMarketIndex(){return this.client.get("/quotes/index","v3")}};var h=class{constructor(e){this.client=e;}async getHolders(e){return this.client.get(`/mutual-fund-holder/${e}`,"v3")}};var R=class{constructor(e){this.client=e;}async getArticles(e={}){let{page:t=1,limit:s=100}=e;return this.client.get("/fmp-articles","stable",{page:t,limit:s})}async getStockNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/stock-latest","stable",o)}async getCryptoNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/crypto-latest","stable",o)}async getForexNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/forex-latest","stable",o)}async getStockNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/stock?symbols=${a}`,"stable",l)}async getCryptoNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/crypto?symbols=${a}`,"stable",l)}async getForexNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/forex?symbols=${a}`,"stable",l)}};var I=class{constructor(e){this.client=e;}async getQuote(e){return this.client.getSingle(`/quote/${e}`,"v3")}async getHistoricalPrice(e){let{symbol:t,from:s,to:r}=e,i={};return s&&(i.from=s),r&&(i.to=r),this.client.getSingle(`/historical-price-full/${t}`,"v3",i)}async getQuotes(e){let t=e.join(",");return this.client.get(`/quote/${t}`,"v3")}async getIntraday(e){let{symbol:t,interval:s,from:r,to:i}=e,o={};return r&&(o.from=r),i&&(o.to=i),this.client.get(`/historical-chart/${s}/${t}`,"v3",o)}};var A=class{constructor(e){this.client=e;}async getScreener(e){return this.client.get("/company-screener","stable",e)}async getAvailableExchanges(){return this.client.get("/available-exchanges","stable")}async getAvailableSectors(){return this.client.get("/available-sectors","stable")}async getAvailableIndustries(){return this.client.get("/available-industries","stable")}async getAvailableCountries(){return this.client.get("/available-countries","stable")}};var S=class{constructor(e){this.client=e;}async search(e){let{query:t,limit:s,exchange:r}=e;return this.client.get("/search","v3",{query:t,limit:s,exchange:r})}};var T=class{constructor(e){this.client=e;}async getEstimates(e){let{symbol:t,period:s="annual",limit:r}=e;return this.client.get("/analyst-estimates","stable",{symbol:t,period:s,limit:r})}async getPriceTargetConsensus(e){return this.client.getSingle("/price-target-consensus","stable",{symbol:e.symbol})}async getPriceTargetSummary(e){return this.client.getSingle("/price-target-summary","stable",{symbol:e.symbol})}async getGrades(e){return this.client.get("/grades","stable",{symbol:e.symbol})}async getGradesConsensus(e){return this.client.getSingle("/grades-consensus","stable",{symbol:e.symbol})}};var C=class{constructor(e){this.client=e;}async getDiscountedCashFlow(e){return this.client.getSingle("/discounted-cash-flow","stable",{symbol:e.symbol})}async getRatingSnapshot(e){return this.client.getSingle("/ratings-snapshot","stable",{symbol:e.symbol})}async getHistoricalRating(e){let{symbol:t,limit:s}=e;return this.client.get("/ratings-historical","stable",{symbol:t,limit:s})}};var E=class{constructor(e){this.client=e;}async getTechnicalIndicator(e){let{symbol:t,type:s,periodLength:r,timeframe:i}=e;return this.client.get(`/technical-indicators/${s}`,"stable",{symbol:t,periodLength:r,timeframe:i})}};var F=class{constructor(e){this.client=e;}async getRSSFeed(e){return this.client.get("/rss_feed","v4",e)}async getRSSFeedAll(e){return this.client.get("/rss_feed_all","v4",e)}async getRSSFeedV3(e){return this.client.get("/rss_feed","v3",e)}async getRSSFeed8K(e){return this.client.get("/rss_feed_8k","v4",e)}async getSECFilings({symbol:e,params:t}){return this.client.get(`/sec_filings/${e}`,"v3",t)}async getIndividualIndustryClassification(e){return this.client.getSingle("/standard_industrial_classification","v4",e)}async getAllIndustryClassifications(){return this.client.get("/standard_industrial_classification/all","v4")}async getIndustryClassificationCodes(e){return this.client.get("/standard_industrial_classification_list","v4",e)}};var v=class{constructor(e){this.client=e;}async getSenateTrading(e){let{symbol:t}=e;return this.client.get("/senate-trades","stable",{symbol:t})}async getSenateTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/senate-latest","stable",{page:t,limit:s??100})}async getSenateTradingByName(e){let{name:t}=e;return this.client.get("/senate-trades-by-name","stable",{name:t})}async getHouseTrading(e){let{symbol:t}=e;return this.client.get("/house-trades","stable",{symbol:t})}async getHouseTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/house-latest","stable",{page:t,limit:s??100})}async getHouseTradingByName(e){let{name:t}=e;return this.client.get("/house-trades-by-name","stable",{name:t})}};var M=class{constructor(e){this.client=e;}async getMarketCap(e){return this.client.getSingle(`/market-capitalization/${e}`,"v3")}async getStockSplits(e){return this.client.get(`/historical-price-full/stock_split/${e}`,"v3")}async getDividendHistory(e){return this.client.getSingle(`/historical-price-full/stock_dividend/${e}`,"v3")}async getRealTimePrice(e){let t=`stock/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}async getRealTimePriceForMultipleStocks(e){let t=`stock/full/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No full real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}};var D=class{constructor(e={}){let t=e.apiKey||process.env.FMP_API_KEY;if(!t)throw new Error("FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable.");if(!a.isValidApiKey(t))throw new Error("Invalid API key format");let s=new c({...e,apiKey:t});this.calendar=new m(s),this.company=new p(s),this.economic=new g(s),this.etf=new u(s),this.financial=new y(s),this.insider=new d(s),this.institutional=new P(s),this.list=new f(s),this.market=new b(s),this.mutualFund=new h(s),this.news=new R(s),this.quote=new I(s),this.screener=new A(s),this.search=new S(s),this.analyst=new T(s),this.valuation=new C(s),this.technical=new E(s),this.sec=new F(s),this.senateHouse=new v(s),this.stock=new M(s);}getClient(){return this.stock.client}};function q(n,e="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:e}).format(n)}function U(n,e=2){return `${n.toFixed(e)}%`}function O(n){return n>=1e12?`${(n/1e12).toFixed(2)}T`:n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}function B(n){return (typeof n=="string"?new Date(n):n).toISOString().split("T")[0]}function G(n){return n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}var V=1e4,K=100,Y=1e3,j={ANNUAL:"annual",QUARTER:"quarter"},Q={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},X={TECHNOLOGY:"Technology",HEALTHCARE:"Healthcare",FINANCIAL:"Financial",CONSUMER_DISCRETIONARY:"Consumer Discretionary",CONSUMER_STAPLES:"Consumer Staples",INDUSTRIALS:"Industrials",ENERGY:"Energy",MATERIALS:"Materials",UTILITIES:"Utilities",REAL_ESTATE:"Real Estate",COMMUNICATION_SERVICES:"Communication Services"};var L=class extends Error{constructor(t,s,r){super(t);this.status=s;this.code=r;this.name="FMPError";}};
2
- export{T as AnalystEndpoints,m as CalendarEndpoints,p as CompanyEndpoints,K as DEFAULT_LIMIT,V as DEFAULT_TIMEOUT,u as ETFEndpoints,Q as EXCHANGES,g as EconomicEndpoints,D as FMP,c as FMPClient,L as FMPError,y as FinancialEndpoints,d as InsiderEndpoints,P as InstitutionalEndpoints,f as ListEndpoints,Y as MAX_LIMIT,b as MarketEndpoints,h as MutualFundEndpoints,R as NewsEndpoints,j as PERIODS,I as QuoteEndpoints,F as SECEndpoints,X as SECTORS,A as ScreenerEndpoints,S as SearchEndpoints,v as SenateHouseEndpoints,M as StockEndpoints,E as TechnicalEndpoints,C as ValuationEndpoints,k as classifyError,q as formatCurrency,B as formatDate,O as formatLargeNumber,U as formatPercentage,G as formatVolume};
1
+ import {a}from'./chunk-RM7ETDL3.mjs';export{a as FMPValidation}from'./chunk-RM7ETDL3.mjs';import D from'axios';var _=[/exclusive endpoint/i,/not available under your current/i,/premium/i,/special endpoint/i,/upgrade your plan/i];function w(n,e){let t=e?.trim()||"Unknown error occurred",s=_.some(r=>r.test(t));return n===429?{errorType:"rate-limit",message:`FMP rate limit reached: ${t}`}:n===401?{errorType:"auth",message:`FMP authentication failed (check your FMP_API_KEY): ${t}`}:n===402||n===403||s?{errorType:"plan-restricted",message:`This endpoint is not available on your current FMP plan. (${n}: ${t})`}:n===404?{errorType:"not-found",message:`Not found: ${t}`}:n===400?{errorType:"bad-request",message:`Invalid request: ${t}`}:n===0?{errorType:"network",message:`Network error: ${t}`}:{errorType:"unknown",message:t}}function $(n){return Array.isArray(n)&&n.length===1?n[0]:n}function q(n){return Array.isArray(n)?n:n??[]}function H(n){return n==null?{}:Array.isArray(n)&&n.length===0?{}:n}var c=class{constructor(e){if(!e.apiKey)throw new Error("API key is required for FMPClient");this.apiKey=e.apiKey,this.v3Client=D.create({baseURL:"https://financialmodelingprep.com/api/v3",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.v4Client=D.create({baseURL:"https://financialmodelingprep.com/api/v4",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),this.stableClient=D.create({baseURL:"https://financialmodelingprep.com/stable",timeout:e.timeout||1e4,headers:{"Content-Type":"application/json"}}),[this.v3Client,this.v4Client,this.stableClient].forEach(t=>{t.interceptors.request.use(s=>(s.params={...s.params,apikey:this.apiKey},s));});}async get(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s}),o=i.data;return (Array.isArray(o)||o==null)&&(o=q(o)),{success:!0,data:o,error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}async getSingle(e,t="v3",s){let r=this.getClientForVersion(t);try{let i=await r.get(e,{params:s});return {success:!0,data:H($(i.data)),error:null,status:i.status}}catch(i){return this.buildErrorResponse(i)}}buildErrorResponse(e){let t=e?.response?.data,s=t&&typeof t=="object"?t["Error Message"]??t.message??null:typeof t=="string"?t:null,r=e?.response?.status??0,{errorType:i,message:o}=w(r,s||e?.message||"");return {success:false,data:null,error:o,errorType:i,status:r||500}}getClientForVersion(e){switch(e){case "v3":return this.v3Client;case "v4":return this.v4Client;case "stable":return this.stableClient;default:return this.v3Client}}};var m=class{constructor(e){this._client=e;}async getEarningsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning_calendar","v3",r)}async getEarningsConfirmed(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/earning-calendar-confirmed","v4",r)}async getDividendsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_dividend_calendar","v3",r)}async getEconomicsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/economic_calendar","v3",r)}async getIPOCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/ipo_calendar","v3",r)}async getSplitsCalendar(e={}){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this._client.get("/stock_split_calendar","v3",r)}};var p=class{constructor(e){this.client=e;}async getCompanyProfile(e){return this.client.getSingle("/profile","stable",{symbol:e})}async getExecutiveCompensation(e){return this.client.get("/governance-executive-compensation","stable",{symbol:e})}async getCompanyNotes(e){return this.client.get("/company-notes","stable",{symbol:e})}async getHistoricalEmployeeCount(e){return this.client.get("/historical-employee-count","stable",{symbol:e})}async getSharesFloat(e){return this.client.getSingle("/shares-float","stable",{symbol:e})}async getHistoricalSharesFloat(e){return this.client.get("/historical/shares_float","v4",{symbol:e})}async getEarningsCallTranscript(e){let{symbol:t,year:s,quarter:r}=e;return this.client.getSingle(`/earning_call_transcript/${t}`,"v3",{year:s,quarter:r})}async getCompanyTranscriptData(e){return this.client.getSingle("/earning_call_transcript","v4",{symbol:e})}async getStockPeers(e){return this.client.get("/stock-peers","stable",{symbol:e})}};var g=class{constructor(e){this.client=e;}async getTreasuryRates(e){let{from:t,to:s}=e,r={};return t&&(r.from=t),s&&(r.to=s),this.client.get("/treasury-rates","stable",r)}async getEconomicIndicators(e){let{name:t,from:s,to:r}=e,i={name:t};return s&&(i.from=s),r&&(i.to=r),this.client.get("/economic-indicators","stable",i)}};var u=class{constructor(e){this.client=e;}async getHoldingDates(e){return this.client.get("/etf-holdings/portfolio-date","v4",{symbol:e})}async getHoldings(e){let{symbol:t,date:s}=e,r={};return t&&(r.symbol=t),s&&(r.date=s),this.client.get("/etf-holdings","v4",r)}async getHolder(e){return this.client.get(`/etf-holder/${e}`,"v3")}async getProfile(e){return this.client.getSingle("/etf/info","stable",{symbol:e})}async getSectorWeighting(e){return this.client.get("/etf/sector-weightings","stable",{symbol:e})}async getCountryWeighting(e){return this.client.get("/etf/country-weightings","stable",{symbol:e})}async getStockExposure(e){return this.client.get(`/etf-stock-exposure/${e}`,"v3")}};var y=class{constructor(e){this.client=e;}async getIncomeStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheet(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashFlowStatement(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getKeyMetrics(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/key-metrics?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialRatios(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/ratios?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEnterpriseValue(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/enterprise-values?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getCashflowGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/cash-flow-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getIncomeGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/income-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getBalanceSheetGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/balance-sheet-statement-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getFinancialGrowth(e){let{symbol:t,period:s="annual",limit:r=5}=e;return this.client.get(`/financial-growth?symbol=${t}&period=${s}&limit=${r}`,"stable")}async getEarningsHistorical(e){let{symbol:t,limit:s=5}=e;return this.client.get(`/earnings?symbol=${t}&limit=${s}`,"stable")}async getEarningsSurprises(e){return this.client.get(`/earnings-surprises/${e}`,"v3")}async getFinancialScores(e){return this.client.getSingle("/financial-scores","stable",{symbol:e.symbol})}async getKeyMetricsTTM(e){return this.client.getSingle("/key-metrics-ttm","stable",{symbol:e.symbol})}async getFinancialRatiosTTM(e){return this.client.getSingle("/ratios-ttm","stable",{symbol:e.symbol})}async getRevenueProductSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-product-segmentation","stable",{symbol:t,period:s})}async getRevenueGeographicSegmentation(e){let{symbol:t,period:s}=e;return this.client.get("/revenue-geographic-segmentation","stable",{symbol:t,period:s})}};var d=class{constructor(e){this.client=e;}async getInsiderTradingRSS(e){let{page:t=0,limit:s=100}=e;return this.client.get("/insider-trading/latest","stable",{page:t,limit:s})}async searchInsiderTrading(e){let{symbol:t,reportingCik:s,companyCik:r,transactionType:i,page:o=0,limit:a=100}=e,l={page:o,limit:a};return t&&(l.symbol=t),s&&(l.reportingCik=s),r&&(l.companyCik=r),i&&(l.transactionType=i),this.client.get("/insider-trading/search","stable",l)}async getTransactionTypes(){return this.client.get("/insider-trading-transaction-type","stable")}async getInsidersBySymbol(e){let{symbol:t}=e;return this.client.get("/insider-roaster","v4",{symbol:t})}async getInsiderTradeStatistics(e){let{symbol:t}=e;return this.client.get("/insider-trading/statistics","stable",{symbol:t})}async getCikMapper(e){let{page:t=0}=e;return this.client.get("/mapper-cik-name","v4",{page:t})}async getCikMapperByName(e){let{name:t,page:s=0}=e;return this.client.get("/mapper-cik-name","v4",{name:t,page:s})}async getCikMapperBySymbol(e){let{symbol:t}=e;return this.client.getSingle(`/mapper-cik-company/${t}`,"v4")}async getBeneficialOwnership(e){let{symbol:t,limit:s=100}=e;return this.client.get("/acquisition-of-beneficial-ownership","stable",{symbol:t,limit:s})}async getFailToDeliver(e){let{symbol:t,page:s=0}=e;return this.client.get("/fail_to_deliver","v4",{symbol:t,page:s})}async getInsiderTradesBySymbol(e,t=0){return this.searchInsiderTrading({symbol:e,page:t})}async getInsiderTradesByType(e,t=0){return this.searchInsiderTrading({transactionType:e,page:t})}async getInsiderTradesByReportingCik(e,t=0){return this.searchInsiderTrading({reportingCik:e,page:t})}async getInsiderTradesByCompanyCik(e,t=0){return this.searchInsiderTrading({companyCik:e,page:t})}};var P=class{constructor(e){this.client=e;}async getForm13F(e){let{cik:t,date:s}=e,r={};return s&&(r.date=s),this.client.get(`/form-thirteen/${t}`,"v3",r)}async getForm13FDates(e){let{cik:t}=e;return this.client.get(`/form-thirteen-date/${t}`,"v3")}async getInstitutionalHolders(e){let{symbol:t}=e;return this.client.get(`/institutional-holder/${t}`,"v3")}};var f=class{constructor(e){this.client=e;}async getStockList(){return this.client.get("/stock/list")}async getETFList(){return this.client.get("/etf/list")}async getCryptoList(){return this.client.get("/symbol/available-cryptocurrencies")}async getForexList(){return this.client.get("/symbol/available-forex-currency-pairs")}async getAvailableIndexes(){return this.client.get("/symbol/available-indexes")}};var b=class{constructor(e){this.client=e;}async getMarketHours(){return this.client.get("/all-exchange-market-hours","stable")}async getMarketPerformance(){return this.client.get("/quotes/index","v3")}async getGainers(){return this.client.get("/biggest-gainers","stable")}async getLosers(){return this.client.get("/biggest-losers","stable")}async getMostActive(){return this.client.get("/most-actives","stable")}async getSectorPerformance(e){return this.client.get("/sector-performance-snapshot","stable",e)}async getIndustryPESnapshot(e){return this.client.get("/industry-pe-snapshot","stable",e)}async getMarketIndex(){return this.client.get("/quotes/index","v3")}};var h=class{constructor(e){this.client=e;}async getHolders(e){return this.client.get(`/mutual-fund-holder/${e}`,"v3")}};var R=class{constructor(e){this.client=e;}async getArticles(e={}){let{page:t=1,limit:s=100}=e;return this.client.get("/fmp-articles","stable",{page:t,limit:s})}async getStockNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/stock-latest","stable",o)}async getCryptoNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/crypto-latest","stable",o)}async getForexNews(e={}){let{from:t,to:s,page:r=1,limit:i=100}=e,o={page:r,limit:i};return t&&(o.from=t),s&&(o.to=s),this.client.get("/news/forex-latest","stable",o)}async getStockNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/stock?symbols=${a}`,"stable",l)}async getCryptoNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/crypto?symbols=${a}`,"stable",l)}async getForexNewsBySymbol(e){let{symbols:t,from:s,to:r,page:i=1,limit:o=100}=e,a=t.join(","),l={page:i,limit:o};return s&&(l.from=s),r&&(l.to=r),this.client.get(`/news/forex?symbols=${a}`,"stable",l)}};var I=class{constructor(e){this.client=e;}async getQuote(e){return this.client.getSingle(`/quote/${e}`,"v3")}async getQuoteShort(e){return this.client.getSingle("/quote-short","stable",{symbol:e})}async getHistoricalPrice(e){let{symbol:t,from:s,to:r}=e,i={};return s&&(i.from=s),r&&(i.to=r),this.client.getSingle(`/historical-price-full/${t}`,"v3",i)}async getQuotes(e){let t=e.join(",");return this.client.get(`/quote/${t}`,"v3")}async getIntraday(e){let{symbol:t,interval:s,from:r,to:i}=e,o={};return r&&(o.from=r),i&&(o.to=i),this.client.get(`/historical-chart/${s}/${t}`,"v3",o)}};var A=class{constructor(e){this.client=e;}async getScreener(e){return this.client.get("/company-screener","stable",e)}async getAvailableExchanges(){return this.client.get("/available-exchanges","stable")}async getAvailableSectors(){return this.client.get("/available-sectors","stable")}async getAvailableIndustries(){return this.client.get("/available-industries","stable")}async getAvailableCountries(){return this.client.get("/available-countries","stable")}};var S=class{constructor(e){this.client=e;}async search(e){let{query:t,limit:s,exchange:r}=e;return this.client.get("/search","v3",{query:t,limit:s,exchange:r})}};var T=class{constructor(e){this.client=e;}async getEstimates(e){let{symbol:t,period:s="annual",limit:r}=e;return this.client.get("/analyst-estimates","stable",{symbol:t,period:s,limit:r})}async getPriceTargetConsensus(e){return this.client.getSingle("/price-target-consensus","stable",{symbol:e.symbol})}async getPriceTargetSummary(e){return this.client.getSingle("/price-target-summary","stable",{symbol:e.symbol})}async getGrades(e){return this.client.get("/grades","stable",{symbol:e.symbol})}async getGradesConsensus(e){return this.client.getSingle("/grades-consensus","stable",{symbol:e.symbol})}};var C=class{constructor(e){this.client=e;}async getDiscountedCashFlow(e){return this.client.getSingle("/discounted-cash-flow","stable",{symbol:e.symbol})}async getRatingSnapshot(e){return this.client.getSingle("/ratings-snapshot","stable",{symbol:e.symbol})}async getHistoricalRating(e){let{symbol:t,limit:s}=e;return this.client.get("/ratings-historical","stable",{symbol:t,limit:s})}};var E=class{constructor(e){this.client=e;}async getTechnicalIndicator(e){let{symbol:t,type:s,periodLength:r,timeframe:i}=e;return this.client.get(`/technical-indicators/${s}`,"stable",{symbol:t,periodLength:r,timeframe:i})}};var F=class{constructor(e){this.client=e;}async getRSSFeed(e){return this.client.get("/rss_feed","v4",e)}async getRSSFeedAll(e){return this.client.get("/rss_feed_all","v4",e)}async getRSSFeedV3(e){return this.client.get("/rss_feed","v3",e)}async getRSSFeed8K(e){return this.client.get("/rss_feed_8k","v4",e)}async getSECFilings({symbol:e,params:t}){return this.client.get(`/sec_filings/${e}`,"v3",t)}async getIndividualIndustryClassification(e){return this.client.getSingle("/standard_industrial_classification","v4",e)}async getAllIndustryClassifications(){return this.client.get("/standard_industrial_classification/all","v4")}async getIndustryClassificationCodes(e){return this.client.get("/standard_industrial_classification_list","v4",e)}};var v=class{constructor(e){this.client=e;}async getSenateTrading(e){let{symbol:t}=e;return this.client.get("/senate-trades","stable",{symbol:t})}async getSenateTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/senate-latest","stable",{page:t,limit:s??100})}async getSenateTradingByName(e){let{name:t}=e;return this.client.get("/senate-trades-by-name","stable",{name:t})}async getHouseTrading(e){let{symbol:t}=e;return this.client.get("/house-trades","stable",{symbol:t})}async getHouseTradingRSSFeed(e){let{page:t,limit:s}=e;return this.client.get("/house-latest","stable",{page:t,limit:s??100})}async getHouseTradingByName(e){let{name:t}=e;return this.client.get("/house-trades-by-name","stable",{name:t})}};var k=class{constructor(e){this.client=e;}async getMarketCap(e){return this.client.getSingle(`/market-capitalization/${e}`,"v3")}async getPriceChange(e){return this.client.getSingle("/stock-price-change","stable",{symbol:e})}async getStockSplits(e){return this.client.get(`/historical-price-full/stock_split/${e}`,"v3")}async getDividendHistory(e){return this.client.getSingle(`/historical-price-full/stock_dividend/${e}`,"v3")}async getRealTimePrice(e){let t=`stock/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}async getRealTimePriceForMultipleStocks(e){let t=`stock/full/real-time-price/${e.join(",")}`,s=await this.client.get(t,"v3");if(s.success&&s.data&&!Array.isArray(s.data)){let i=s.data;if(typeof i=="object"&&i!==null&&"companiesPriceList"in i&&Array.isArray(i.companiesPriceList)){let o=i.companiesPriceList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}if(typeof i=="object"&&i!==null&&"stockList"in i&&Array.isArray(i.stockList)){let o=i.stockList.filter(a=>a&&a.symbol);if(o.length>0)return {...s,data:o}}return i.symbol?{...s,data:[i]}:(e.length===1&&console.warn(`No full real-time price data found for symbol: ${e[0]}`),{...s,data:[]})}let r=s.data.filter(i=>i&&i.symbol);return {...s,data:r}}};var M=class{constructor(e){this.client=e;}async getTrade(e){return this.client.getSingle("/aftermarket-trade","stable",{symbol:e})}async getQuote(e){return this.client.getSingle("/aftermarket-quote","stable",{symbol:e})}};var L=class{constructor(e={}){let t=e.apiKey||process.env.FMP_API_KEY;if(!t)throw new Error("FMP API key is required. Please provide it in the config or set the FMP_API_KEY environment variable.");if(!a.isValidApiKey(t))throw new Error("Invalid API key format");let s=new c({...e,apiKey:t});this.calendar=new m(s),this.company=new p(s),this.economic=new g(s),this.etf=new u(s),this.financial=new y(s),this.insider=new d(s),this.institutional=new P(s),this.list=new f(s),this.market=new b(s),this.mutualFund=new h(s),this.news=new R(s),this.quote=new I(s),this.screener=new A(s),this.search=new S(s),this.analyst=new T(s),this.valuation=new C(s),this.technical=new E(s),this.sec=new F(s),this.senateHouse=new v(s),this.stock=new k(s),this.aftermarket=new M(s);}getClient(){return this.stock.client}};function U(n,e="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:e}).format(n)}function O(n,e=2){return `${n.toFixed(e)}%`}function B(n){return n>=1e12?`${(n/1e12).toFixed(2)}T`:n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}function G(n){return (typeof n=="string"?new Date(n):n).toISOString().split("T")[0]}function V(n){return n>=1e9?`${(n/1e9).toFixed(2)}B`:n>=1e6?`${(n/1e6).toFixed(2)}M`:n>=1e3?`${(n/1e3).toFixed(2)}K`:n.toString()}var K=1e4,Q=100,Y=1e3,j={ANNUAL:"annual",QUARTER:"quarter"},X={NYSE:"NYSE",NASDAQ:"NASDAQ",AMEX:"AMEX",TSX:"TSX",LSE:"LSE",ASX:"ASX",NSE:"NSE",BSE:"BSE"},W={TECHNOLOGY:"Technology",HEALTHCARE:"Healthcare",FINANCIAL:"Financial",CONSUMER_DISCRETIONARY:"Consumer Discretionary",CONSUMER_STAPLES:"Consumer Staples",INDUSTRIALS:"Industrials",ENERGY:"Energy",MATERIALS:"Materials",UTILITIES:"Utilities",REAL_ESTATE:"Real Estate",COMMUNICATION_SERVICES:"Communication Services"};var N=class extends Error{constructor(t,s,r){super(t);this.status=s;this.code=r;this.name="FMPError";}};
2
+ export{M as AftermarketEndpoints,T as AnalystEndpoints,m as CalendarEndpoints,p as CompanyEndpoints,Q as DEFAULT_LIMIT,K as DEFAULT_TIMEOUT,u as ETFEndpoints,X as EXCHANGES,g as EconomicEndpoints,L as FMP,c as FMPClient,N as FMPError,y as FinancialEndpoints,d as InsiderEndpoints,P as InstitutionalEndpoints,f as ListEndpoints,Y as MAX_LIMIT,b as MarketEndpoints,h as MutualFundEndpoints,R as NewsEndpoints,j as PERIODS,I as QuoteEndpoints,F as SECEndpoints,W as SECTORS,A as ScreenerEndpoints,S as SearchEndpoints,v as SenateHouseEndpoints,k as StockEndpoints,E as TechnicalEndpoints,C as ValuationEndpoints,w as classifyError,U as formatCurrency,G as formatDate,B as formatLargeNumber,O as formatPercentage,V as formatVolume};