Skip to main content

HyperliquidRawHttpClient

Struct HyperliquidRawHttpClient 

Source
pub struct HyperliquidRawHttpClient { /* private fields */ }
Expand description

Provides a raw HTTP client for low-level Hyperliquid REST API operations.

This client handles HTTP infrastructure, request signing, and raw API calls that closely match Hyperliquid endpoint specifications.

Implementations§

Source§

impl HyperliquidRawHttpClient

Source

pub fn new( environment: HyperliquidEnvironment, timeout_secs: u64, proxy_url: Option<String>, ) -> Result<Self, HttpClientError>

Creates a new HyperliquidRawHttpClient for public endpoints only.

§Errors

Returns an error if the HTTP client cannot be created.

Source

pub fn with_credentials( secrets: &Secrets, timeout_secs: u64, proxy_url: Option<String>, ) -> Result<Self, HttpClientError>

Creates a new HyperliquidRawHttpClient configured with credentials for authenticated requests.

§Errors

Returns an error if the HTTP client cannot be created.

Source

pub fn set_base_info_url(&mut self, url: String)

Overrides the base info URL (for testing with mock servers).

Source

pub fn set_base_exchange_url(&mut self, url: String)

Overrides the base exchange URL (for testing with mock servers).

Source

pub fn from_env(environment: HyperliquidEnvironment) -> Result<Self>

Creates an authenticated client from environment variables for the specified network.

§Errors

Returns Error::Auth if required environment variables are not set.

Source

pub fn from_credentials( private_key: &str, vault_address: Option<&str>, environment: HyperliquidEnvironment, timeout_secs: u64, proxy_url: Option<String>, ) -> Result<Self>

Creates a new HyperliquidRawHttpClient configured with explicit credentials.

§Errors

Returns Error::Auth if the private key is invalid or cannot be parsed.

Source

pub fn with_rate_limits(self) -> Self

Configure rate limiting parameters (chainable).

Source

pub fn environment(&self) -> HyperliquidEnvironment

Returns the configured environment.

Source

pub fn is_testnet(&self) -> bool

Returns whether this client is configured for testnet.

Source

pub fn get_user_address(&self) -> Result<String>

Gets the user address derived from the private key (if client has credentials).

§Errors

Returns Error::Auth if the client has no signer configured.

Source

pub fn has_vault_address(&self) -> bool

Returns true if a vault address is configured.

Source

pub fn get_account_address(&self) -> Result<String>

Gets the account address for queries: vault address if configured, otherwise the user (EOA) address.

§Errors

Returns Error::Auth if the client has no signer configured.

Source

pub async fn info_meta(&self) -> Result<HyperliquidMeta>

Get metadata about available markets.

Source

pub async fn get_spot_meta(&self) -> Result<SpotMeta>

Get complete spot metadata (tokens and pairs).

Source

pub async fn get_perp_meta_and_ctxs(&self) -> Result<PerpMetaAndCtxs>

Get perpetuals metadata with asset contexts (for price precision refinement).

Source

pub async fn get_spot_meta_and_ctxs(&self) -> Result<SpotMetaAndCtxs>

Get spot metadata with asset contexts (for price precision refinement).

Source

pub async fn get_outcome_meta(&self) -> Result<OutcomeMeta>

Get outcome metadata.

Source

pub async fn info_l2_book(&self, coin: &str) -> Result<HyperliquidL2Book>

Get L2 order book for a coin.

Source

pub async fn info_recent_trades( &self, coin: &str, ) -> Result<Vec<HyperliquidRecentTrade>>

Get recent public trades for a coin.

Returns a recent snapshot (newest first) with no time range. Depends on the Hyperliquid indexer: self-hosted /info nodes return HTTP 422.

Source

pub async fn info_user_fills(&self, user: &str) -> Result<HyperliquidFills>

Get user fills (trading history).

Source

pub async fn info_order_status( &self, user: &str, oid: u64, ) -> Result<HyperliquidOrderStatus>

Get order status for a user.

Source

pub async fn info_open_orders(&self, user: &str) -> Result<Value>

Get all open orders for a user.

Source

pub async fn info_frontend_open_orders(&self, user: &str) -> Result<Value>

Get frontend open orders (includes more detail) for a user.

Source

pub async fn info_clearinghouse_state(&self, user: &str) -> Result<Value>

Get clearinghouse state (balances, positions, margin) for a user.

Source

pub async fn info_spot_clearinghouse_state(&self, user: &str) -> Result<Value>

Get spot clearinghouse state (per-token spot balances) for a user.

Source

pub async fn info_user_fees(&self, user: &str) -> Result<Value>

Get user fee schedule and effective rates.

Source

pub async fn info_candle_snapshot( &self, coin: &str, interval: HyperliquidBarInterval, start_time: u64, end_time: u64, ) -> Result<HyperliquidCandleSnapshot>

Get candle/bar data for a coin.

Source

pub async fn info_funding_history( &self, coin: &str, start_time: u64, end_time: Option<u64>, ) -> Result<Vec<HyperliquidFundingHistoryEntry>>

Get historical funding rates for a coin.

start_time and end_time are Unix milliseconds. end_time is optional; if omitted, the venue returns entries up to the most recent funding.

Source

pub async fn send_info_request_raw( &self, request: &InfoRequest, ) -> Result<Value>

Generic info request method that returns raw JSON (useful for new endpoints and testing).

Source

pub async fn post_action( &self, action: &ExchangeAction, ) -> Result<HyperliquidExchangeResponse>

Send a signed action to the exchange.

Source

pub fn sign_action_exec_request( &self, action: &HyperliquidExecAction, expires_after: Option<u64>, ) -> Result<HyperliquidExchangeRequest<HyperliquidExecAction>>

Build a signed exchange request using the typed HyperliquidExecAction enum.

Source

pub async fn post_action_exec( &self, action: &HyperliquidExecAction, ) -> Result<HyperliquidExchangeResponse>

Send a signed action to the exchange using the typed HyperliquidExecAction enum.

This is the preferred method for placing orders as it uses properly typed structures that match Hyperliquid’s API expectations exactly.

Source

pub async fn rest_limiter_snapshot(&self) -> RateLimitSnapshot

Submit a single order to the Hyperliquid exchange.

Trait Implementations§

Source§

impl Clone for HyperliquidRawHttpClient

Source§

fn clone(&self) -> HyperliquidRawHttpClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for HyperliquidRawHttpClient

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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