Expand description
Hyperliquid SDK for Rust
A simple, performant SDK for trading on Hyperliquid.
§Quick Start
use hyperliquid_sdk::{HyperliquidSDK, Side, TIF};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize with private key (or set PRIVATE_KEY env var)
let sdk = HyperliquidSDK::new()
.endpoint("https://your-endpoint.hype-mainnet.quiknode.pro/TOKEN")
.private_key("0x...")
.build()
.await?;
// Market buy $100 worth of BTC
let order = sdk.market_buy("BTC").await.notional(100.0).await?;
println!("Order placed: {:?}", order.oid);
// Or use the fluent builder
use hyperliquid_sdk::Order;
let order = sdk.order(
Order::buy("BTC").size(0.001).price(65000.0).gtc()
).await?;
Ok(())
}§Features
- Trading: Market/limit orders, stop-loss, take-profit, TWAP
- Order Management: Cancel, modify, batch operations
- Info API: Market data, positions, open orders, account state
- HyperCore: Real-time block data, trades, order book updates
- Streaming: WebSocket and gRPC (optional) for real-time data
- HyperEVM: Ethereum JSON-RPC compatibility
Re-exports§
pub use types::Chain;pub use types::Side;pub use types::TIF;pub use types::TpSl;pub use types::OrderGrouping;pub use types::Signature;pub use types::OrderRequest;pub use types::OrderTypePlacement;pub use types::TimeInForce;pub use types::Action;pub use types::ActionRequest;pub use order::Order;pub use order::TriggerOrder;pub use order::PlacedOrder;pub use error::Error;pub use error::Result;pub use client::HyperliquidSDK;pub use client::HyperliquidSDKBuilder;pub use client::EndpointInfo;pub use info::Info;pub use hypercore::HyperCore;pub use evm::EVM;pub use stream::Stream;pub use evm_stream::EVMStream;pub use evm_stream::EVMSubscriptionType;pub use evm_stream::EVMConnectionState;pub use grpc::GRPCStream;
Modules§
- client
- Main SDK client for Hyperliquid.
- error
- Error types for the Hyperliquid SDK.
- evm
- EVM (HyperEVM) client for Hyperliquid.
- evm_
stream - EVM WebSocket streaming client for HyperEVM.
- grpc
- gRPC streaming client for Hyperliquid.
- hypercore
- HyperCore API client for Hyperliquid.
- info
- Info API client for Hyperliquid.
- order
- Order builders for the Hyperliquid SDK.
- signing
- Signing utilities for Hyperliquid transactions.
- stream
- WebSocket streaming client for Hyperliquid.
- types
- Core types for the Hyperliquid SDK.
Enums§
- Value
- Represents any valid JSON value.