sentisense 0.30.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -87,6 +87,61 @@ interface StockEntity {
87
87
  type: string;
88
88
  [key: string]: unknown;
89
89
  }
90
+ /** Per-source tone for a stock: where the conversation is, and how it leans. */
91
+ interface SentimentSourceTone {
92
+ source: string;
93
+ /** "Bullish" | "Neutral" | "Bearish". */
94
+ direction: string;
95
+ /** Share of this stock's mentions coming from this source. */
96
+ mentionShare: number;
97
+ /** Exact polarity in [-1, 1]. */
98
+ value?: number;
99
+ }
100
+ /** A news story moving a stock's sentiment, with its own tone. */
101
+ interface SentimentDriver {
102
+ title: string;
103
+ /** Tone of this driver in [-1, 1]. */
104
+ tone: number;
105
+ }
106
+ interface StockSentiment {
107
+ ticker: string;
108
+ companyName?: string;
109
+ /** ISO date (YYYY-MM-DD) the data is current as of. */
110
+ asOf?: string;
111
+ /** Latest SentiSense Score: a 0-centered composite of sentiment and mentions, unbounded. */
112
+ sentisenseScore?: number;
113
+ /** 30-day average Score, the stable regime figure. */
114
+ sentisenseScoreAvg30d?: number;
115
+ sentisenseScoreDelta30d?: number;
116
+ /** Seven-band label of the 30-day average. */
117
+ scoreLabel?: string;
118
+ /** "Bullish" | "Neutral" | "Bearish", from the 30-day average. */
119
+ direction?: string;
120
+ /** Same three bands, from today's read. */
121
+ latestDirection?: string;
122
+ /** "UP" | "DOWN" | "FLAT". */
123
+ trend?: string;
124
+ /** Daily Score series. */
125
+ scoreSparkline?: number[];
126
+ /** Today's mention volume. */
127
+ mentions?: number;
128
+ /** 30-day average mentions per day. */
129
+ mentionsAvg30d?: number;
130
+ socialDominance?: number;
131
+ bySource?: SentimentSourceTone[];
132
+ relatedTickers?: Array<{
133
+ ticker: string;
134
+ name: string;
135
+ }>;
136
+ drivers?: SentimentDriver[];
137
+ /** Plain-language summary of why the Score sits where it does. */
138
+ narrative?: string;
139
+ faq?: Array<{
140
+ question: string;
141
+ answer: string;
142
+ }>;
143
+ [key: string]: unknown;
144
+ }
90
145
  interface ChartDataPoint {
91
146
  /** Unix timestamp in milliseconds. */
92
147
  timestamp?: number;
@@ -112,9 +167,47 @@ interface MarketStatus {
112
167
  status: string;
113
168
  [key: string]: unknown;
114
169
  }
170
+ /**
171
+ * One period of filed financial statement data from `stocks.getFundamentals()`.
172
+ *
173
+ * The index signature is deliberate: the response carries the full income statement, balance
174
+ * sheet, and cash flow line items, and more are added over time, so every field is reachable
175
+ * whether or not it is typed here. The cash-flow block below is typed because its sign and
176
+ * relationships are easy to get wrong.
177
+ */
115
178
  interface Fundamentals {
116
179
  ticker: string;
117
180
  timeframe: string;
181
+ /**
182
+ * The currency the filer reports in ("USD", "KRW", "EUR", ...). Statement figures are as
183
+ * reported in this currency and are never converted to US dollars: foreign companies listed
184
+ * as ADRs file in their home currency while their listed share price is in USD. Absent means
185
+ * the currency is unknown, not implicitly USD. For non-USD filers the API serves `peRatio`,
186
+ * `psRatio`, and `pbRatio` as `null` on purpose (a USD price over a home-currency per-share
187
+ * figure is a unit mismatch); do not recompute them client-side.
188
+ */
189
+ reportedCurrency?: string;
190
+ /** Net cash from operating activities, in the reporting currency (see `reportedCurrency`). */
191
+ operatingCashFlow?: number | null;
192
+ /** Net cash from investing activities, in the reporting currency. */
193
+ investingCashFlow?: number | null;
194
+ /** Net cash from financing activities, in the reporting currency. */
195
+ financingCashFlow?: number | null;
196
+ /**
197
+ * Capital expenditure, in the reporting currency, signed as filed: normally NEGATIVE,
198
+ * because it is an outflow. Take the absolute value before treating it as a magnitude.
199
+ */
200
+ capitalExpenditure?: number | null;
201
+ /**
202
+ * Free cash flow, in the reporting currency: `operatingCashFlow - Math.abs(capitalExpenditure)`.
203
+ *
204
+ * `null` rather than a guess when the period's capital expenditure is not available, so a
205
+ * screen for positive free cash flow can never match on a fabricated number. Do not
206
+ * substitute `operatingCashFlow + investingCashFlow`: investing cash flow also carries
207
+ * marketable-securities and acquisition activity, which for a company holding a large
208
+ * securities portfolio is wrong by billions and can flip the sign.
209
+ */
210
+ freeCashFlow?: number | null;
118
211
  [key: string]: unknown;
119
212
  }
120
213
  /**
@@ -169,7 +262,14 @@ interface AISummary {
169
262
  [key: string]: unknown;
170
263
  }
171
264
  interface GetChartOptions {
172
- timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "ALL";
265
+ /**
266
+ * Chart range. "MAX" returns the full available history (up to ~26 years); "10Y" and "5Y"
267
+ * return weekly bars. Ranges of "5Y" and longer are split- and dividend-adjusted; shorter
268
+ * ranges are split-adjusted only.
269
+ *
270
+ * "ALL" is a legacy alias of "5Y", retained so existing code keeps compiling.
271
+ */
272
+ timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "10Y" | "MAX" | "ALL";
173
273
  }
