Skip to main content

LightconeApiClient

Struct LightconeApiClient 

Source
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

Source

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.

Source

pub fn builder(base_url: impl Into<String>) -> LightconeApiClientBuilder

Create a new client builder for custom configuration.

Source

pub fn base_url(&self) -> &str

Get the base URL.

Source

pub async fn health_check(&self) -> ApiResult<()>

Check API health.

Returns Ok(()) if the API is healthy.

Source

pub async fn get_markets(&self) -> ApiResult<MarketsResponse>

Get all markets.

Returns a list of all markets with their metadata.

Source

pub async fn get_market( &self, market_pubkey: &str, ) -> ApiResult<MarketInfoResponse>

Get market details by pubkey.

Returns complete market information including deposit assets.

Source

pub async fn get_market_by_slug( &self, slug: &str, ) -> ApiResult<MarketInfoResponse>

Get market by URL-friendly slug.

Source

pub async fn get_deposit_assets( &self, market_pubkey: &str, ) -> ApiResult<DepositAssetsResponse>

Get deposit assets for a market.

Source

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)
Source

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.

Source

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 called order.sign(&keypair))
  • orderbook_id - Target orderbook (use order.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?;
Source

pub async fn cancel_order( &self, order_hash: &str, maker: &str, ) -> ApiResult<CancelResponse>

Cancel a specific order.

The maker must match the order creator.

Source

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.

Source

pub async fn get_user_positions( &self, user_pubkey: &str, ) -> ApiResult<PositionsResponse>

Get all positions for a user.

Source

pub async fn get_user_market_positions( &self, user_pubkey: &str, market_pubkey: &str, ) -> ApiResult<MarketPositionsResponse>

Get user positions in a specific market.

Source

pub async fn get_user_orders( &self, user_pubkey: &str, ) -> ApiResult<UserOrdersResponse>

Get all open orders and balances for a user.

Source

pub async fn get_price_history( &self, params: PriceHistoryParams, ) -> ApiResult<PriceHistoryResponse>

Get historical price data (candlesticks).

Source

pub async fn get_trades( &self, params: TradesParams, ) -> ApiResult<TradesResponse>

Get executed trades.

Source

pub async fn admin_health_check(&self) -> ApiResult<AdminResponse>

Admin health check endpoint.

Source

pub async fn create_orderbook( &self, request: CreateOrderbookRequest, ) -> ApiResult<CreateOrderbookResponse>

Create a new orderbook for a market.

Trait Implementations§

Source§

impl Clone for LightconeApiClient

Source§

fn clone(&self) -> LightconeApiClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LightconeApiClient

Source§

fn fmt(&self, f: &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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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