pub struct TradingViewClient { /* private fields */ }Expand description
High-level entry point for TradingView screener, search, quote, and history data.
Most consumers should start with TradingViewClient::builder and then use one of the
product-oriented facades such as TradingViewClient::equity,
TradingViewClient::crypto, or TradingViewClient::forex.
§Examples
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let quote = client.equity().quote("NASDAQ:AAPL").await?;
println!("{:?}", quote.close);
Ok(())
}Implementations§
Source§impl TradingViewClient
impl TradingViewClient
pub fn for_backend_history() -> Result<Self>
Sourcepub fn for_research() -> Result<Self>
pub fn for_research() -> Result<Self>
Builds a client tuned for research-style workflows with moderate retries and timeout.
Sourcepub fn for_interactive() -> Result<Self>
pub fn for_interactive() -> Result<Self>
Builds a client tuned for lower-latency interactive usage.
pub fn from_config(config: TradingViewClientConfig) -> Result<Self>
pub fn endpoints(&self) -> &Endpoints
pub fn history_config(&self) -> &HistoryClientConfig
pub fn snapshot_batch_config(&self) -> &SnapshotBatchConfig
pub fn request_budget(&self) -> &RequestBudget
Sourcepub async fn scan(&self, query: &ScanQuery) -> Result<ScanResponse>
pub async fn scan(&self, query: &ScanQuery) -> Result<ScanResponse>
Executes a low-level TradingView screener query.
This is the most flexible API in the crate and is useful when you need fields or filters that are not covered by the higher-level market facades.
§Examples
use tvdata_rs::scanner::fields::{core, price};
use tvdata_rs::scanner::ScanQuery;
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let query = ScanQuery::new()
.market("america")
.select([core::NAME, price::CLOSE])
.page(0, 10)?;
let response = client.scan(&query).await?;
println!("rows: {}", response.rows.len());
Ok(())
}Sourcepub async fn validate_scan_query(
&self,
query: &ScanQuery,
) -> Result<ScanValidationReport>
pub async fn validate_scan_query( &self, query: &ScanQuery, ) -> Result<ScanValidationReport>
Validates a scan query against live TradingView metainfo before execution.
Validation currently requires the query to specify one or more markets so the
client can resolve the corresponding /{market}/metainfo endpoints.
§Examples
use tvdata_rs::scanner::fields::{core, price};
use tvdata_rs::scanner::ScanQuery;
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let query = ScanQuery::new()
.market("america")
.select([core::NAME, price::CLOSE]);
let report = client.validate_scan_query(&query).await?;
assert!(report.is_strictly_supported());
Ok(())
}Sourcepub async fn scan_validated(&self, query: &ScanQuery) -> Result<ScanResponse>
pub async fn scan_validated(&self, query: &ScanQuery) -> Result<ScanResponse>
Executes a scan only after validating all requested fields against live TradingView metainfo for the selected markets.
§Examples
use tvdata_rs::scanner::fields::{core, price};
use tvdata_rs::scanner::ScanQuery;
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let query = ScanQuery::new()
.market("america")
.select([core::NAME, price::CLOSE]);
let response = client.scan_validated(&query).await?;
println!("rows: {}", response.rows.len());
Ok(())
}Sourcepub async fn filter_scan_query(
&self,
query: &ScanQuery,
) -> Result<(ScanQuery, ScanValidationReport)>
pub async fn filter_scan_query( &self, query: &ScanQuery, ) -> Result<(ScanQuery, ScanValidationReport)>
Filters a scan query down to columns that are fully supported across the selected markets according to live TradingView metainfo plus the embedded registry fallback.
Partially supported columns are removed from the filtered query to keep the result safe across all requested markets.
§Examples
use tvdata_rs::scanner::fields::{fundamentals, price};
use tvdata_rs::scanner::ScanQuery;
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let query = ScanQuery::new()
.markets(["america", "crypto"])
.select([price::CLOSE, fundamentals::MARKET_CAP_BASIC]);
let (filtered, report) = client.filter_scan_query(&query).await?;
println!("filtered columns: {:?}", report.filtered_column_names());
assert!(!filtered.columns.is_empty());
Ok(())
}Sourcepub async fn scan_supported(&self, query: &ScanQuery) -> Result<ScanResponse>
pub async fn scan_supported(&self, query: &ScanQuery) -> Result<ScanResponse>
Executes a scan after dropping columns that are not fully supported across all selected markets.
§Examples
use tvdata_rs::scanner::fields::{fundamentals, price};
use tvdata_rs::scanner::ScanQuery;
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let query = ScanQuery::new()
.markets(["america", "crypto"])
.select([price::CLOSE, fundamentals::MARKET_CAP_BASIC]);
let response = client.scan_supported(&query).await?;
println!("rows: {}", response.rows.len());
Ok(())
}Sourcepub async fn metainfo(
&self,
market: impl Into<Market>,
) -> Result<ScannerMetainfo>
pub async fn metainfo( &self, market: impl Into<Market>, ) -> Result<ScannerMetainfo>
Fetches TradingView scanner metainfo for a specific market or screener.
This endpoint returns the currently supported field names and their value types as exposed by TradingView for the selected screener route.
§Examples
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let metainfo = client.metainfo("america").await?;
println!("fields: {}", metainfo.fields.len());
Ok(())
}Sourcepub async fn search(&self, request: &SearchRequest) -> Result<Vec<SearchHit>>
pub async fn search(&self, request: &SearchRequest) -> Result<Vec<SearchHit>>
Searches TradingView symbol metadata using the symbol search endpoint.
§Examples
use tvdata_rs::{Result, SearchRequest, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let hits = client
.search(&SearchRequest::builder().text("AAPL").build())
.await?;
println!("matches: {}", hits.len());
Ok(())
}Sourcepub async fn search_equities(
&self,
text: impl Into<String>,
) -> Result<Vec<SearchHit>>
pub async fn search_equities( &self, text: impl Into<String>, ) -> Result<Vec<SearchHit>>
Searches equities using TradingView’s current search_type=stock filter.
Sourcepub async fn search_equities_response(
&self,
text: impl Into<String>,
) -> Result<SearchResponse>
pub async fn search_equities_response( &self, text: impl Into<String>, ) -> Result<SearchResponse>
Searches equities and returns the richer v3 response envelope.
Sourcepub async fn search_forex(
&self,
text: impl Into<String>,
) -> Result<Vec<SearchHit>>
pub async fn search_forex( &self, text: impl Into<String>, ) -> Result<Vec<SearchHit>>
Searches forex instruments using TradingView’s current search_type=forex filter.
Sourcepub async fn search_forex_response(
&self,
text: impl Into<String>,
) -> Result<SearchResponse>
pub async fn search_forex_response( &self, text: impl Into<String>, ) -> Result<SearchResponse>
Searches forex instruments and returns the richer v3 response envelope.
Sourcepub async fn search_crypto(
&self,
text: impl Into<String>,
) -> Result<Vec<SearchHit>>
pub async fn search_crypto( &self, text: impl Into<String>, ) -> Result<Vec<SearchHit>>
Searches crypto instruments using TradingView’s current search_type=crypto filter.
Sourcepub async fn search_crypto_response(
&self,
text: impl Into<String>,
) -> Result<SearchResponse>
pub async fn search_crypto_response( &self, text: impl Into<String>, ) -> Result<SearchResponse>
Searches crypto instruments and returns the richer v3 response envelope.
Sourcepub async fn search_options(
&self,
text: impl Into<String>,
) -> Result<Vec<SearchHit>>
pub async fn search_options( &self, text: impl Into<String>, ) -> Result<Vec<SearchHit>>
Searches option-like instruments.
As of March 22, 2026, TradingView’s live symbol_search/v3 endpoint rejects
search_type=option, so this method performs a broader search and then keeps
hits that look option-related based on the returned payload.
Sourcepub async fn search_options_response(
&self,
text: impl Into<String>,
) -> Result<SearchResponse>
pub async fn search_options_response( &self, text: impl Into<String>, ) -> Result<SearchResponse>
Searches option-like instruments and returns the filtered v3 response envelope.
Sourcepub async fn search_response(
&self,
request: &SearchRequest,
) -> Result<SearchResponse>
pub async fn search_response( &self, request: &SearchRequest, ) -> Result<SearchResponse>
Searches TradingView symbol metadata and returns the richer v3 search envelope.
This includes the remaining symbol count reported by TradingView, plus richer instrument metadata such as identifiers and listing/source information.
§Examples
use tvdata_rs::{Result, SearchRequest, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let response = client
.search_response(&SearchRequest::builder().text("AAPL").build())
.await?;
println!("hits: {}", response.hits.len());
println!("remaining: {}", response.symbols_remaining);
Ok(())
}Sourcepub async fn economic_calendar(
&self,
request: &EconomicCalendarRequest,
) -> Result<EconomicCalendarResponse>
pub async fn economic_calendar( &self, request: &EconomicCalendarRequest, ) -> Result<EconomicCalendarResponse>
Fetches economic calendar events from TradingView’s Reuters-backed calendar feed.
§Examples
use tvdata_rs::{EconomicCalendarRequest, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let response = client
.economic_calendar(&EconomicCalendarRequest::upcoming(7))
.await?;
println!("events: {}", response.events.len());
Ok(())
}Sourcepub async fn earnings_calendar(
&self,
request: &CalendarWindowRequest,
) -> Result<Vec<EarningsCalendarEntry>>
pub async fn earnings_calendar( &self, request: &CalendarWindowRequest, ) -> Result<Vec<EarningsCalendarEntry>>
Fetches an earnings calendar window from TradingView scanner fields.
This is a market-wide calendar product, distinct from
client.equity().earnings_calendar("NASDAQ:AAPL"), which returns
single-symbol analyst earnings metadata.
§Examples
use tvdata_rs::{CalendarWindowRequest, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let events = client
.earnings_calendar(&CalendarWindowRequest::upcoming("america", 7))
.await?;
println!("events: {}", events.len());
Ok(())
}Sourcepub async fn dividend_calendar(
&self,
request: &DividendCalendarRequest,
) -> Result<Vec<DividendCalendarEntry>>
pub async fn dividend_calendar( &self, request: &DividendCalendarRequest, ) -> Result<Vec<DividendCalendarEntry>>
Fetches a dividend calendar window from TradingView scanner fields.
The request can be anchored either on upcoming ex-dates or upcoming
payment dates through DividendCalendarRequest::date_kind.
§Examples
use tvdata_rs::{DividendCalendarRequest, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let events = client
.dividend_calendar(&DividendCalendarRequest::upcoming("america", 14))
.await?;
println!("events: {}", events.len());
Ok(())
}Sourcepub async fn ipo_calendar(
&self,
request: &CalendarWindowRequest,
) -> Result<Vec<IpoCalendarEntry>>
pub async fn ipo_calendar( &self, request: &CalendarWindowRequest, ) -> Result<Vec<IpoCalendarEntry>>
Fetches an IPO calendar window from TradingView scanner fields.
§Examples
use tvdata_rs::{CalendarWindowRequest, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let events = client
.ipo_calendar(&CalendarWindowRequest::trailing("america", 30))
.await?;
println!("events: {}", events.len());
Ok(())
}Sourcepub async fn history(&self, request: &HistoryRequest) -> Result<HistorySeries>
pub async fn history(&self, request: &HistoryRequest) -> Result<HistorySeries>
Downloads a single OHLCV history series over TradingView’s chart websocket.
§Examples
use tvdata_rs::{HistoryRequest, Interval, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let request = HistoryRequest::new("NASDAQ:AAPL", Interval::Day1, 30);
let series = client.history(&request).await?;
println!("bars: {}", series.bars.len());
Ok(())
}To fetch the maximum history currently available, construct the request
with HistoryRequest::max("NASDAQ:AAPL", Interval::Day1).
Sourcepub fn builder() -> TradingViewClientBuilder
pub fn builder() -> TradingViewClientBuilder
Builds a TradingViewClient with validated endpoint configuration and retry settings.
Source§impl TradingViewClient
impl TradingViewClient
Sourcepub async fn history_batch(
&self,
request: &HistoryBatchRequest,
) -> Result<Vec<HistorySeries>>
pub async fn history_batch( &self, request: &HistoryBatchRequest, ) -> Result<Vec<HistorySeries>>
Downloads multiple OHLCV history series with bounded concurrency.
§Examples
use tvdata_rs::{HistoryBatchRequest, Interval, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let request = HistoryBatchRequest::new(["NASDAQ:AAPL", "NASDAQ:MSFT"], Interval::Day1, 30);
let series = client.history_batch(&request).await?;
println!("series: {}", series.len());
Ok(())
}Sourcepub async fn history_batch_detailed(
&self,
request: &HistoryBatchRequest,
) -> Result<BatchResult<HistorySeries>>
pub async fn history_batch_detailed( &self, request: &HistoryBatchRequest, ) -> Result<BatchResult<HistorySeries>>
Downloads multiple OHLCV history series and returns successes, missing symbols, and failures separately.
Sourcepub async fn download_history_max<I, T>(
&self,
symbols: I,
interval: Interval,
) -> Result<Vec<HistorySeries>>
pub async fn download_history_max<I, T>( &self, symbols: I, interval: Interval, ) -> Result<Vec<HistorySeries>>
Downloads the maximum history currently available for multiple symbols.
The crate keeps requesting older bars over the chart websocket until TradingView stops returning new history.
§Examples
use tvdata_rs::{Interval, Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let series = client
.download_history_max(["NASDAQ:AAPL", "NASDAQ:MSFT"], Interval::Day1)
.await?;
println!("series: {}", series.len());
Ok(())
}Sourcepub async fn download_history<I, T>(
&self,
symbols: I,
interval: Interval,
bars: u32,
) -> Result<Vec<HistorySeries>>
pub async fn download_history<I, T>( &self, symbols: I, interval: Interval, bars: u32, ) -> Result<Vec<HistorySeries>>
Convenience wrapper around TradingViewClient::history_batch for a list of symbols.
Sourcepub async fn download_history_map<I, T>(
&self,
symbols: I,
interval: Interval,
bars: u32,
) -> Result<BTreeMap<Ticker, HistorySeries>>
pub async fn download_history_map<I, T>( &self, symbols: I, interval: Interval, bars: u32, ) -> Result<BTreeMap<Ticker, HistorySeries>>
Downloads multiple history series and returns them keyed by symbol.
Sourcepub async fn download_history_map_max<I, T>(
&self,
symbols: I,
interval: Interval,
) -> Result<BTreeMap<Ticker, HistorySeries>>
pub async fn download_history_map_max<I, T>( &self, symbols: I, interval: Interval, ) -> Result<BTreeMap<Ticker, HistorySeries>>
Downloads the maximum history available and returns it keyed by symbol.
Sourcepub async fn daily_bars_on(
&self,
request: &DailyBarRequest,
) -> Result<BatchResult<Bar>>
pub async fn daily_bars_on( &self, request: &DailyBarRequest, ) -> Result<BatchResult<Bar>>
Downloads daily bars for a set of instruments and selects the best bar for the requested trading date.
Sourcepub async fn daily_bars_range(
&self,
request: &DailyBarRangeRequest,
) -> Result<BatchResult<HistorySeries>>
pub async fn daily_bars_range( &self, request: &DailyBarRangeRequest, ) -> Result<BatchResult<HistorySeries>>
Downloads daily history and trims each successful series to the requested date window.
Source§impl TradingViewClient
impl TradingViewClient
Sourcepub fn crypto(&self) -> CryptoClient<'_>
pub fn crypto(&self) -> CryptoClient<'_>
Returns the high-level crypto facade.
Source§impl TradingViewClient
impl TradingViewClient
Sourcepub fn equity(&self) -> EquityClient<'_>
pub fn equity(&self) -> EquityClient<'_>
Returns the high-level equity facade.
§Examples
use tvdata_rs::{Result, TradingViewClient};
#[tokio::main]
async fn main() -> Result<()> {
let client = TradingViewClient::builder().build()?;
let movers = client.equity().top_gainers("america", 5).await?;
println!("movers: {}", movers.len());
Ok(())
}Source§impl TradingViewClient
impl TradingViewClient
Sourcepub fn forex(&self) -> ForexClient<'_>
pub fn forex(&self) -> ForexClient<'_>
Returns the high-level FX facade.
Trait Implementations§
Source§impl Clone for TradingViewClient
impl Clone for TradingViewClient
Source§fn clone(&self) -> TradingViewClient
fn clone(&self) -> TradingViewClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more