Skip to main content

Client

Struct Client 

Source
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

Source

pub async fn probe_access<Q>( &self, path: &str, params: &Q, ) -> Result<AccessReport>
where Q: Serialize + ?Sized,

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

Source

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.

Source

pub fn with_config( api_key: &str, subscription: Subscription, config: ClientConfig, ) -> Result<Self>

Creates a client with explicit transport settings.

Source

pub const fn subscription(&self) -> &Subscription

Returns the configured plan and cluster grants. They are not server-verified.

Source

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

pub async fn get_text<Q>(&self, path: &str, params: &Q) -> Result<String>
where Q: Serialize + ?Sized,

Requests a text endpoint, including FMP CSV bulk datasets. Provider errors are still checked before returning the UTF-8 text.

Source

pub async fn get_bytes<Q>(&self, path: &str, params: &Q) -> Result<Vec<u8>>
where Q: Serialize + ?Sized,

Requests a binary endpoint, such as financial reports in XLSX format.

Source§

impl Client

Source

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.

Source

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

Source

pub async fn profile(&self, symbol: &str) -> Result<Vec<Profile>>

Company information from Stable profile.

Source§

impl Client

Source

pub async fn stock_peers(&self, symbol: &str) -> Result<Vec<Peer>>

Comparable companies from Stable stock-peers.

Source§

impl Client

Source

pub async fn quote(&self, symbol: &str) -> Result<Vec<Quote>>

A full quote from Stable quote for any supported stock, ETF, index, crypto, forex, or commodity symbol.

Source§

impl Client

Source

pub async fn quote_short(&self, symbol: &str) -> Result<Vec<ShortQuote>>

A compact quote from Stable quote-short.

Source§

impl Client

Source

pub async fn aftermarket_trade( &self, symbol: &str, ) -> Result<Vec<AftermarketTrade>>

The latest after-hours trade from Stable aftermarket-trade.

Source§

impl Client

Source

pub async fn aftermarket_quote( &self, symbol: &str, ) -> Result<Vec<AftermarketQuote>>

After-hours bid and ask data from Stable aftermarket-quote.

Source§

impl Client

Source

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

Source

pub async fn market_capitalization( &self, symbol: &str, ) -> Result<Vec<MarketCapitalization>>

Current market capitalization from Stable market-capitalization.

Source§

impl Client

Source

pub async fn shares_float(&self, symbol: &str) -> Result<Vec<ShareFloat>>

Available share float from Stable shares-float.

Source§

impl Client

Source

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

Source

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

Source

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

Source

pub async fn key_metrics_ttm(&self, symbol: &str) -> Result<Vec<KeyMetricsTtm>>

Trailing twelve-month metrics from Stable key-metrics-ttm.

Source§

impl Client

Source

pub async fn ratios_ttm(&self, symbol: &str) -> Result<Vec<FinancialRatiosTtm>>

Trailing twelve-month ratios from Stable ratios-ttm.

Source§

impl Client

Source

pub async fn earnings(&self, symbol: &str) -> Result<Vec<Earnings>>

Company earnings history and scheduled reports from Stable earnings.

Source§

impl Client

Source

pub async fn dividends(&self, symbol: &str) -> Result<Vec<Dividend>>

Company dividend events from Stable dividends.

Source§

impl Client

Source

pub async fn splits(&self, symbol: &str) -> Result<Vec<StockSplit>>

Company split events from Stable splits.

Source§

impl Client

Source

pub async fn price_target_consensus( &self, symbol: &str, ) -> Result<Vec<PriceTargetConsensus>>

Consensus analyst price targets from Stable price-target-consensus.

Source§

impl Client

Source

pub async fn ratings_snapshot( &self, symbol: &str, ) -> Result<Vec<RatingSnapshot>>

Fundamental ratings from Stable ratings-snapshot.

Source§

impl Client

Source

pub async fn discounted_cash_flow( &self, symbol: &str, ) -> Result<Vec<DiscountedCashFlow>>

Company DCF valuation from Stable discounted-cash-flow.

Source§

impl Client

Source

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

Source

pub async fn etf_holdings(&self, symbol: &str) -> Result<Vec<EtfHolding>>

Underlying securities and weights from Stable etf/holdings.

Source§

impl Client

Source

pub async fn batch_quote(&self, symbols: &[&str]) -> Result<Vec<Quote>>

Full quotes for multiple symbols from Stable batch-quote.

Source§

impl Client

Source

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

Source

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

Source

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

Source

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

Source

pub async fn stock_list(&self) -> Result<Vec<DirectorySymbol>>

Company symbols from Stable stock-list.

Source§

impl Client

Source

pub async fn etf_list(&self) -> Result<Vec<DirectorySymbol>>

ETF symbols from Stable etf-list.

Source§

impl Client

Source

pub async fn actively_trading_list(&self) -> Result<Vec<DirectorySymbol>>

Actively traded symbols from Stable actively-trading-list.

Source§

impl Client

Source

pub async fn biggest_gainers(&self) -> Result<Vec<MarketMover>>

