fmp-node-api 0.2.0-beta.3 → 0.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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})}};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")}};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 C=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,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})}};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 x=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(!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 C(s),this.analyst=new T(s),this.valuation=new E(s),this.technical=new F(s),this.sec=new v(s),this.senateHouse=new x(s),this.stock=new M(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,j=1e3,K={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";}};
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})}};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")}};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 C=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})}};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 x=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(!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 C(s),this.analyst=new T(s),this.valuation=new E(s),this.technical=new F(s),this.sec=new v(s),this.senateHouse=new x(s),this.stock=new M(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,j=1e3,K={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
2
  exports.AnalystEndpoints=T;exports.CalendarEndpoints=p;exports.CompanyEndpoints=g;exports.DEFAULT_LIMIT=G;exports.DEFAULT_TIMEOUT=Y;exports.ETFEndpoints=d;exports.EXCHANGES=Q;exports.EconomicEndpoints=u;exports.FMP=D;exports.FMPClient=c;exports.FMPError=L;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=K;exports.QuoteEndpoints=A;exports.SECEndpoints=v;exports.SECTORS=X;exports.ScreenerEndpoints=S;exports.SearchEndpoints=C;exports.SenateHouseEndpoints=x;exports.StockEndpoints=M;exports.TechnicalEndpoints=F;exports.ValuationEndpoints=E;exports.classifyError=k;exports.formatCurrency=H;exports.formatDate=O;exports.formatLargeNumber=U;exports.formatPercentage=V;exports.formatVolume=B;
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})}};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")}};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,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})}};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 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(!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 x(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";}};
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})}};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")}};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})}};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 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(!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 x(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
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,x 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};
@@ -3659,54 +3659,72 @@ type SearchResult = z.infer<typeof SearchResultSchema>;
3659
3659
  declare const AnalystEstimateSchema: z.ZodObject<{
3660
3660
  symbol: z.ZodString;
3661
3661
  date: z.ZodString;
3662
- estimatedRevenueLow: z.ZodNullable<z.ZodNumber>;
3663
- estimatedRevenueHigh: z.ZodNullable<z.ZodNumber>;
3664
- estimatedRevenueAvg: z.ZodNullable<z.ZodNumber>;
3665
- estimatedEbitdaLow: z.ZodNullable<z.ZodNumber>;
3666
- estimatedEbitdaHigh: z.ZodNullable<z.ZodNumber>;
3667
- estimatedEbitdaAvg: z.ZodNullable<z.ZodNumber>;
3668
- estimatedNetIncomeLow: z.ZodNullable<z.ZodNumber>;
3669
- estimatedNetIncomeHigh: z.ZodNullable<z.ZodNumber>;
3670
- estimatedNetIncomeAvg: z.ZodNullable<z.ZodNumber>;
3671
- estimatedEpsLow: z.ZodNullable<z.ZodNumber>;
3672
- estimatedEpsHigh: z.ZodNullable<z.ZodNumber>;
3673
- estimatedEpsAvg: z.ZodNullable<z.ZodNumber>;
3674
- numberAnalystEstimatedRevenue: z.ZodNullable<z.ZodNumber>;
3675
- numberAnalystsEstimatedEps: z.ZodNullable<z.ZodNumber>;
3662
+ revenueLow: z.ZodNullable<z.ZodNumber>;
3663
+ revenueHigh: z.ZodNullable<z.ZodNumber>;
3664
+ revenueAvg: z.ZodNullable<z.ZodNumber>;
3665
+ ebitdaLow: z.ZodNullable<z.ZodNumber>;
3666
+ ebitdaHigh: z.ZodNullable<z.ZodNumber>;
3667
+ ebitdaAvg: z.ZodNullable<z.ZodNumber>;
3668
+ ebitLow: z.ZodNullable<z.ZodNumber>;
3669
+ ebitHigh: z.ZodNullable<z.ZodNumber>;
3670
+ ebitAvg: z.ZodNullable<z.ZodNumber>;
3671
+ netIncomeLow: z.ZodNullable<z.ZodNumber>;
3672
+ netIncomeHigh: z.ZodNullable<z.ZodNumber>;
3673
+ netIncomeAvg: z.ZodNullable<z.ZodNumber>;
3674
+ sgaExpenseLow: z.ZodNullable<z.ZodNumber>;
3675
+ sgaExpenseHigh: z.ZodNullable<z.ZodNumber>;
3676
+ sgaExpenseAvg: z.ZodNullable<z.ZodNumber>;
3677
+ epsAvg: z.ZodNullable<z.ZodNumber>;
3678
+ epsHigh: z.ZodNullable<z.ZodNumber>;
3679
+ epsLow: z.ZodNullable<z.ZodNumber>;
3680
+ numAnalystsRevenue: z.ZodNullable<z.ZodNumber>;
3681
+ numAnalystsEps: z.ZodNullable<z.ZodNumber>;
3676
3682
  }, "strip", z.ZodTypeAny, {
3677
3683
  symbol: string;
3678
3684
  date: string;
3679
- estimatedRevenueLow: number | null;
3680
- estimatedRevenueHigh: number | null;
3681
- estimatedRevenueAvg: number | null;
3682
- estimatedEbitdaLow: number | null;
3683
- estimatedEbitdaHigh: number | null;
3684
- estimatedEbitdaAvg: number | null;
3685
- estimatedNetIncomeLow: number | null;
3686
- estimatedNetIncomeHigh: number | null;
3687
- estimatedNetIncomeAvg: number | null;
3688
- estimatedEpsLow: number | null;
3689
- estimatedEpsHigh: number | null;
3690
- estimatedEpsAvg: number | null;
3691
- numberAnalystEstimatedRevenue: number | null;
3692
- numberAnalystsEstimatedEps: number | null;
3685
+ revenueLow: number | null;
3686
+ revenueHigh: number | null;
3687
+ revenueAvg: number | null;
3688
+ ebitdaLow: number | null;
3689
+ ebitdaHigh: number | null;
3690
+ ebitdaAvg: number | null;
3691
+ ebitLow: number | null;
3692
+ ebitHigh: number | null;
3693
+ ebitAvg: number | null;
3694
+ netIncomeLow: number | null;
3695
+ netIncomeHigh: number | null;
3696
+ netIncomeAvg: number | null;
3697
+ sgaExpenseLow: number | null;
3698
+ sgaExpenseHigh: number | null;
3699
+ sgaExpenseAvg: number | null;
3700
+ epsAvg: number | null;
3701
+ epsHigh: number | null;
3702
+ epsLow: number | null;
3703
+ numAnalystsRevenue: number | null;
3704
+ numAnalystsEps: number | null;
3693
3705
  }, {
3694
3706
  symbol: string;
3695
3707
  date: string;
3696
- estimatedRevenueLow: number | null;
3697
- estimatedRevenueHigh: number | null;
3698
- estimatedRevenueAvg: number | null;
3699
- estimatedEbitdaLow: number | null;
3700
- estimatedEbitdaHigh: number | null;
3701
- estimatedEbitdaAvg: number | null;
3702
- estimatedNetIncomeLow: number | null;
3703
- estimatedNetIncomeHigh: number | null;
3704
- estimatedNetIncomeAvg: number | null;
3705
- estimatedEpsLow: number | null;
3706
- estimatedEpsHigh: number | null;
3707
- estimatedEpsAvg: number | null;
3708
- numberAnalystEstimatedRevenue: number | null;
3709
- numberAnalystsEstimatedEps: number | null;
3708
+ revenueLow: number | null;
3709
+ revenueHigh: number | null;
3710
+ revenueAvg: number | null;
3711
+ ebitdaLow: number | null;
3712
+ ebitdaHigh: number | null;
3713
+ ebitdaAvg: number | null;
3714
+ ebitLow: number | null;
3715
+ ebitHigh: number | null;
3716
+ ebitAvg: number | null;
3717
+ netIncomeLow: number | null;
3718
+ netIncomeHigh: number | null;
3719
+ netIncomeAvg: number | null;
3720
+ sgaExpenseLow: number | null;
3721
+ sgaExpenseHigh: number | null;
3722
+ sgaExpenseAvg: number | null;
3723
+ epsAvg: number | null;
3724
+ epsHigh: number | null;
3725
+ epsLow: number | null;
3726
+ numAnalystsRevenue: number | null;
3727
+ numAnalystsEps: number | null;
3710
3728
  }>;
