pub struct Client { /* private fields */ }Expand description
Reusable, asynchronous FMP connector. Clones share the connection pool. API keys travel in a sensitive header, and redirects are rejected.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn probe_access<Q>(
&self,
path: &str,
params: &Q,
) -> Result<AccessReport>
pub async fn probe_access<Q>( &self, path: &str, params: &Q, ) -> Result<AccessReport>
Verifies whether the key can call an endpoint with these parameters.
This costs a real API request. Invalid keys, rate limits, outages, and
unclassified forbidden responses propagate as errors; they never become
evidence of a lower plan. FMP does not expose a documented billing-plan
lookup, so the report keeps the configured plan separate from the result.
Successful bodies are not checked against a dataset schema; use a typed
endpoint method or get when the data itself must also be validated.
Source§impl Client
impl Client
Sourcepub fn new(api_key: &str, subscription: Subscription) -> Result<Self>
pub fn new(api_key: &str, subscription: Subscription) -> Result<Self>
Creates a client for the Stable API with a 30-second timeout and two transient-error retries. The supplied subscription is user configuration.
Sourcepub fn with_config(
api_key: &str,
subscription: Subscription,
config: ClientConfig,
) -> Result<Self>
pub fn with_config( api_key: &str, subscription: Subscription, config: ClientConfig, ) -> Result<Self>
Creates a client with explicit transport settings.
Sourcepub const fn subscription(&self) -> &Subscription
pub const fn subscription(&self) -> &Subscription
Returns the configured plan and cluster grants. They are not server-verified.
Sourcepub async fn get<T, Q>(&self, path: &str, params: &Q) -> Result<T>
pub async fn get<T, Q>(&self, path: &str, params: &Q) -> Result<T>
Requests any Stable JSON endpoint and validates its response against T.
Define a Deserialize model for endpoints without a named SDK wrapper.
Paths must be relative (e.g. "quote"); serialize query parameters through
params, never append them to the path. An API error inside HTTP 200 is
returned as an error even if T could deserialize that object.
Source§impl Client
impl Client
Sourcepub fn from_env(websocket_entitlements: WebSocketEntitlements) -> Result<Self>
pub fn from_env(websocket_entitlements: WebSocketEntitlements) -> Result<Self>
Creates a client from FMP_API_KEY and optional FMP_PLAN in the process environment.
The API key is required. A missing or blank plan uses the free plan
(Plan::Basic). WebSocket cluster grants are supplied explicitly.
Sourcepub fn from_dotenv(
path: &Path,
websocket_entitlements: WebSocketEntitlements,
) -> Result<Self>
pub fn from_dotenv( path: &Path, websocket_entitlements: WebSocketEntitlements, ) -> Result<Self>
Creates a client from the selected dotenv file without populating the process environment.
The file must contain FMP_API_KEY. Missing or blank FMP_PLAN uses the
free plan (Plan::Basic). Unrelated entries are ignored, and duplicate FMP
settings return an error. Quoting and variable expansion follow dotenvy syntax.
use std::path::Path;
use fmp_rust_sdk::{Client, WebSocketEntitlements};
let client = Client::from_dotenv(Path::new(".env"), WebSocketEntitlements::none())?;Source§impl Client
impl Client
Sourcepub async fn quote_short(&self, symbol: &str) -> Result<Vec<ShortQuote>>
pub async fn quote_short(&self, symbol: &str) -> Result<Vec<ShortQuote>>
A compact quote from Stable quote-short.
Source§impl Client
impl Client
Sourcepub async fn aftermarket_trade(
&self,
symbol: &str,
) -> Result<Vec<AftermarketTrade>>
pub async fn aftermarket_trade( &self, symbol: &str, ) -> Result<Vec<AftermarketTrade>>
The latest after-hours trade from Stable aftermarket-trade.
Source§impl Client
impl Client
Sourcepub async fn aftermarket_quote(
&self,
symbol: &str,
) -> Result<Vec<AftermarketQuote>>
pub async fn aftermarket_quote( &self, symbol: &str, ) -> Result<Vec<AftermarketQuote>>
After-hours bid and ask data from Stable aftermarket-quote.
Source§impl Client
impl Client
Sourcepub async fn stock_price_change(&self, symbol: &str) -> Result<Vec<PriceChange>>
pub async fn stock_price_change(&self, symbol: &str) -> Result<Vec<PriceChange>>
Changes across multiple time horizons from Stable stock-price-change.
Source§impl Client
impl Client
Sourcepub async fn market_capitalization(
&self,
symbol: &str,
) -> Result<Vec<MarketCapitalization>>
pub async fn market_capitalization( &self, symbol: &str, ) -> Result<Vec<MarketCapitalization>>
Current market capitalization from Stable market-capitalization.
Source§impl Client
impl Client
Sourcepub async fn income_statement_ttm(
&self,
symbol: &str,
) -> Result<Vec<IncomeStatement>>
pub async fn income_statement_ttm( &self, symbol: &str, ) -> Result<Vec<IncomeStatement>>
Trailing twelve-month income statements from Stable income-statement-ttm.
Source§impl Client
impl Client
Sourcepub async fn balance_sheet_statement_ttm(
&self,
symbol: &str,
) -> Result<Vec<BalanceSheetStatement>>
pub async fn balance_sheet_statement_ttm( &self, symbol: &str, ) -> Result<Vec<BalanceSheetStatement>>
Trailing twelve-month balance sheets from Stable balance-sheet-statement-ttm.
Source§impl Client
impl Client
Sourcepub async fn cash_flow_statement_ttm(
&self,
symbol: &str,
) -> Result<Vec<CashFlowStatement>>
pub async fn cash_flow_statement_ttm( &self, symbol: &str, ) -> Result<Vec<CashFlowStatement>>
Trailing twelve-month cash flow statements from Stable cash-flow-statement-ttm.
Source§impl Client
impl Client
Sourcepub async fn key_metrics_ttm(&self, symbol: &str) -> Result<Vec<KeyMetricsTtm>>
pub async fn key_metrics_ttm(&self, symbol: &str) -> Result<Vec<KeyMetricsTtm>>
Trailing twelve-month metrics from Stable key-metrics-ttm.
Source§impl Client
impl Client
Sourcepub async fn ratios_ttm(&self, symbol: &str) -> Result<Vec<FinancialRatiosTtm>>
pub async fn ratios_ttm(&self, symbol: &str) -> Result<Vec<FinancialRatiosTtm>>
Trailing twelve-month ratios from Stable ratios-ttm.
Source§impl Client
impl Client
Sourcepub async fn price_target_consensus(
&self,
symbol: &str,
) -> Result<Vec<PriceTargetConsensus>>
pub async fn price_target_consensus( &self, symbol: &str, ) -> Result<Vec<PriceTargetConsensus>>
Consensus analyst price targets from Stable price-target-consensus.
Source§impl Client
impl Client
Sourcepub async fn ratings_snapshot(
&self,
symbol: &str,
) -> Result<Vec<RatingSnapshot>>
pub async fn ratings_snapshot( &self, symbol: &str, ) -> Result<Vec<RatingSnapshot>>
Fundamental ratings from Stable ratings-snapshot.
Source§impl Client
impl Client
Sourcepub async fn discounted_cash_flow(
&self,
symbol: &str,
) -> Result<Vec<DiscountedCashFlow>>
pub async fn discounted_cash_flow( &self, symbol: &str, ) -> Result<Vec<DiscountedCashFlow>>
Company DCF valuation from Stable discounted-cash-flow.
Source§impl Client
impl Client
Sourcepub async fn levered_discounted_cash_flow(
&self,
symbol: &str,
) -> Result<Vec<DiscountedCashFlow>>
pub async fn levered_discounted_cash_flow( &self, symbol: &str, ) -> Result<Vec<DiscountedCashFlow>>
Levered company DCF valuation from Stable levered-discounted-cash-flow.
Source§impl Client
impl Client
Sourcepub async fn etf_holdings(&self, symbol: &str) -> Result<Vec<EtfHolding>>
pub async fn etf_holdings(&self, symbol: &str) -> Result<Vec<EtfHolding>>
Underlying securities and weights from Stable etf/holdings.
Source§impl Client
impl Client
Sourcepub async fn batch_quote_short(
&self,
symbols: &[&str],
) -> Result<Vec<ShortQuote>>
pub async fn batch_quote_short( &self, symbols: &[&str], ) -> Result<Vec<ShortQuote>>
Compact quotes for multiple symbols from Stable batch-quote-short.
Source§impl Client
impl Client
Sourcepub async fn batch_aftermarket_trade(
&self,
symbols: &[&str],
) -> Result<Vec<AftermarketTrade>>
pub async fn batch_aftermarket_trade( &self, symbols: &[&str], ) -> Result<Vec<AftermarketTrade>>
After-hours trades for multiple symbols from Stable batch-aftermarket-trade.
Source§impl Client
impl Client
Sourcepub async fn batch_aftermarket_quote(
&self,
symbols: &[&str],
) -> Result<Vec<AftermarketQuote>>
pub async fn batch_aftermarket_quote( &self, symbols: &[&str], ) -> Result<Vec<AftermarketQuote>>
After-hours quotes for multiple symbols from Stable batch-aftermarket-quote.
Source§impl Client
impl Client
Sourcepub async fn batch_market_capitalization(
&self,
symbols: &[&str],
) -> Result<Vec<MarketCapitalization>>
pub async fn batch_market_capitalization( &self, symbols: &[&str], ) -> Result<Vec<MarketCapitalization>>
Market capitalizations for multiple symbols from Stable market-capitalization-batch.
Source§impl Client
impl Client
Sourcepub async fn stock_list(&self) -> Result<Vec<DirectorySymbol>>
pub async fn stock_list(&self) -> Result<Vec<DirectorySymbol>>
Company symbols from Stable stock-list.
Source§impl Client
impl Client
Sourcepub async fn etf_list(&self) -> Result<Vec<DirectorySymbol>>
pub async fn etf_list(&self) -> Result<Vec<DirectorySymbol>>
ETF symbols from Stable etf-list.
Source§impl Client
impl Client
Sourcepub async fn actively_trading_list(&self) -> Result<Vec<DirectorySymbol>>
pub async fn actively_trading_list(&self) -> Result<Vec<DirectorySymbol>>
Actively traded symbols from Stable actively-trading-list.
Source§impl Client
impl Client
Sourcepub async fn biggest_gainers(&self) -> Result<Vec<MarketMover>>
pub async fn biggest_gainers(&self) -> Result<Vec<MarketMover>>
Top gaining stocks from Stable biggest-gainers.
Source§impl Client
impl Client
Sourcepub async fn biggest_losers(&self) -> Result<Vec<MarketMover>>
pub async fn biggest_losers(&self) -> Result<Vec<MarketMover>>
Top losing stocks from Stable biggest-losers.
Source§impl Client
impl Client
Sourcepub async fn most_actives(&self) -> Result<Vec<MarketMover>>
pub async fn most_actives(&self) -> Result<Vec<MarketMover>>
Most active stocks from Stable most-actives.
Source§impl Client
impl Client
Sourcepub async fn etf_quotes(&self) -> Result<Vec<Quote>>
pub async fn etf_quotes(&self) -> Result<Vec<Quote>>
ETF quotes from Stable batch-etf-quotes.
Source§impl Client
impl Client
Sourcepub async fn crypto_quotes(&self) -> Result<Vec<Quote>>
pub async fn crypto_quotes(&self) -> Result<Vec<Quote>>
Cryptocurrency quotes from Stable batch-crypto-quotes.
Source§impl Client
impl Client
Sourcepub async fn forex_quotes(&self) -> Result<Vec<Quote>>
pub async fn forex_quotes(&self) -> Result<Vec<Quote>>
Forex quotes from Stable batch-forex-quotes.
Source§impl Client
impl Client
Sourcepub async fn commodity_quotes(&self) -> Result<Vec<Quote>>
pub async fn commodity_quotes(&self) -> Result<Vec<Quote>>
Commodity quotes from Stable batch-commodity-quotes.
Source§impl Client
impl Client
Sourcepub async fn index_quotes(&self) -> Result<Vec<Quote>>
pub async fn index_quotes(&self) -> Result<Vec<Quote>>
Index quotes from Stable batch-index-quotes.
Source§impl Client
impl Client
Sourcepub async fn income_statement(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<IncomeStatement>>
pub async fn income_statement( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<IncomeStatement>>
Historical income statements from Stable income-statement.
Source§impl Client
impl Client
Sourcepub async fn balance_sheet_statement(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<BalanceSheetStatement>>
pub async fn balance_sheet_statement( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<BalanceSheetStatement>>
Historical balance sheets from Stable balance-sheet-statement.
Source§impl Client
impl Client
Sourcepub async fn cash_flow_statement(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<CashFlowStatement>>
pub async fn cash_flow_statement( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<CashFlowStatement>>
Historical cash flow statements from Stable cash-flow-statement.
Source§impl Client
impl Client
Sourcepub async fn key_metrics(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<KeyMetrics>>
pub async fn key_metrics( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<KeyMetrics>>
Historical key metrics from Stable key-metrics.
Source§impl Client
impl Client
Sourcepub async fn ratios(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<FinancialRatios>>
pub async fn ratios( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<FinancialRatios>>
Historical financial ratios from Stable ratios.
Source§impl Client
impl Client
Sourcepub async fn financial_growth(
&self,
symbol: &str,
options: StatementOptions,
) -> Result<Vec<FinancialGrowth>>
pub async fn financial_growth( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<FinancialGrowth>>
Growth rates from Stable financial-growth.
Source§impl Client
impl Client
Sourcepub async fn search_symbol(
&self,
query: &str,
options: SearchOptions<'_>,
) -> Result<Vec<SearchResult>>
pub async fn search_symbol( &self, query: &str, options: SearchOptions<'_>, ) -> Result<Vec<SearchResult>>
Find symbols through Stable search-symbol.
Sourcepub async fn search_name(
&self,
query: &str,
options: SearchOptions<'_>,
) -> Result<Vec<SearchResult>>
pub async fn search_name( &self, query: &str, options: SearchOptions<'_>, ) -> Result<Vec<SearchResult>>
Find company names through Stable search-name.
Sourcepub async fn profile_by_cik(&self, cik: &str) -> Result<Vec<Profile>>
pub async fn profile_by_cik(&self, cik: &str) -> Result<Vec<Profile>>
Get company profiles through Stable profile-cik.
Sourcepub async fn exchange_quotes(&self, exchange: &str) -> Result<Vec<Quote>>
pub async fn exchange_quotes(&self, exchange: &str) -> Result<Vec<Quote>>
Get all quotes for an exchange through Stable batch-exchange-quote.
Sourcepub async fn historical_prices(
&self,
symbol: &str,
dates: DateRange,
) -> Result<Vec<HistoricalPrice>>
pub async fn historical_prices( &self, symbol: &str, dates: DateRange, ) -> Result<Vec<HistoricalPrice>>
Daily split-adjusted OHLCV bars from Stable historical-price-eod/full.
Sourcepub async fn historical_prices_light(
&self,
symbol: &str,
dates: DateRange,
) -> Result<Vec<HistoricalPriceLight>>
pub async fn historical_prices_light( &self, symbol: &str, dates: DateRange, ) -> Result<Vec<HistoricalPriceLight>>
Daily closes from Stable historical-price-eod/light.
Sourcepub async fn intraday_prices(
&self,
symbol: &str,
interval: IntradayInterval,
dates: DateRange,
) -> Result<Vec<IntradayPrice>>
pub async fn intraday_prices( &self, symbol: &str, interval: IntradayInterval, dates: DateRange, ) -> Result<Vec<IntradayPrice>>
Intraday OHLCV bars at the chosen documented Stable chart interval.
Sourcepub async fn historical_market_capitalization(
&self,
symbol: &str,
dates: DateRange,
limit: u32,
) -> Result<Vec<MarketCapitalization>>
pub async fn historical_market_capitalization( &self, symbol: &str, dates: DateRange, limit: u32, ) -> Result<Vec<MarketCapitalization>>
Market cap history through Stable historical-market-capitalization.
Sourcepub async fn analyst_estimates(
&self,
symbol: &str,
period: EstimatePeriod,
pagination: Pagination,
) -> Result<Vec<AnalystEstimate>>
pub async fn analyst_estimates( &self, symbol: &str, period: EstimatePeriod, pagination: Pagination, ) -> Result<Vec<AnalystEstimate>>
Analyst projections through Stable analyst-estimates.
Sourcepub async fn earnings_transcript(
&self,
symbol: &str,
year: u16,
quarter: u8,
) -> Result<Vec<EarningsTranscript>>
pub async fn earnings_transcript( &self, symbol: &str, year: u16, quarter: u8, ) -> Result<Vec<EarningsTranscript>>
Full earnings call content through Stable earning-call-transcript.
Sourcepub async fn earnings_calendar(&self, dates: DateRange) -> Result<Vec<Earnings>>
pub async fn earnings_calendar(&self, dates: DateRange) -> Result<Vec<Earnings>>
Earnings calendar through Stable earnings-calendar.
Sourcepub async fn dividends_calendar(
&self,
dates: DateRange,
) -> Result<Vec<Dividend>>
pub async fn dividends_calendar( &self, dates: DateRange, ) -> Result<Vec<Dividend>>
Dividend calendar through Stable dividends-calendar.
Sourcepub async fn splits_calendar(&self, dates: DateRange) -> Result<Vec<StockSplit>>
pub async fn splits_calendar(&self, dates: DateRange) -> Result<Vec<StockSplit>>
Split calendar through Stable splits-calendar.
Sourcepub async fn latest_stock_news(
&self,
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn latest_stock_news( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Latest company news through Stable news/stock-latest.
Sourcepub async fn general_news(
&self,
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn general_news( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>
General news through Stable news/general-latest.
Sourcepub async fn latest_press_releases(
&self,
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn latest_press_releases( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Latest press releases through Stable news/press-releases-latest.
Sourcepub async fn stock_news(
&self,
symbols: &[&str],
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn stock_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Company news selected by symbol through Stable news/stock.
Sourcepub async fn press_releases(
&self,
symbols: &[&str],
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn press_releases( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Press releases selected by symbol through Stable news/press-releases.
Sourcepub async fn crypto_news(
&self,
symbols: &[&str],
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn crypto_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Cryptocurrency news through Stable news/crypto.
Sourcepub async fn forex_news(
&self,
symbols: &[&str],
options: NewsOptions,
) -> Result<Vec<NewsArticle>>
pub async fn forex_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>
Foreign exchange news through Stable news/forex.
Sourcepub async fn treasury_rates(
&self,
dates: DateRange,
) -> Result<Vec<TreasuryRate>>
pub async fn treasury_rates( &self, dates: DateRange, ) -> Result<Vec<TreasuryRate>>
Historical Treasury yields through Stable treasury-rates.
Sourcepub async fn economic_indicators(
&self,
name: &str,
dates: DateRange,
) -> Result<Vec<EconomicIndicator>>
pub async fn economic_indicators( &self, name: &str, dates: DateRange, ) -> Result<Vec<EconomicIndicator>>
A named economic series through Stable economic-indicators.
Indicator names are supplied explicitly as documented by FMP.
Sourcepub async fn economic_calendar(
&self,
dates: DateRange,
) -> Result<Vec<EconomicEvent>>
pub async fn economic_calendar( &self, dates: DateRange, ) -> Result<Vec<EconomicEvent>>
Scheduled economic releases through Stable economic-calendar.
Sourcepub async fn sector_performance(
&self,
date: NaiveDate,
exchange: Option<&str>,
sector: Option<&str>,
) -> Result<Vec<SectorPerformance>>
pub async fn sector_performance( &self, date: NaiveDate, exchange: Option<&str>, sector: Option<&str>, ) -> Result<Vec<SectorPerformance>>
Sector performance for a date through Stable sector-performance-snapshot.
Sourcepub async fn industry_performance(
&self,
date: NaiveDate,
exchange: Option<&str>,
industry: Option<&str>,
) -> Result<Vec<IndustryPerformance>>
pub async fn industry_performance( &self, date: NaiveDate, exchange: Option<&str>, industry: Option<&str>, ) -> Result<Vec<IndustryPerformance>>
Industry performance for a date through Stable industry-performance-snapshot.
Source§impl Client
impl Client
Sourcepub async fn connect_streams(
&self,
entitlements: StreamEntitlements,
config: StreamConfig,
) -> Result<StandardWebSocketClient, WebSocketError>
pub async fn connect_streams( &self, entitlements: StreamEntitlements, config: StreamConfig, ) -> Result<StandardWebSocketClient, WebSocketError>
Opens an authenticated current market-stream connection for this client.
Explicit stream grants are independent of the client’s configured plan.