pub struct LightconeApiClient { /* private fields */ }Expand description
Lightcone REST API client.
Provides methods for all Lightcone API endpoints including markets, orderbooks, orders, positions, and price history.
Implementations§
Source§impl LightconeApiClient
impl LightconeApiClient
Sourcepub fn new(base_url: impl Into<String>) -> ApiResult<Self>
pub fn new(base_url: impl Into<String>) -> ApiResult<Self>
Create a new client with the given base URL.
Uses default settings (30s timeout, connection pooling).
§Errors
Returns an error if the HTTP client cannot be initialized.
Sourcepub fn builder(base_url: impl Into<String>) -> LightconeApiClientBuilder
pub fn builder(base_url: impl Into<String>) -> LightconeApiClientBuilder
Create a new client builder for custom configuration.
Sourcepub async fn health_check(&self) -> ApiResult<()>
pub async fn health_check(&self) -> ApiResult<()>
Check API health.
Returns Ok(()) if the API is healthy.
Sourcepub async fn get_markets(&self) -> ApiResult<MarketsResponse>
pub async fn get_markets(&self) -> ApiResult<MarketsResponse>
Get all markets.
Returns a list of all markets with their metadata.
Sourcepub async fn get_market(
&self,
market_pubkey: &str,
) -> ApiResult<MarketInfoResponse>
pub async fn get_market( &self, market_pubkey: &str, ) -> ApiResult<MarketInfoResponse>
Get market details by pubkey.
Returns complete market information including deposit assets.
Sourcepub async fn get_market_by_slug(
&self,
slug: &str,
) -> ApiResult<MarketInfoResponse>
pub async fn get_market_by_slug( &self, slug: &str, ) -> ApiResult<MarketInfoResponse>
Get market by URL-friendly slug.
Sourcepub async fn get_deposit_assets(
&self,
market_pubkey: &str,
) -> ApiResult<DepositAssetsResponse>
pub async fn get_deposit_assets( &self, market_pubkey: &str, ) -> ApiResult<DepositAssetsResponse>
Get deposit assets for a market.
Sourcepub async fn get_orderbook(
&self,
orderbook_id: &str,
depth: Option<u32>,
) -> ApiResult<OrderbookResponse>
pub async fn get_orderbook( &self, orderbook_id: &str, depth: Option<u32>, ) -> ApiResult<OrderbookResponse>
Get orderbook depth.
Returns price levels for bids and asks.
§Arguments
orderbook_id- Orderbook identifier (can be “orderbook_id” or “market_pubkey:orderbook_id”)depth- Optional max price levels per side (0 or None = all)
Sourcepub async fn submit_order(
&self,
request: SubmitOrderRequest,
) -> ApiResult<OrderResponse>
pub async fn submit_order( &self, request: SubmitOrderRequest, ) -> ApiResult<OrderResponse>
Submit a new order.
The order must be pre-signed with the maker’s Ed25519 key.
Sourcepub async fn submit_full_order(
&self,
order: &FullOrder,
orderbook_id: impl Into<String>,
) -> ApiResult<OrderResponse>
pub async fn submit_full_order( &self, order: &FullOrder, orderbook_id: impl Into<String>, ) -> ApiResult<OrderResponse>
Submit a signed FullOrder to the API.
Convenience method that converts the order and submits it. This bridges on-chain order creation with REST API submission.
§Arguments
order- A signed FullOrder (must have calledorder.sign(&keypair))orderbook_id- Target orderbook (useorder.derive_orderbook_id()or from market API)
§Example
let mut order = FullOrder::new_bid(params);
order.sign(&keypair);
let response = api_client
.submit_full_order(&order, order.derive_orderbook_id())
.await?;Sourcepub async fn cancel_order(
&self,
order_hash: &str,
maker: &str,
) -> ApiResult<CancelResponse>
pub async fn cancel_order( &self, order_hash: &str, maker: &str, ) -> ApiResult<CancelResponse>
Cancel a specific order.
The maker must match the order creator.
Sourcepub async fn cancel_all_orders(
&self,
user_pubkey: &str,
market_pubkey: Option<&str>,
) -> ApiResult<CancelAllResponse>
pub async fn cancel_all_orders( &self, user_pubkey: &str, market_pubkey: Option<&str>, ) -> ApiResult<CancelAllResponse>
Cancel all orders for a user.
Optionally filter by market.
Sourcepub async fn get_user_positions(
&self,
user_pubkey: &str,
) -> ApiResult<PositionsResponse>
pub async fn get_user_positions( &self, user_pubkey: &str, ) -> ApiResult<PositionsResponse>
Get all positions for a user.
Sourcepub async fn get_user_market_positions(
&self,
user_pubkey: &str,
market_pubkey: &str,
) -> ApiResult<MarketPositionsResponse>
pub async fn get_user_market_positions( &self, user_pubkey: &str, market_pubkey: &str, ) -> ApiResult<MarketPositionsResponse>
Get user positions in a specific market.
Sourcepub async fn get_user_orders(
&self,
user_pubkey: &str,
) -> ApiResult<UserOrdersResponse>
pub async fn get_user_orders( &self, user_pubkey: &str, ) -> ApiResult<UserOrdersResponse>
Get all open orders and balances for a user.
Sourcepub async fn get_price_history(
&self,
params: PriceHistoryParams,
) -> ApiResult<PriceHistoryResponse>
pub async fn get_price_history( &self, params: PriceHistoryParams, ) -> ApiResult<PriceHistoryResponse>
Get historical price data (candlesticks).
Sourcepub async fn get_trades(
&self,
params: TradesParams,
) -> ApiResult<TradesResponse>
pub async fn get_trades( &self, params: TradesParams, ) -> ApiResult<TradesResponse>
Get executed trades.
Sourcepub async fn admin_health_check(&self) -> ApiResult<AdminResponse>
pub async fn admin_health_check(&self) -> ApiResult<AdminResponse>
Admin health check endpoint.
Sourcepub async fn create_orderbook(
&self,
request: CreateOrderbookRequest,
) -> ApiResult<CreateOrderbookResponse>
pub async fn create_orderbook( &self, request: CreateOrderbookRequest, ) -> ApiResult<CreateOrderbookResponse>
Create a new orderbook for a market.
Trait Implementations§
Source§impl Clone for LightconeApiClient
impl Clone for LightconeApiClient
Source§fn clone(&self) -> LightconeApiClient
fn clone(&self) -> LightconeApiClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LightconeApiClient
impl !RefUnwindSafe for LightconeApiClient
impl Send for LightconeApiClient
impl Sync for LightconeApiClient
impl Unpin for LightconeApiClient
impl !UnwindSafe for LightconeApiClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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