pub struct CoinApiHttpClient { /* private fields */ }Expand description
Authenticated, data-only CoinAPI REST client.
Requests return raw protocol models. The single-page historical methods fetch exactly one page; callers must not infer completeness from a full page. The range methods page through a whole window.
Implementations§
Source§impl CoinApiHttpClient
impl CoinApiHttpClient
Sourcepub fn new(
api_key: SecretString,
config: CoinApiHttpConfig,
) -> Result<Self, Error>
pub fn new( api_key: SecretString, config: CoinApiHttpConfig, ) -> Result<Self, Error>
Creates a client using an explicit secret and endpoint configuration.
§Errors
Returns an error if the credentials, endpoint, limits, or transport configuration are invalid.
Sourcepub fn credits_remaining(&self) -> u64
pub fn credits_remaining(&self) -> u64
Returns the remaining conservative local credit allowance.
Sourcepub async fn get_exchanges(
&self,
query: &ExchangesQuery,
) -> Result<Vec<Exchange>, Error>
pub async fn get_exchanges( &self, query: &ExchangesQuery, ) -> Result<Vec<Exchange>, Error>
Retrieves exchange metadata with optional filtering.
§Errors
Returns an error if the request fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_symbols(
&self,
exchange_id: &str,
query: &SymbolsQuery,
) -> Result<Vec<Symbol>, Error>
pub async fn get_symbols( &self, exchange_id: &str, query: &SymbolsQuery, ) -> Result<Vec<Symbol>, Error>
Retrieves active symbols for one exchange.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn request_instruments(
&self,
exchange_id: &str,
query: &SymbolsQuery,
price_precisions: &HashMap<InstrumentId, u8>,
ts_init: UnixNanos,
) -> Result<Vec<CoinApiInstrument>, Error>
pub async fn request_instruments( &self, exchange_id: &str, query: &SymbolsQuery, price_precisions: &HashMap<InstrumentId, u8>, ts_init: UnixNanos, ) -> Result<Vec<CoinApiInstrument>, Error>
Loads native instruments from the active symbols of one exchange.
Only spot, perpetual, and futures symbols are parsed. Symbols of those types that cannot
be mapped to a native instrument are logged and skipped. An instrument listed in
price_precisions takes that price precision instead of the CoinAPI price resolution.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails. Validation rejects a price precision beyond the Nautilus maximum.
Sourcepub async fn get_book(
&self,
symbol_id: &str,
query: &BookQuery,
) -> Result<Book, Error>
pub async fn get_book( &self, symbol_id: &str, query: &BookQuery, ) -> Result<Book, Error>
Retrieves a current L2 market-by-price book for one symbol.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_book_l3(
&self,
symbol_id: &str,
query: &BookQuery,
) -> Result<Book, Error>
pub async fn get_book_l3( &self, symbol_id: &str, query: &BookQuery, ) -> Result<Book, Error>
Retrieves a current L3 market-by-order book for one symbol.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_quotes(
&self,
symbol_id: &str,
query: &HistoryQuery,
) -> Result<Vec<Quote>, Error>
pub async fn get_quotes( &self, symbol_id: &str, query: &HistoryQuery, ) -> Result<Vec<Quote>, Error>
Retrieves one historical quote page with an explicit window and limit.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_quotes_range(
&self,
symbol_id: &str,
range: &HistoryRange,
) -> Result<HistoryPages<Quote>, Error>
pub async fn get_quotes_range( &self, symbol_id: &str, range: &HistoryRange, ) -> Result<HistoryPages<Quote>, Error>
Retrieves historical quotes across a window, ordered and paged by time_exchange.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, decoding fails, or response ordering fails.
Sourcepub async fn get_trades(
&self,
symbol_id: &str,
query: &TradesQuery,
) -> Result<Vec<Trade>, Error>
pub async fn get_trades( &self, symbol_id: &str, query: &TradesQuery, ) -> Result<Vec<Trade>, Error>
Retrieves one historical trade page with an explicit window and limit.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_trades_range(
&self,
symbol_id: &str,
range: &HistoryRange,
) -> Result<HistoryPages<Trade>, Error>
pub async fn get_trades_range( &self, symbol_id: &str, range: &HistoryRange, ) -> Result<HistoryPages<Trade>, Error>
Retrieves historical trades across a window, ordered and paged by time_exchange.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, decoding fails, or response ordering fails.
Sourcepub async fn get_ohlcv(
&self,
symbol_id: &str,
query: &OhlcvQuery,
) -> Result<Vec<Ohlcv>, Error>
pub async fn get_ohlcv( &self, symbol_id: &str, query: &OhlcvQuery, ) -> Result<Vec<Ohlcv>, Error>
Retrieves one historical OHLCV page for the requested period.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, or decoding fails.
Sourcepub async fn get_ohlcv_range(
&self,
symbol_id: &str,
period_id: &str,
range: &HistoryRange,
) -> Result<HistoryPages<Ohlcv>, Error>
pub async fn get_ohlcv_range( &self, symbol_id: &str, period_id: &str, range: &HistoryRange, ) -> Result<HistoryPages<Ohlcv>, Error>
Retrieves OHLCV periods starting within a window, ordered and paged by
time_period_start.
§Errors
Returns an error if validation fails, the credit budget is exhausted, the transport or HTTP request fails, decoding fails, or response ordering fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CoinApiHttpClient
impl !RefUnwindSafe for CoinApiHttpClient
impl !UnwindSafe for CoinApiHttpClient
impl Send for CoinApiHttpClient
impl Sync for CoinApiHttpClient
impl Unpin for CoinApiHttpClient
impl UnsafeUnpin for CoinApiHttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more