3711
3729
  declare const PriceTargetConsensusSchema: z.ZodObject<{
3712
3730
  symbol: z.ZodString;
@@ -3729,35 +3747,35 @@ declare const PriceTargetConsensusSchema: z.ZodObject<{
3729
3747
  }>;
3730
3748
  declare const PriceTargetSummarySchema: z.ZodObject<{
3731
3749
  symbol: z.ZodString;
3732
- lastMonth: z.ZodNullable<z.ZodNumber>;
3750
+ lastMonthCount: z.ZodNullable<z.ZodNumber>;
3733
3751
  lastMonthAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3734
- lastQuarter: z.ZodNullable<z.ZodNumber>;
3752
+ lastQuarterCount: z.ZodNullable<z.ZodNumber>;
3735
3753
  lastQuarterAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3736
- lastYear: z.ZodNullable<z.ZodNumber>;
3754
+ lastYearCount: z.ZodNullable<z.ZodNumber>;
3737
3755
  lastYearAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3738
- allTime: z.ZodNullable<z.ZodNumber>;
3756
+ allTimeCount: z.ZodNullable<z.ZodNumber>;
3739
3757
  allTimeAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3740
3758
  publishers: z.ZodNullable<z.ZodString>;
3741
3759
  }, "strip", z.ZodTypeAny, {
3742
3760
  symbol: string;
3743
- lastMonth: number | null;
3761
+ lastMonthCount: number | null;
3744
3762
  lastMonthAvgPriceTarget: number | null;
3745
- lastQuarter: number | null;
3763
+ lastQuarterCount: number | null;
3746
3764
  lastQuarterAvgPriceTarget: number | null;
3747
- lastYear: number | null;
3765
+ lastYearCount: number | null;
3748
3766
  lastYearAvgPriceTarget: number | null;
3749
- allTime: number | null;
3767
+ allTimeCount: number | null;
3750
3768
  allTimeAvgPriceTarget: number | null;
3751
3769
  publishers: string | null;
3752
3770
  }, {
3753
3771
  symbol: string;
3754
- lastMonth: number | null;
3772
+ lastMonthCount: number | null;
3755
3773
  lastMonthAvgPriceTarget: number | null;
3756
- lastQuarter: number | null;
3774
+ lastQuarterCount: number | null;
3757
3775
  lastQuarterAvgPriceTarget: number | null;
3758
- lastYear: number | null;
3776
+ lastYearCount: number | null;
3759
3777
  lastYearAvgPriceTarget: number | null;
3760
- allTime: number | null;
3778
+ allTimeCount: number | null;
3761
3779
  allTimeAvgPriceTarget: number | null;
3762
3780
  publishers: string | null;
3763
3781
  }>;
@@ -3792,20 +3810,21 @@ declare const DCFValuationSchema: z.ZodObject<{
3792
3810
  symbol: z.ZodString;
3793
3811
  date: z.ZodNullable<z.ZodString>;
3794
3812
  dcf: z.ZodNullable<z.ZodNumber>;
3795
- stockPrice: z.ZodNullable<z.ZodNumber>;
3813
+ "Stock Price": z.ZodNullable<z.ZodNumber>;
3796
3814
  }, "strip", z.ZodTypeAny, {
3797
3815
  symbol: string;
3798
3816
  date: string | null;
3799
- stockPrice: number | null;
3800
3817
  dcf: number | null;
3818
+ "Stock Price": number | null;
3801
3819
  }, {
3802
3820
  symbol: string;
3803
3821
  date: string | null;
3804
- stockPrice: number | null;
3805
3822
  dcf: number | null;
3823
+ "Stock Price": number | null;
3806
3824
  }>;
3807
3825
  declare const CompanyRatingSchema: z.ZodObject<{
3808
3826
  symbol: z.ZodString;
3827
+ date: z.ZodOptional<z.ZodString>;
3809
3828
  rating: z.ZodNullable<z.ZodString>;
3810
3829
  overallScore: z.ZodNullable<z.ZodNumber>;
3811
3830
  discountedCashFlowScore: z.ZodNullable<z.ZodNumber>;
@@ -3824,6 +3843,7 @@ declare const CompanyRatingSchema: z.ZodObject<{
3824
3843
  debtToEquityScore: number | null;
3825
3844
  priceToEarningsScore: number | null;
3826
3845
  priceToBookScore: number | null;
3846
+ date?: string | undefined;
3827
3847
  }, {
3828
3848
  symbol: string;
3829
3849
  rating: string | null;
@@ -3834,6 +3854,7 @@ declare const CompanyRatingSchema: z.ZodObject<{
3834
3854
  debtToEquityScore: number | null;
3835
3855
  priceToEarningsScore: number | null;
3836
3856
  priceToBookScore: number | null;
3857
+ date?: string | undefined;
3837
3858
  }>;
3838
3859
  type DCFValuation = z.infer<typeof DCFValuationSchema>;
3839
3860
  type CompanyRating = z.infer<typeof CompanyRatingSchema>;
@@ -3659,54 +3659,72 @@ type SearchResult = z.infer<typeof SearchResultSchema>;
3659
3659
  declare const AnalystEstimateSchema: z.ZodObject<{
3660
3660
  symbol: z.ZodString;
3661
3661
  date: z.ZodString;
3662
- estimatedRevenueLow: z.ZodNullable<z.ZodNumber>;
3663
- estimatedRevenueHigh: z.ZodNullable<z.ZodNumber>;
3664
- estimatedRevenueAvg: z.ZodNullable<z.ZodNumber>;
3665
- estimatedEbitdaLow: z.ZodNullable<z.ZodNumber>;
3666
- estimatedEbitdaHigh: z.ZodNullable<z.ZodNumber>;
3667
- estimatedEbitdaAvg: z.ZodNullable<z.ZodNumber>;
3668
- estimatedNetIncomeLow: z.ZodNullable<z.ZodNumber>;
3669
- estimatedNetIncomeHigh: z.ZodNullable<z.ZodNumber>;
3670
- estimatedNetIncomeAvg: z.ZodNullable<z.ZodNumber>;
3671
- estimatedEpsLow: z.ZodNullable<z.ZodNumber>;
3672
- estimatedEpsHigh: z.ZodNullable<z.ZodNumber>;
3673
- estimatedEpsAvg: z.ZodNullable<z.ZodNumber>;
3674
- numberAnalystEstimatedRevenue: z.ZodNullable<z.ZodNumber>;
3675
- numberAnalystsEstimatedEps: z.ZodNullable<z.ZodNumber>;
3662
+ revenueLow: z.ZodNullable<z.ZodNumber>;
3663
+ revenueHigh: z.ZodNullable<z.ZodNumber>;
3664
+ revenueAvg: z.ZodNullable<z.ZodNumber>;
3665
+ ebitdaLow: z.ZodNullable<z.ZodNumber>;
3666
+ ebitdaHigh: z.ZodNullable<z.ZodNumber>;
3667
+ ebitdaAvg: z.ZodNullable<z.ZodNumber>;
3668
+ ebitLow: z.ZodNullable<z.ZodNumber>;
3669
+ ebitHigh: z.ZodNullable<z.ZodNumber>;
3670
+ ebitAvg: z.ZodNullable<z.ZodNumber>;
3671
+ netIncomeLow: z.ZodNullable<z.ZodNumber>;
3672
+ netIncomeHigh: z.ZodNullable<z.ZodNumber>;
3673
+ netIncomeAvg: z.ZodNullable<z.ZodNumber>;
3674
+ sgaExpenseLow: z.ZodNullable<z.ZodNumber>;
3675
+ sgaExpenseHigh: z.ZodNullable<z.ZodNumber>;
3676
+ sgaExpenseAvg: z.ZodNullable<z.ZodNumber>;
3677
+ epsAvg: z.ZodNullable<z.ZodNumber>;
3678
+ epsHigh: z.ZodNullable<z.ZodNumber>;
3679
+ epsLow: z.ZodNullable<z.ZodNumber>;
3680
+ numAnalystsRevenue: z.ZodNullable<z.ZodNumber>;
3681
+ numAnalystsEps: z.ZodNullable<z.ZodNumber>;
3676
3682
  }, "strip", z.ZodTypeAny, {
3677
3683
  symbol: string;
3678
3684
  date: string;
3679
- estimatedRevenueLow: number | null;
3680
- estimatedRevenueHigh: number | null;
3681
- estimatedRevenueAvg: number | null;
3682
- estimatedEbitdaLow: number | null;
3683
- estimatedEbitdaHigh: number | null;
3684
- estimatedEbitdaAvg: number | null;
3685
- estimatedNetIncomeLow: number | null;
3686
- estimatedNetIncomeHigh: number | null;
3687
- estimatedNetIncomeAvg: number | null;
3688
- estimatedEpsLow: number | null;
3689
- estimatedEpsHigh: number | null;
3690
- estimatedEpsAvg: number | null;
3691
- numberAnalystEstimatedRevenue: number | null;
3692
- numberAnalystsEstimatedEps: number | null;
3685
+ revenueLow: number | null;
3686
+ revenueHigh: number | null;
3687
+ revenueAvg: number | null;
3688
+ ebitdaLow: number | null;
3689
+ ebitdaHigh: number | null;
3690
+ ebitdaAvg: number | null;
3691
+ ebitLow: number | null;
3692
+ ebitHigh: number | null;
3693
+ ebitAvg: number | null;
3694
+ netIncomeLow: number | null;
3695
+ netIncomeHigh: number | null;
3696
+ netIncomeAvg: number | null;
3697
+ sgaExpenseLow: number | null;
3698
+ sgaExpenseHigh: number | null;
3699
+ sgaExpenseAvg: number | null;
3700
+ epsAvg: number | null;
3701
+ epsHigh: number | null;
3702
+ epsLow: number | null;
3703
+ numAnalystsRevenue: number | null;
3704
+ numAnalystsEps: number | null;
3693
3705
  }, {
3694
3706
  symbol: string;
3695
3707
  date: string;
3696
- estimatedRevenueLow: number | null;
3697
- estimatedRevenueHigh: number | null;
3698
- estimatedRevenueAvg: number | null;
3699
- estimatedEbitdaLow: number | null;
3700
- estimatedEbitdaHigh: number | null;
3701
- estimatedEbitdaAvg: number | null;
3702
- estimatedNetIncomeLow: number | null;
3703
- estimatedNetIncomeHigh: number | null;
3704
- estimatedNetIncomeAvg: number | null;
3705
- estimatedEpsLow: number | null;
3706
- estimatedEpsHigh: number | null;
3707
- estimatedEpsAvg: number | null;
3708
- numberAnalystEstimatedRevenue: number | null;
3709
- numberAnalystsEstimatedEps: number | null;
3708
+ revenueLow: number | null;
3709
+ revenueHigh: number | null;
3710
+ revenueAvg: number | null;
3711
+ ebitdaLow: number | null;
3712
+ ebitdaHigh: number | null;
3713
+ ebitdaAvg: number | null;
3714
+ ebitLow: number | null;
3715
+ ebitHigh: number | null;
3716
+ ebitAvg: number | null;
3717
+ netIncomeLow: number | null;
3718
+ netIncomeHigh: number | null;
3719
+ netIncomeAvg: number | null;
3720
+ sgaExpenseLow: number | null;
3721
+ sgaExpenseHigh: number | null;
3722
+ sgaExpenseAvg: number | null;
3723
+ epsAvg: number | null;
3724
+ epsHigh: number | null;
3725
+ epsLow: number | null;
3726
+ numAnalystsRevenue: number | null;
3727
+ numAnalystsEps: number | null;
3710
3728
  }>;
3711
3729
  declare const PriceTargetConsensusSchema: z.ZodObject<{
3712
3730
  symbol: z.ZodString;
@@ -3729,35 +3747,35 @@ declare const PriceTargetConsensusSchema: z.ZodObject<{
3729
3747
  }>;
3730
3748
  declare const PriceTargetSummarySchema: z.ZodObject<{
3731
3749
  symbol: z.ZodString;
3732
- lastMonth: z.ZodNullable<z.ZodNumber>;
3750
+ lastMonthCount: z.ZodNullable<z.ZodNumber>;
3733
3751
  lastMonthAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3734
- lastQuarter: z.ZodNullable<z.ZodNumber>;
3752
+ lastQuarterCount: z.ZodNullable<z.ZodNumber>;
3735
3753
  lastQuarterAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3736
- lastYear: z.ZodNullable<z.ZodNumber>;
3754
+ lastYearCount: z.ZodNullable<z.ZodNumber>;
3737
3755
  lastYearAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3738
- allTime: z.ZodNullable<z.ZodNumber>;
3756
+ allTimeCount: z.ZodNullable<z.ZodNumber>;
3739
3757
  allTimeAvgPriceTarget: z.ZodNullable<z.ZodNumber>;
3740
3758
  publishers: z.ZodNullable<z.ZodString>;
3741
3759
  }, "strip", z.ZodTypeAny, {
3742
3760
  symbol: string;
3743
- lastMonth: number | null;
3761
+ lastMonthCount: number | null;
3744
3762
  lastMonthAvgPriceTarget: number | null;
3745
- lastQuarter: number | null;
3763
+ lastQuarterCount: number | null;
3746
3764
  lastQuarterAvgPriceTarget: number | null;
3747
- lastYear: number | null;
3765
+ lastYearCount: number | null;
3748
3766
  lastYearAvgPriceTarget: number | null;
3749
- allTime: number | null;
3767
+ allTimeCount: number | null;
3750
3768
  allTimeAvgPriceTarget: number | null;
3751
3769
  publishers: string | null;
3752
3770
  }, {
3753
3771
  symbol: string;
3754
- lastMonth: number | null;
3772
+ lastMonthCount: number | null;
3755
3773
  lastMonthAvgPriceTarget: number | null;
3756
- lastQuarter: number | null;
3774
+ lastQuarterCount: number | null;
3757
3775
  lastQuarterAvgPriceTarget: number | null;
3758
- lastYear: number | null;
3776
+ lastYearCount: number | null;
3759
3777
  lastYearAvgPriceTarget: number | null;
3760
- allTime: number | null;
3778
+ allTimeCount: number | null;
3761
3779
  allTimeAvgPriceTarget: number | null;
3762
3780
  publishers: string | null;
3763
3781
  }>;
@@ -3792,20 +3810,21 @@ declare const DCFValuationSchema: z.ZodObject<{
3792
3810
  symbol: z.ZodString;
3793
3811
  date: z.ZodNullable<z.ZodString>;
3794
3812
  dcf: z.ZodNullable<z.ZodNumber>;
3795
- stockPrice: z.ZodNullable<z.ZodNumber>;
3813
+ "Stock Price": z.ZodNullable<z.ZodNumber>;
3796
3814
  }, "strip", z.ZodTypeAny, {
3797
3815
  symbol: string;
3798
3816
  date: string | null;
3799
- stockPrice: number | null;
3800
3817
  dcf: number | null;
3818
+ "Stock Price": number | null;
3801
3819
  }, {
3802
3820
  symbol: string;
3803
3821
  date: string | null;
3804
- stockPrice: number | null;
3805
3822
  dcf: number | null;
3823
+ "Stock Price": number | null;
3806
3824
  }>;
3807
3825
  declare const CompanyRatingSchema: z.ZodObject<{
3808
3826
  symbol: z.ZodString;
3827
+ date: z.ZodOptional<z.ZodString>;
3809
3828
  rating: z.ZodNullable<z.ZodString>;
3810
3829
  overallScore: z.ZodNullable<z.ZodNumber>;
3811
3830
  discountedCashFlowScore: z.ZodNullable<z.ZodNumber>;
@@ -3824,6 +3843,7 @@ declare const CompanyRatingSchema: z.ZodObject<{
3824
3843
  debtToEquityScore: number | null;
3825
3844
  priceToEarningsScore: number | null;
3826
3845
  priceToBookScore: number | null;
3846
+ date?: string | undefined;
3827
3847
  }, {
3828
3848
  symbol: string;
3829
3849
  rating: string | null;
@@ -3834,6 +3854,7 @@ declare const CompanyRatingSchema: z.ZodObject<{
3834
3854
  debtToEquityScore: number | null;
3835
3855
  priceToEarningsScore: number | null;
3836
3856
  priceToBookScore: number | null;
3857
+ date?: string | undefined;
3837
3858
  }>;
3838
3859
  type DCFValuation = z.infer<typeof DCFValuationSchema>;
3839
3860
  type CompanyRating = z.infer<typeof CompanyRatingSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fmp-node-api",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.2.0-beta.4",
4
4
  "description": "A comprehensive Node.js wrapper for Financial Modeling Prep API",
5
5
  "disclaimer": "This package is not affiliated with, endorsed by, or sponsored by Financial Modeling Prep (FMP). This is an independent, community-developed wrapper.",
6
6
  "main": "./dist/index.js",
@@ -55,7 +55,7 @@
55
55
  "tsx": "^4.7.0",
56
56
  "typescript": "^5.3.3",
57
57
  "zod": "^3.25.76",
58
- "fmp-node-types": "0.2.0-beta.3"
58
+ "fmp-node-types": "0.2.0-beta.4"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsup",