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
impl HyperliquidRawHttpClient
Sourcepub fn new(
environment: HyperliquidEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
) -> Result<Self, HttpClientError>
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.
Sourcepub fn with_credentials(
secrets: &Secrets,
timeout_secs: u64,
proxy_url: Option<String>,
) -> Result<Self, HttpClientError>
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.
Sourcepub fn set_base_info_url(&mut self, url: String)
pub fn set_base_info_url(&mut self, url: String)
Overrides the base info URL (for testing with mock servers).
Sourcepub fn set_base_exchange_url(&mut self, url: String)
pub fn set_base_exchange_url(&mut self, url: String)
Overrides the base exchange URL (for testing with mock servers).
Sourcepub fn from_env(environment: HyperliquidEnvironment) -> Result<Self>
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.
Sourcepub fn from_credentials(
private_key: &str,
vault_address: Option<&str>,
environment: HyperliquidEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
) -> Result<Self>
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.
Sourcepub fn with_rate_limits(self) -> Self
pub fn with_rate_limits(self) -> Self
Configure rate limiting parameters (chainable).
Sourcepub fn environment(&self) -> HyperliquidEnvironment
pub fn environment(&self) -> HyperliquidEnvironment
Returns the configured environment.
Sourcepub fn is_testnet(&self) -> bool
pub fn is_testnet(&self) -> bool
Returns whether this client is configured for testnet.
Sourcepub fn get_user_address(&self) -> Result<String>
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.
Sourcepub fn has_vault_address(&self) -> bool
pub fn has_vault_address(&self) -> bool
Returns true if a vault address is configured.
Sourcepub fn get_account_address(&self) -> Result<String>
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.
Sourcepub async fn info_meta(&self) -> Result<HyperliquidMeta>
pub async fn info_meta(&self) -> Result<HyperliquidMeta>
Get metadata about available markets.
Sourcepub async fn get_spot_meta(&self) -> Result<SpotMeta>
pub async fn get_spot_meta(&self) -> Result<SpotMeta>
Get complete spot metadata (tokens and pairs).
Sourcepub async fn get_perp_meta_and_ctxs(&self) -> Result<PerpMetaAndCtxs>
pub async fn get_perp_meta_and_ctxs(&self) -> Result<PerpMetaAndCtxs>
Get perpetuals metadata with asset contexts (for price precision refinement).
Sourcepub async fn get_spot_meta_and_ctxs(&self) -> Result<SpotMetaAndCtxs>
pub async fn get_spot_meta_and_ctxs(&self) -> Result<SpotMetaAndCtxs>
Get spot metadata with asset contexts (for price precision refinement).
Sourcepub async fn get_outcome_meta(&self) -> Result<OutcomeMeta>
pub async fn get_outcome_meta(&self) -> Result<OutcomeMeta>
Get outcome metadata.
Sourcepub async fn info_l2_book(&self, coin: &str) -> Result<HyperliquidL2Book>
pub async fn info_l2_book(&self, coin: &str) -> Result<HyperliquidL2Book>
Get L2 order book for a coin.
Sourcepub async fn info_recent_trades(
&self,
coin: &str,
) -> Result<Vec<HyperliquidRecentTrade>>
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.
Sourcepub async fn info_user_fills(&self, user: &str) -> Result<HyperliquidFills>
pub async fn info_user_fills(&self, user: &str) -> Result<HyperliquidFills>
Get user fills (trading history).
Sourcepub async fn info_order_status(
&self,
user: &str,
oid: u64,
) -> Result<HyperliquidOrderStatus>
pub async fn info_order_status( &self, user: &str, oid: u64, ) -> Result<HyperliquidOrderStatus>
Get order status for a user.
Sourcepub async fn info_open_orders(&self, user: &str) -> Result<Value>
pub async fn info_open_orders(&self, user: &str) -> Result<Value>
Get all open orders for a user.
Sourcepub async fn info_frontend_open_orders(&self, user: &str) -> Result<Value>
pub async fn info_frontend_open_orders(&self, user: &str) -> Result<Value>
Get frontend open orders (includes more detail) for a user.
Sourcepub async fn info_clearinghouse_state(&self, user: &str) -> Result<Value>
pub async fn info_clearinghouse_state(&self, user: &str) -> Result<Value>
Get clearinghouse state (balances, positions, margin) for a user.
Sourcepub async fn info_spot_clearinghouse_state(&self, user: &str) -> Result<Value>
pub async fn info_spot_clearinghouse_state(&self, user: &str) -> Result<Value>
Get spot clearinghouse state (per-token spot balances) for a user.
Sourcepub async fn info_user_fees(&self, user: &str) -> Result<Value>
pub async fn info_user_fees(&self, user: &str) -> Result<Value>
Get user fee schedule and effective rates.
Sourcepub async fn info_candle_snapshot(
&self,
coin: &str,
interval: HyperliquidBarInterval,
start_time: u64,
end_time: u64,
) -> Result<HyperliquidCandleSnapshot>
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.
Sourcepub async fn info_funding_history(
&self,
coin: &str,
start_time: u64,
end_time: Option<u64>,
) -> Result<Vec<HyperliquidFundingHistoryEntry>>
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.
Sourcepub async fn send_info_request_raw(
&self,
request: &InfoRequest,
) -> Result<Value>
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).
Sourcepub async fn post_action(
&self,
action: &ExchangeAction,
) -> Result<HyperliquidExchangeResponse>
pub async fn post_action( &self, action: &ExchangeAction, ) -> Result<HyperliquidExchangeResponse>
Send a signed action to the exchange.
Sourcepub fn sign_action_exec_request(
&self,
action: &HyperliquidExecAction,
expires_after: Option<u64>,
) -> Result<HyperliquidExchangeRequest<HyperliquidExecAction>>
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.
Sourcepub async fn post_action_exec(
&self,
action: &HyperliquidExecAction,
) -> Result<HyperliquidExchangeResponse>
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.
Sourcepub async fn rest_limiter_snapshot(&self) -> RateLimitSnapshot
pub async fn rest_limiter_snapshot(&self) -> RateLimitSnapshot
Submit a single order to the Hyperliquid exchange.
Trait Implementations§
Source§impl Clone for HyperliquidRawHttpClient
impl Clone for HyperliquidRawHttpClient
Source§fn clone(&self) -> HyperliquidRawHttpClient
fn clone(&self) -> HyperliquidRawHttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HyperliquidRawHttpClient
impl !UnwindSafe for HyperliquidRawHttpClient
impl Freeze for HyperliquidRawHttpClient
impl Send for HyperliquidRawHttpClient
impl Sync for HyperliquidRawHttpClient
impl Unpin for HyperliquidRawHttpClient
impl UnsafeUnpin for HyperliquidRawHttpClient
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,
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