174
274
  interface GetImagesOptions {
175
275
  forced?: boolean;
@@ -1089,14 +1189,15 @@ declare class EntityMetrics {
1089
1189
  /**
1090
1190
  * Get time-series metric data for an entity using the v2 Serving Metrics API.
1091
1191
  *
1092
- * @param symbol Ticker symbol (e.g. "AAPL") — the backend resolves the entity.
1192
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
1193
+ * case-insensitive; discover slugs via stocks.getEntities()).
1093
1194
  * @param options Metric type and optional time range / resolution.
1094
1195
  */
1095
1196
  getMetrics(symbol: string, options?: MetricsOptions): Promise<ServingMetric[]>;
1096
1197
  /**
1097
1198
  * Get distribution data for a metric, broken down by a dimension (default: source).
1098
1199
  *
1099
- * @param symbol Ticker symbol (e.g. "AAPL").
1200
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
1100
1201
  * @param metricType The metric to break down (e.g. "mentions", "sentiment").
1101
1202
  * @param options Optional dimension parameter.
1102
1203
  */
@@ -1447,8 +1548,6 @@ declare class KB {
1447
1548
  constructor(client: APIClient);
1448
1549
  /** Get popular entities for search suggestions. */
1449
1550
  getPopularEntities(): Promise<KBEntity[]>;
1450
- /** Get all tracked entities. */
1451
- getAllEntities(): Promise<KBEntity[]>;
1452
1551
  }
1453
1552
 
1454
1553
  declare class MarketMoodResource {
@@ -1494,6 +1593,18 @@ declare class Stocks {
1494
1593
  getSimilar(ticker: string, options?: GetSimilarOptions): Promise<SimilarStock[]>;
1495
1594
  /** Get company profile (CEO, sector, industry, market data). */
1496
1595
  getProfile(ticker: string, options?: GetProfileOptions): Promise<StockProfile>;
1596
+ /**
1597
+ * Get the headline sentiment picture for a stock in one call.
1598
+ *
1599
+ * Returns the SentiSense Score with its 30-day regime, mention volume and social
1600
+ * dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
1601
+ * narrative and an FAQ. Available in full on every API-key tier.
1602
+ *
1603
+ * Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
1604
+ * series over a specific window rather than the headline read. Returns 404 for tickers
1605
+ * with no sentiment coverage.
1606
+ */
1607
+ getSentiment(ticker: string): Promise<PreviewResponse<StockSentiment>>;
1497
1608
  /** Get related KB entities (people, products, partners). */
1498
1609
  getEntities(ticker: string): Promise<StockEntity[]>;
1499
1610
  /** Get AI-generated stock analysis report. Requires PRO tier. */
@@ -1510,7 +1621,13 @@ declare class Stocks {
1510
1621
  getChart(ticker: string, options?: GetChartOptions): Promise<ChartData>;
1511
1622
  /** Get current market open/closed/pre-market/after-hours status. */
1512
1623
  getMarketStatus(): Promise<MarketStatus>;
1513
- /** Get financial statement data. */
1624
+ /**
1625
+ * Get financial statement data for one reporting period: income statement, balance sheet,
1626
+ * and cash flow, including `capitalExpenditure` and `freeCashFlow`.
1627
+ *
1628
+ * Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
1629
+ * for the free-cash-flow relationship and when it is `null`.
1630
+ */
1514
1631
  getFundamentals(ticker: string, options?: GetFundamentalsOptions): Promise<Fundamentals>;
1515
1632
  /** Get available fiscal periods. The periods are in `periods`. */
1516
1633
  getFundamentalsPeriods(ticker: string): Promise<FundamentalsPeriodsResponse>;
@@ -1634,6 +1751,17 @@ declare class AuthenticationError extends SentiSenseError {
1634
1751
  declare class NotFoundError extends SentiSenseError {
1635
1752
  constructor(message: string, code?: string);
1636
1753
  }
1754
+ /**
1755
+ * Thrown when a deep chart range is still being assembled.
1756
+ *
1757
+ * The API answers 202 for "10Y" and "MAX" the first time a rarely-requested stock is asked
1758
+ * for. It deliberately does not substitute a shorter range, so a successful response always
1759
+ * carries the timeframe you asked for. Retry after a few seconds.
1760
+ */
1761
+ declare class DeepHistoryUnavailableError extends SentiSenseError {
1762
+ retryAfter?: number;
1763
+ constructor(message: string, retryAfter?: number);
1764
+ }
1637
1765
  declare class RateLimitError extends SentiSenseError {
1638
1766
  retryAfter?: number;
1639
1767
  constructor(message: string, code?: string, retryAfter?: number);
@@ -1642,6 +1770,6 @@ declare class APIError extends SentiSenseError {
1642
1770
  constructor(message: string, status: number, code?: string);
1643
1771
  }
1644
1772
 
1645
- declare const VERSION = "0.30.0";
1773
+ declare const VERSION = "0.33.0";
1646
1774
 
1647
- export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
1775
+ export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, DeepHistoryUnavailableError, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
package/dist/index.d.ts CHANGED
@@ -87,6 +87,61 @@ interface StockEntity {
87
87
  type: string;
88
88
  [key: string]: unknown;
89
89
  }
90
+ /** Per-source tone for a stock: where the conversation is, and how it leans. */
91
+ interface SentimentSourceTone {
92
+ source: string;
93
+ /** "Bullish" | "Neutral" | "Bearish". */
94
+ direction: string;
95
+ /** Share of this stock's mentions coming from this source. */
96
+ mentionShare: number;
97
+ /** Exact polarity in [-1, 1]. */
98
+ value?: number;
99
+ }
100
+ /** A news story moving a stock's sentiment, with its own tone. */
101
+ interface SentimentDriver {
102
+ title: string;
103
+ /** Tone of this driver in [-1, 1]. */
104
+ tone: number;
105
+ }
106
+ interface StockSentiment {
107
+ ticker: string;
108
+ companyName?: string;
109
+ /** ISO date (YYYY-MM-DD) the data is current as of. */
110
+ asOf?: string;
111
+ /** Latest SentiSense Score: a 0-centered composite of sentiment and mentions, unbounded. */
112
+ sentisenseScore?: number;
113
+ /** 30-day average Score, the stable regime figure. */
114
+ sentisenseScoreAvg30d?: number;
115
+ sentisenseScoreDelta30d?: number;
116
+ /** Seven-band label of the 30-day average. */
117
+ scoreLabel?: string;
118
+ /** "Bullish" | "Neutral" | "Bearish", from the 30-day average. */
119
+ direction?: string;
120
+ /** Same three bands, from today's read. */
121
+ latestDirection?: string;
122
+ /** "UP" | "DOWN" | "FLAT". */
123
+ trend?: string;
124
+ /** Daily Score series. */
125
+ scoreSparkline?: number[];
126
+ /** Today's mention volume. */
127
+ mentions?: number;
128
+ /** 30-day average mentions per day. */
129
+ mentionsAvg30d?: number;
130
+ socialDominance?: number;
131
+ bySource?: SentimentSourceTone[];
132
+ relatedTickers?: Array<{
133
+ ticker: string;
134
+ name: string;
135
+ }>;
136
+ drivers?: SentimentDriver[];
137
+ /** Plain-language summary of why the Score sits where it does. */
138
+ narrative?: string;
139
+ faq?: Array<{
140
+ question: string;
141
+ answer: string;
142
+ }>;
143
+ [key: string]: unknown;
144
+ }
90
145
  interface ChartDataPoint {
91
146
  /** Unix timestamp in milliseconds. */
92
147
  timestamp?: number;
@@ -112,9 +167,47 @@ interface MarketStatus {
112
167
  status: string;
113
168
  [key: string]: unknown;
114
169
  }
170
+ /**
171
+ * One period of filed financial statement data from `stocks.getFundamentals()`.
172
+ *
173
+ * The index signature is deliberate: the response carries the full income statement, balance
174
+ * sheet, and cash flow line items, and more are added over time, so every field is reachable
175
+ * whether or not it is typed here. The cash-flow block below is typed because its sign and
176
+ * relationships are easy to get wrong.
177
+ */
115
178
  interface Fundamentals {
116
179
  ticker: string;
117
180
  timeframe: string;
181
+ /**
182
+ * The currency the filer reports in ("USD", "KRW", "EUR", ...). Statement figures are as
183
+ * reported in this currency and are never converted to US dollars: foreign companies listed
184
+ * as ADRs file in their home currency while their listed share price is in USD. Absent means
185
+ * the currency is unknown, not implicitly USD. For non-USD filers the API serves `peRatio`,
186
+ * `psRatio`, and `pbRatio` as `null` on purpose (a USD price over a home-currency per-share
187
+ * figure is a unit mismatch); do not recompute them client-side.
188
+ */
189
+ reportedCurrency?: string;
190
+ /** Net cash from operating activities, in the reporting currency (see `reportedCurrency`). */
191
+ operatingCashFlow?: number | null;
192
+ /** Net cash from investing activities, in the reporting currency. */
193
+ investingCashFlow?: number | null;
194
+ /** Net cash from financing activities, in the reporting currency. */
195
+ financingCashFlow?: number | null;
196
+ /**
197
+ * Capital expenditure, in the reporting currency, signed as filed: normally NEGATIVE,
198
+ * because it is an outflow. Take the absolute value before treating it as a magnitude.
199
+ */
200
+ capitalExpenditure?: number | null;
201
+ /**
202
+ * Free cash flow, in the reporting currency: `operatingCashFlow - Math.abs(capitalExpenditure)`.
203
+ *
204
+ * `null` rather than a guess when the period's capital expenditure is not available, so a
205
+ * screen for positive free cash flow can never match on a fabricated number. Do not
206
+ * substitute `operatingCashFlow + investingCashFlow`: investing cash flow also carries
207
+ * marketable-securities and acquisition activity, which for a company holding a large
208
+ * securities portfolio is wrong by billions and can flip the sign.
209
+ */
210
+ freeCashFlow?: number | null;
118
211
  [key: string]: unknown;
119
212
  }
120
213
  /**
@@ -169,7 +262,14 @@ interface AISummary {
169
262
  [key: string]: unknown;
170
263
  }
171
264
  interface GetChartOptions {
172
- timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "ALL";
265
+ /**
266
+ * Chart range. "MAX" returns the full available history (up to ~26 years); "10Y" and "5Y"
267
+ * return weekly bars. Ranges of "5Y" and longer are split- and dividend-adjusted; shorter
268
+ * ranges are split-adjusted only.
269
+ *
270
+ * "ALL" is a legacy alias of "5Y", retained so existing code keeps compiling.
271
+ */
272
+ timeframe?: "1D" | "5D" | "1W" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "10Y" | "MAX" | "ALL";
173
273
  }
174
274
  interface GetImagesOptions {
175
275
  forced?: boolean;
@@ -1089,14 +1189,15 @@ declare class EntityMetrics {
1089
1189
  /**
1090
1190
  * Get time-series metric data for an entity using the v2 Serving Metrics API.
1091
1191
  *
1092
- * @param symbol Ticker symbol (e.g. "AAPL") — the backend resolves the entity.
1192
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
1193
+ * case-insensitive; discover slugs via stocks.getEntities()).
1093
1194
  * @param options Metric type and optional time range / resolution.
1094
1195
  */
1095
1196
  getMetrics(symbol: string, options?: MetricsOptions): Promise<ServingMetric[]>;
1096
1197
  /**
1097
1198
  * Get distribution data for a metric, broken down by a dimension (default: source).
1098
1199
  *
1099
- * @param symbol Ticker symbol (e.g. "AAPL").
1200
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
1100
1201
  * @param metricType The metric to break down (e.g. "mentions", "sentiment").
1101
1202
  * @param options Optional dimension parameter.
1102
1203
  */
@@ -1447,8 +1548,6 @@ declare class KB {
1447
1548
  constructor(client: APIClient);
1448
1549
  /** Get popular entities for search suggestions. */
1449
1550
  getPopularEntities(): Promise<KBEntity[]>;
1450
- /** Get all tracked entities. */
1451
- getAllEntities(): Promise<KBEntity[]>;
1452
1551
  }
1453
1552
 
1454
1553
  declare class MarketMoodResource {
@@ -1494,6 +1593,18 @@ declare class Stocks {
1494
1593
  getSimilar(ticker: string, options?: GetSimilarOptions): Promise<SimilarStock[]>;
1495
1594
  /** Get company profile (CEO, sector, industry, market data). */
1496
1595
  getProfile(ticker: string, options?: GetProfileOptions): Promise<StockProfile>;
1596
+ /**
1597
+ * Get the headline sentiment picture for a stock in one call.
1598
+ *
1599
+ * Returns the SentiSense Score with its 30-day regime, mention volume and social
1600
+ * dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
1601
+ * narrative and an FAQ. Available in full on every API-key tier.
1602
+ *
1603
+ * Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
1604
+ * series over a specific window rather than the headline read. Returns 404 for tickers
1605
+ * with no sentiment coverage.
1606
+ */
1607
+ getSentiment(ticker: string): Promise<PreviewResponse<StockSentiment>>;
1497
1608
  /** Get related KB entities (people, products, partners). */
1498
1609
  getEntities(ticker: string): Promise<StockEntity[]>;
1499
1610
  /** Get AI-generated stock analysis report. Requires PRO tier. */
@@ -1510,7 +1621,13 @@ declare class Stocks {
1510
1621
  getChart(ticker: string, options?: GetChartOptions): Promise<ChartData>;
1511
1622
  /** Get current market open/closed/pre-market/after-hours status. */
1512
1623
  getMarketStatus(): Promise<MarketStatus>;
1513
- /** Get financial statement data. */
1624
+ /**
1625
+ * Get financial statement data for one reporting period: income statement, balance sheet,
1626
+ * and cash flow, including `capitalExpenditure` and `freeCashFlow`.
1627
+ *
1628
+ * Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
1629
+ * for the free-cash-flow relationship and when it is `null`.
1630
+ */
1514
1631
  getFundamentals(ticker: string, options?: GetFundamentalsOptions): Promise<Fundamentals>;
1515
1632
  /** Get available fiscal periods. The periods are in `periods`. */
1516
1633
  getFundamentalsPeriods(ticker: string): Promise<FundamentalsPeriodsResponse>;
@@ -1634,6 +1751,17 @@ declare class AuthenticationError extends SentiSenseError {
1634
1751
  declare class NotFoundError extends SentiSenseError {
1635
1752
  constructor(message: string, code?: string);
1636
1753
  }
1754
+ /**
1755
+ * Thrown when a deep chart range is still being assembled.
1756
+ *
1757
+ * The API answers 202 for "10Y" and "MAX" the first time a rarely-requested stock is asked
1758
+ * for. It deliberately does not substitute a shorter range, so a successful response always
1759
+ * carries the timeframe you asked for. Retry after a few seconds.
1760
+ */
1761
+ declare class DeepHistoryUnavailableError extends SentiSenseError {
1762
+ retryAfter?: number;
1763
+ constructor(message: string, retryAfter?: number);
1764
+ }
1637
1765
  declare class RateLimitError extends SentiSenseError {
1638
1766
  retryAfter?: number;
1639
1767
  constructor(message: string, code?: string, retryAfter?: number);
@@ -1642,6 +1770,6 @@ declare class APIError extends SentiSenseError {
1642
1770
  constructor(message: string, status: number, code?: string);
1643
1771
  }
1644
1772
 
1645
- declare const VERSION = "0.30.0";
1773
+ declare const VERSION = "0.33.0";
1646
1774
 
1647
- export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
1775
+ export { type AISummary, APIError, type AnalystAction, type AnalystConsensus, type AnalystEarningsSurprise, type AnalystEstimate, type AnalystEstimatesResponse, type AssetMetadata, AuthenticationError, type CalendarMeta, type ChartData, type ChartDataPoint, type ClusterBuy, type CompanyKpisData, type CongressTrade, DeepHistoryUnavailableError, type Document, type DocumentSearchResponse, type DocumentSource, type EarningsCalendarResponse, type EarningsEvent, type EtfAggregateCoverage, type EtfAnalystAggregate, type EtfAnalystContributor, type EtfHolding, type EtfHoldings, type EtfInfo, type EtfInsiderAggregate, type EtfInsiderContributor, type EtfSentimentAggregate, type EtfSentimentReading, type FloatInfo, type Fundamentals, type FundamentalsPeriod, type FundamentalsPeriodsResponse, type GetAnalystActionsOptions, type GetAnalystMarketActivityOptions, type GetEarningsCalendarOptions, type GetEtfInsiderAggregateOptions, type GetInsiderOptions, type GetInsightsOptions, type GetLatestInsightsOptions, type GetPoliticiansOptions, type GetStockInsightsRangeOptions, type GetUserInsightsOptions, type Holder, type InsiderActivityResponse, type InsiderActivitySummary, type InsiderTrade, type Insight, type InsightPreviewResponse, type InstitutionList, type InstitutionListResponse, type InstitutionSummary, type InstitutionalFlow, type InstitutionalFlows, type InstitutionalFlowsResponse, type KBEntity, type KpiCoverageEntry, type KpiCoverageResponse, type KpiDataPoint, type KpiSeries, type KpiTypeEntry, type ListInstitutionsOptions, type LockedInsight, type MarketMood, type MarketStatus, type MarketSummary, type MetricDistribution, type MetricDistributionOptions, type MetricType, type MetricsBreakdown, type MetricsOptions, NotFoundError, type PoliticianDetail, type PoliticianSummary, type PreviewResponse, type Quarter, RateLimitError, SentiSense, SentiSenseError, type SentiSenseOptions, type SentimentEntry, type ServingMetric, type ShortInterest, type ShortVolume, type SimilarStock, type StockDetail, type StockEntity, type StockImage, type StockPrice, type StockProfile, type StockQuote, type Story, type StoryCluster, type TickerHolders, type TrackerEvent, type TrackerGeoEntry, type TrackerHeadlineMetric, type TrackerListResponse, type TrackerListing, type TrackerMetricValue, type TrackerSignal, type TrackerSnapshot, type TrackerSnapshotResponse, type TrackerSourceRef, type TrackerTableRow, type TrackerTimeSeriesPoint, type TtmFundamentals, VERSION, type WeightedConsensus, type WeightedNetFlow, SentiSense as default };
package/dist/index.mjs CHANGED
@@ -19,6 +19,13 @@ var NotFoundError = class extends SentiSenseError {
19
19
  this.name = "NotFoundError";
20
20
  }
21
21
  };
22
+ var DeepHistoryUnavailableError = class extends SentiSenseError {
23
+ constructor(message, retryAfter) {
24
+ super(message, 202);
25
+ this.name = "DeepHistoryUnavailableError";
26
+ this.retryAfter = retryAfter;
27
+ }
28
+ };
22
29
  var RateLimitError = class extends SentiSenseError {
23
30
  constructor(message, code, retryAfter) {
24
31
  super(message, 429, code);
@@ -152,7 +159,8 @@ var EntityMetrics = class {
152
159
  /**
153
160
  * Get time-series metric data for an entity using the v2 Serving Metrics API.
154
161
  *
155
- * @param symbol Ticker symbol (e.g. "AAPL") — the backend resolves the entity.
162
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug (e.g. "Nancy-Pelosi",
163
+ * case-insensitive; discover slugs via stocks.getEntities()).
156
164
  * @param options Metric type and optional time range / resolution.
157
165
  */
158
166
  async getMetrics(symbol, options = {}) {
@@ -169,7 +177,7 @@ var EntityMetrics = class {
169
177
  /**
170
178
  * Get distribution data for a metric, broken down by a dimension (default: source).
171
179
  *
172
- * @param symbol Ticker symbol (e.g. "AAPL").
180
+ * @param symbol Ticker symbol (e.g. "AAPL") or entity urlSlug.
173
181
  * @param metricType The metric to break down (e.g. "mentions", "sentiment").
174
182
  * @param options Optional dimension parameter.
175
183
  */
@@ -477,10 +485,6 @@ var KB = class {
477
485
  async getPopularEntities() {
478
486
  return this.client.get("/api/v1/kb/entities/popular");
479
487
  }
480
- /** Get all tracked entities. */
481
- async getAllEntities() {
482
- return this.client.get("/api/v1/kb/entities/all");
483
- }
484
488
  };
485
489
 
486
490
  // src/resources/marketMood.ts
@@ -568,6 +572,22 @@ var Stocks = class {
568
572
  async getProfile(ticker, options) {
569
573
  return this.client.get(`/api/v1/stocks/${encodeURIComponent(ticker)}/profile`, options);
570
574
  }
575
+ /**
576
+ * Get the headline sentiment picture for a stock in one call.
577
+ *
578
+ * Returns the SentiSense Score with its 30-day regime, mention volume and social
579
+ * dominance, per-source tone in `bySource`, plus related tickers, story drivers, a
580
+ * narrative and an FAQ. Available in full on every API-key tier.
581
+ *
582
+ * Use `entityMetrics.getMetrics(ticker, "sentiment", ...)` instead when you need a time
583
+ * series over a specific window rather than the headline read. Returns 404 for tickers
584
+ * with no sentiment coverage.
585
+ */
586
+ async getSentiment(ticker) {
587
+ return this.client.get(
588
+ `/api/v1/stocks/${encodeURIComponent(ticker)}/sentiment`
589
+ );
590
+ }
571
591
  /** Get related KB entities (people, products, partners). */
572
592
  async getEntities(ticker) {
573
593
  return this.client.get(`/api/v1/stocks/${encodeURIComponent(ticker)}/entities`);
@@ -601,7 +621,13 @@ var Stocks = class {
601
621
  async getMarketStatus() {
602
622
  return this.client.get("/api/v1/stocks/market-status");
603
623
  }
604
- /** Get financial statement data. */
624
+ /**
625
+ * Get financial statement data for one reporting period: income statement, balance sheet,
626
+ * and cash flow, including `capitalExpenditure` and `freeCashFlow`.
627
+ *
628
+ * Capital expenditure is signed as filed, so normally negative. See {@link Fundamentals}
629
+ * for the free-cash-flow relationship and when it is `null`.
630
+ */
605
631
  async getFundamentals(ticker, options) {
606
632
  return this.client.get("/api/v1/stocks/fundamentals", { ticker, ...options });
607
633
  }
@@ -703,7 +729,7 @@ var Trackers = class {
703
729
  };
704
730
 
705
731
  // src/version.ts
706
- var VERSION = "0.30.0";
732
+ var VERSION = "0.33.0";
707
733
 
708
734
  // src/client.ts
709
735
  var DEFAULT_BASE_URL = "https://app.sentisense.ai";
@@ -711,6 +737,16 @@ var DEFAULT_TIMEOUT = 3e4;
711
737
  var DEFAULT_MAX_RETRIES = 3;
712
738
  var BASE_DELAY_MS = 1e3;
713
739
  var MAX_DELAY_MS = 6e4;
740
+ var DEEP_HISTORY_FALLBACK_WAIT_S = 3;
741
+ var MAX_DEEP_HISTORY_WAIT_S = 30;
742
+ var MAX_RATE_LIMIT_WAIT_S = 120;
743
+ var RATE_LIMIT_FALLBACK_WAIT_S = 60;
744
+ function retryAfterSeconds(raw, defaultS, maxWaitS) {
745
+ if (!raw) return defaultS;
746
+ const parsed = Number(raw);
747
+ if (!Number.isFinite(parsed)) return defaultS;
748
+ return Math.min(Math.max(0.5, parsed), maxWaitS);
749
+ }
714
750
  function sleep(ms) {
715
751
  return new Promise((resolve) => setTimeout(resolve, ms));
716
752
  }
@@ -761,12 +797,34 @@ var SentiSense = class {
761
797
  headers,
762
798
  signal: controller.signal
763
799
  });
800
+ if (response.status === 202) {
801
+ const waitSeconds = retryAfterSeconds(
802
+ response.headers.get("Retry-After"),
803
+ DEEP_HISTORY_FALLBACK_WAIT_S,
804
+ MAX_DEEP_HISTORY_WAIT_S
805
+ );
806
+ try {
807
+ await response.body?.cancel();
808
+ } catch {
809
+ }
810
+ if (attempt < this.maxRetries) {
811
+ delayMs = waitSeconds * 1e3;
812
+ continue;
813
+ }
814
+ throw new DeepHistoryUnavailableError(
815
+ "Deep history is still being assembled. Retry in a few seconds.",
816
+ waitSeconds
817
+ );
818
+ }
764
819
  if (!response.ok) {
765
820
  const isRetryable = response.status === 429 || response.status >= 500;
766
821
  if (isRetryable && attempt < this.maxRetries) {
767
822
  if (response.status === 429) {
768
- const ra = response.headers.get("Retry-After");
769
- delayMs = (ra ? parseInt(ra, 10) : 60) * 1e3;
823
+ delayMs = retryAfterSeconds(
824
+ response.headers.get("Retry-After"),
825
+ RATE_LIMIT_FALLBACK_WAIT_S,
826
+ MAX_RATE_LIMIT_WAIT_S
827
+ ) * 1e3;
770
828
  } else {
771
829
  delayMs = Math.min(BASE_DELAY_MS * Math.pow(2, attempt), MAX_DELAY_MS) + Math.random() * 1e3;
772
830
  }
@@ -868,6 +926,7 @@ var SentiSense = class {
868
926
  export {
869
927
  APIError,
870
928
  AuthenticationError,
929
+ DeepHistoryUnavailableError,
871
930
  NotFoundError,
872
931
  RateLimitError,
873
932
  SentiSense,