Skip to content

Hyperliquid

Convenience bundle of info, exchange, and streams.

http

Source code in pkg/src/hyperliquid/__init__.py
@classmethod
def http(cls, wallet: Wallet | None = None, /, *, mainnet: bool = True, validate: bool = True):
  wallet = _parse_wallet(wallet)
  from .core import HttpClient
  http = HttpClient()
  return cls(
    info=Info.http(mainnet=mainnet, validate=validate, http=http),
    exchange=Exchange.http(wallet, mainnet=mainnet, validate=validate, http=http),
    streams=Streams.new(mainnet=mainnet, validate=validate),
  )

ws

Source code in pkg/src/hyperliquid/__init__.py
@classmethod
def ws(cls, wallet: Wallet | None = None, *, mainnet: bool = True, validate: bool = True):
  wallet = _parse_wallet(wallet)
  from .core import SocketClient
  domain = HYPERLIQUID_MAINNET if mainnet else HYPERLIQUID_TESTNET
  ws = SocketClient(url=f'wss://{domain}/ws')
  return cls(
    info=Info.ws_of(ws, validate=validate),
    exchange=Exchange.ws_of(wallet, ws=ws, mainnet=mainnet, validate=validate),
    streams=Streams.of(ws, validate=validate),
  )