pub struct LighterHttpClient { /* private fields */ }Expand description
Domain HTTP client for Lighter REST operations.
This client wraps LighterRawHttpClient and converts selected endpoint responses into
Nautilus domain data. Market metadata calls also populate the shared MarketRegistry.
Implementations§
Source§impl LighterHttpClient
impl LighterHttpClient
Sourcepub fn new(
environment: LighterEnvironment,
base_url: Option<String>,
timeout_secs: u64,
proxy_url: Option<String>,
) -> LighterHttpResult<Self>
pub fn new( environment: LighterEnvironment, base_url: Option<String>, timeout_secs: u64, proxy_url: Option<String>, ) -> LighterHttpResult<Self>
Creates a new LighterHttpClient.
§Errors
Returns an error if the underlying raw HTTP client cannot be created.
Sourcepub fn from_raw(raw_client: LighterRawHttpClient) -> Self
pub fn from_raw(raw_client: LighterRawHttpClient) -> Self
Wraps an existing raw HTTP client.
Sourcepub fn from_raw_with_registry(
raw_client: LighterRawHttpClient,
market_registry: Arc<MarketRegistry>,
) -> Self
pub fn from_raw_with_registry( raw_client: LighterRawHttpClient, market_registry: Arc<MarketRegistry>, ) -> Self
Wraps an existing raw HTTP client and shared market registry.
Sourcepub fn environment(&self) -> LighterEnvironment
pub fn environment(&self) -> LighterEnvironment
Returns the configured Lighter environment.
Sourcepub fn market_registry(&self) -> Arc<MarketRegistry> ⓘ
pub fn market_registry(&self) -> Arc<MarketRegistry> ⓘ
Returns the shared market registry used by this client.
Sourcepub fn set_base_url(&mut self, base_url: &str)
pub fn set_base_url(&mut self, base_url: &str)
Sourcepub async fn get_order_books(
&self,
query: &LighterOrderBooksQuery,
) -> LighterHttpResult<LighterOrderBooks>
pub async fn get_order_books( &self, query: &LighterOrderBooksQuery, ) -> LighterHttpResult<LighterOrderBooks>
Calls GET /api/v1/orderBooks and registers returned markets.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_order_book_details(
&self,
query: &LighterOrderBookDetailsQuery,
) -> LighterHttpResult<LighterOrderBookDetails>
pub async fn get_order_book_details( &self, query: &LighterOrderBookDetailsQuery, ) -> LighterHttpResult<LighterOrderBookDetails>
Calls GET /api/v1/orderBookDetails and registers returned markets.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_order_book_orders(
&self,
query: &LighterOrderBookOrdersQuery,
) -> LighterHttpResult<LighterOrderBookOrders>
pub async fn get_order_book_orders( &self, query: &LighterOrderBookOrdersQuery, ) -> LighterHttpResult<LighterOrderBookOrders>
Calls GET /api/v1/orderBookOrders.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_recent_trades(
&self,
query: &LighterRecentTradesQuery,
) -> LighterHttpResult<LighterTrades>
pub async fn get_recent_trades( &self, query: &LighterRecentTradesQuery, ) -> LighterHttpResult<LighterTrades>
Calls GET /api/v1/recentTrades.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_trades(
&self,
query: &LighterTradesQuery,
) -> LighterHttpResult<LighterTrades>
pub async fn get_trades( &self, query: &LighterTradesQuery, ) -> LighterHttpResult<LighterTrades>
Sourcepub async fn get_candles(
&self,
query: &LighterCandlesQuery,
) -> LighterHttpResult<LighterCandles>
pub async fn get_candles( &self, query: &LighterCandlesQuery, ) -> LighterHttpResult<LighterCandles>
Calls GET /api/v1/candles.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_fundings(
&self,
query: &LighterFundingsQuery,
) -> LighterHttpResult<LighterFundings>
pub async fn get_fundings( &self, query: &LighterFundingsQuery, ) -> LighterHttpResult<LighterFundings>
Calls GET /api/v1/fundings.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_account_detail(
&self,
account_index: i64,
) -> LighterHttpResult<LighterAccountDetail>
pub async fn get_account_detail( &self, account_index: i64, ) -> LighterHttpResult<LighterAccountDetail>
Fetches the account row for account_index via GET /api/v1/account.
§Errors
Returns an error if the request fails, the response is invalid, or the venue returns no account for the index.
Sourcepub async fn get_account_active_orders(
&self,
query: &LighterAccountActiveOrdersQuery,
) -> LighterHttpResult<LighterOrders>
pub async fn get_account_active_orders( &self, query: &LighterAccountActiveOrdersQuery, ) -> LighterHttpResult<LighterOrders>
Calls GET /api/v1/accountActiveOrders.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_account_inactive_orders(
&self,
query: &LighterAccountInactiveOrdersQuery,
) -> LighterHttpResult<LighterOrders>
pub async fn get_account_inactive_orders( &self, query: &LighterAccountInactiveOrdersQuery, ) -> LighterHttpResult<LighterOrders>
Calls GET /api/v1/accountInactiveOrders.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_next_nonce(
&self,
account_index: i64,
api_key_index: u8,
) -> LighterHttpResult<LighterNextNonce>
pub async fn get_next_nonce( &self, account_index: i64, api_key_index: u8, ) -> LighterHttpResult<LighterNextNonce>
Calls GET /api/v1/nextNonce for (account_index, api_key_index).
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn get_maker_only_api_keys(
&self,
account_index: i64,
auth_token: impl Into<String>,
) -> LighterHttpResult<LighterMakerOnlyApiKeys>
pub async fn get_maker_only_api_keys( &self, account_index: i64, auth_token: impl Into<String>, ) -> LighterHttpResult<LighterMakerOnlyApiKeys>
Calls GET /api/v1/getMakerOnlyApiKeys for account_index.
auth_token is the canonical Lighter auth string minted from the
caller’s credential.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn send_tx(
&self,
request: &LighterSendTxRequest,
) -> LighterHttpResult<LighterSendTxResponse>
pub async fn send_tx( &self, request: &LighterSendTxRequest, ) -> LighterHttpResult<LighterSendTxResponse>
Calls POST /api/v1/sendTx.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn send_tx_batch(
&self,
request: &LighterSendTxBatchRequest,
) -> LighterHttpResult<LighterSendTxBatchResponse>
pub async fn send_tx_batch( &self, request: &LighterSendTxBatchRequest, ) -> LighterHttpResult<LighterSendTxBatchResponse>
Calls POST /api/v1/sendTxBatch.
§Errors
Returns an error if the request fails or the response is invalid.
Sourcepub async fn request_recent_trades(
&self,
instrument: &InstrumentAny,
limit: u16,
) -> LighterHttpResult<Vec<TradeTick>>
pub async fn request_recent_trades( &self, instrument: &InstrumentAny, limit: u16, ) -> LighterHttpResult<Vec<TradeTick>>
Requests recent trades for an instrument and parses them into [TradeTick]s.
§Errors
Returns an error if the instrument has not been registered, the request fails, or a trade cannot be parsed.
Sourcepub async fn request_trades(
&self,
instrument: &InstrumentAny,
query: LighterTradesQuery,
) -> LighterHttpResult<Vec<TradeTick>>
pub async fn request_trades( &self, instrument: &InstrumentAny, query: LighterTradesQuery, ) -> LighterHttpResult<Vec<TradeTick>>
Requests historical trades and parses them into [TradeTick]s.
If query.market_id is None, the value is resolved from the shared market registry.
§Errors
Returns an error if the instrument has not been registered, the request fails, or a trade cannot be parsed.
Sourcepub async fn request_bars(
&self,
instrument: &InstrumentAny,
bar_type: BarType,
start: Option<DateTime<Utc>>,
end: Option<DateTime<Utc>>,
limit: Option<u32>,
) -> LighterHttpResult<Vec<Bar>>
pub async fn request_bars( &self, instrument: &InstrumentAny, bar_type: BarType, start: Option<DateTime<Utc>>, end: Option<DateTime<Utc>>, limit: Option<u32>, ) -> LighterHttpResult<Vec<Bar>>
Requests historical candles and parses them into Nautilus [Bar]s.
§Errors
Returns an error if the instrument has not been registered, the bar type is unsupported, the request fails, or a candle cannot be parsed.
Sourcepub async fn request_funding_rates(
&self,
instrument: &InstrumentAny,
start: Option<DateTime<Utc>>,
end: Option<DateTime<Utc>>,
limit: Option<usize>,
) -> LighterHttpResult<Vec<FundingRateUpdate>>
pub async fn request_funding_rates( &self, instrument: &InstrumentAny, start: Option<DateTime<Utc>>, end: Option<DateTime<Utc>>, limit: Option<usize>, ) -> LighterHttpResult<Vec<FundingRateUpdate>>
Requests historical funding rates and parses them into Nautilus updates.
Lighter’s public /api/v1/fundings endpoint returns settled funding
rows at hourly or daily resolution. The adapter requests hourly rows and
returns them in chronological order.
§Errors
Returns an error if the instrument is not a perpetual, the instrument has not been registered, the request range is invalid, or a row cannot be parsed.
Sourcepub async fn request_instruments(&self) -> LighterHttpResult<Vec<InstrumentAny>>
pub async fn request_instruments(&self) -> LighterHttpResult<Vec<InstrumentAny>>
Requests all instruments from Lighter order book metadata.
Lighter exposes market definitions through GET /api/v1/orderBookDetails.
§Errors
Returns an error if the request fails or an instrument cannot be parsed.
Sourcepub async fn request_instruments_with_status(
&self,
) -> LighterHttpResult<Vec<(InstrumentAny, LighterMarketStatus)>>
pub async fn request_instruments_with_status( &self, ) -> LighterHttpResult<Vec<(InstrumentAny, LighterMarketStatus)>>
Requests all instruments and their market statuses from Lighter order book metadata.
§Errors
Returns an error if the request fails or an instrument cannot be parsed.
Sourcepub async fn request_instrument(
&self,
instrument_id: InstrumentId,
) -> LighterHttpResult<InstrumentAny>
pub async fn request_instrument( &self, instrument_id: InstrumentId, ) -> LighterHttpResult<InstrumentAny>
Requests a single instrument from Lighter order book metadata.
§Errors
Returns an error if the request fails, the instrument is not found, or the instrument cannot be parsed.
Sourcepub async fn request_instrument_with_status(
&self,
instrument_id: InstrumentId,
) -> LighterHttpResult<(InstrumentAny, LighterMarketStatus)>
pub async fn request_instrument_with_status( &self, instrument_id: InstrumentId, ) -> LighterHttpResult<(InstrumentAny, LighterMarketStatus)>
Requests a single instrument and its market status from Lighter order book metadata.
§Errors
Returns an error if the request fails, the instrument is not found, or the instrument cannot be parsed.
Sourcepub async fn request_order_book_snapshot(
&self,
instrument: &InstrumentAny,
limit: u16,
) -> LighterHttpResult<OrderBookDeltas>
pub async fn request_order_book_snapshot( &self, instrument: &InstrumentAny, limit: u16, ) -> LighterHttpResult<OrderBookDeltas>
Requests an HTTP order book snapshot and parses it into Nautilus order book deltas.
§Errors
Returns an error if the instrument has not been registered, the request fails, or any level cannot be parsed.
Trait Implementations§
Source§impl Clone for LighterHttpClient
impl Clone for LighterHttpClient
Source§fn clone(&self) -> LighterHttpClient
fn clone(&self) -> LighterHttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LighterHttpClient
impl Debug for LighterHttpClient
Auto Trait Implementations§
impl !RefUnwindSafe for LighterHttpClient
impl !UnwindSafe for LighterHttpClient
impl Freeze for LighterHttpClient
impl Send for LighterHttpClient
impl Sync for LighterHttpClient
impl Unpin for LighterHttpClient
impl UnsafeUnpin for LighterHttpClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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