Top gaining stocks from Stable biggest-gainers.

Source§

impl Client

Source

pub async fn biggest_losers(&self) -> Result<Vec<MarketMover>>

Top losing stocks from Stable biggest-losers.

Source§

impl Client

Source

pub async fn most_actives(&self) -> Result<Vec<MarketMover>>

Most active stocks from Stable most-actives.

Source§

impl Client

Source

pub async fn etf_quotes(&self) -> Result<Vec<Quote>>

ETF quotes from Stable batch-etf-quotes.

Source§

impl Client

Source

pub async fn crypto_quotes(&self) -> Result<Vec<Quote>>

Cryptocurrency quotes from Stable batch-crypto-quotes.

Source§

impl Client

Source

pub async fn forex_quotes(&self) -> Result<Vec<Quote>>

Forex quotes from Stable batch-forex-quotes.

Source§

impl Client

Source

pub async fn commodity_quotes(&self) -> Result<Vec<Quote>>

Commodity quotes from Stable batch-commodity-quotes.

Source§

impl Client

Source

pub async fn index_quotes(&self) -> Result<Vec<Quote>>

Index quotes from Stable batch-index-quotes.

Source§

impl Client

Source

pub async fn income_statement( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<IncomeStatement>>

Historical income statements from Stable income-statement.

Source§

impl Client

Source

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

Source

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

Source

pub async fn key_metrics( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<KeyMetrics>>

Historical key metrics from Stable key-metrics.

Source§

impl Client

Source

pub async fn ratios( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<FinancialRatios>>

Historical financial ratios from Stable ratios.

Source§

impl Client

Source

pub async fn financial_growth( &self, symbol: &str, options: StatementOptions, ) -> Result<Vec<FinancialGrowth>>

Growth rates from Stable financial-growth.

Source§

impl Client

Source

pub async fn search_symbol( &self, query: &str, options: SearchOptions<'_>, ) -> Result<Vec<SearchResult>>

Find symbols through Stable search-symbol.

Source

pub async fn search_name( &self, query: &str, options: SearchOptions<'_>, ) -> Result<Vec<SearchResult>>

Find company names through Stable search-name.

Source

pub async fn profile_by_cik(&self, cik: &str) -> Result<Vec<Profile>>

Get company profiles through Stable profile-cik.

Source

pub async fn exchange_quotes(&self, exchange: &str) -> Result<Vec<Quote>>

Get all quotes for an exchange through Stable batch-exchange-quote.

Source

pub async fn historical_prices( &self, symbol: &str, dates: DateRange, ) -> Result<Vec<HistoricalPrice>>

Daily split-adjusted OHLCV bars from Stable historical-price-eod/full.

Source

pub async fn historical_prices_light( &self, symbol: &str, dates: DateRange, ) -> Result<Vec<HistoricalPriceLight>>

Daily closes from Stable historical-price-eod/light.

Source

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.

Source

pub async fn historical_market_capitalization( &self, symbol: &str, dates: DateRange, limit: u32, ) -> Result<Vec<MarketCapitalization>>

Market cap history through Stable historical-market-capitalization.

Source

pub async fn analyst_estimates( &self, symbol: &str, period: EstimatePeriod, pagination: Pagination, ) -> Result<Vec<AnalystEstimate>>

Analyst projections through Stable analyst-estimates.

Source

pub async fn earnings_transcript( &self, symbol: &str, year: u16, quarter: u8, ) -> Result<Vec<EarningsTranscript>>

Full earnings call content through Stable earning-call-transcript.

Source

pub async fn earnings_calendar(&self, dates: DateRange) -> Result<Vec<Earnings>>

Earnings calendar through Stable earnings-calendar.

Source

pub async fn dividends_calendar( &self, dates: DateRange, ) -> Result<Vec<Dividend>>

Dividend calendar through Stable dividends-calendar.

Source

pub async fn splits_calendar(&self, dates: DateRange) -> Result<Vec<StockSplit>>

Split calendar through Stable splits-calendar.

Source

pub async fn latest_stock_news( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Latest company news through Stable news/stock-latest.

Source

pub async fn general_news( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>

General news through Stable news/general-latest.

Source

pub async fn latest_press_releases( &self, options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Latest press releases through Stable news/press-releases-latest.

Source

pub async fn stock_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Company news selected by symbol through Stable news/stock.

Source

pub async fn press_releases( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Press releases selected by symbol through Stable news/press-releases.

Source

pub async fn crypto_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Cryptocurrency news through Stable news/crypto.

Source

pub async fn forex_news( &self, symbols: &[&str], options: NewsOptions, ) -> Result<Vec<NewsArticle>>

Foreign exchange news through Stable news/forex.

Source

pub async fn treasury_rates( &self, dates: DateRange, ) -> Result<Vec<TreasuryRate>>

Historical Treasury yields through Stable treasury-rates.

Source

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.

Source

pub async fn economic_calendar( &self, dates: DateRange, ) -> Result<Vec<EconomicEvent>>

Scheduled economic releases through Stable economic-calendar.

Source

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.

Source

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

Source

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.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more