View Source Hyperliquid.Api.Subscription.WebData2 (hyperliquid v0.2.2)
WebSocket subscription for comprehensive user and market data.
Auto-generated from @nktkas/hyperliquid v0.26.0 Source: src/api/subscription/webData2.ts
Description
Subscription to comprehensive user and market data events. This includes:
- Clearinghouse state (perpetual trading account summary)
- Leading vaults information
- Open orders with frontend information
- Agent information
- Market metadata and asset contexts
- TWAP states
- Spot state and asset contexts (optional)
Usage
# Subscribe to webData2 events
params = %{user: "0x..."}
Hyperliquid.Api.Subscription.WebData2.subscribe(params, fn event ->
IO.inspect(event, label: "WebData2 Event")
end)
Summary
Functions
Returns postgres table configurations (multi-table support).
Returns storage configuration for this subscription.
Returns metadata about this subscription endpoint.
Build a cache key from event data using the configured pattern.
Build and validate a subscription request.
Returns true if cache storage is enabled.
Returns the configured cache fields for partial storage, or nil for all fields.
Returns the cache TTL if configured.
Changeset for validating webData2 event data.
Generate a unique subscription key for this parameter set.
Parses raw WebSocket event data into structured format.
Returns true if postgres storage is enabled.
Returns the configured postgres fields for partial storage, or nil for all fields.
Returns the postgres table name if configured (primary table for legacy support).
Returns true if any storage backend is enabled.
Subscribe to webData2 events for a specific user.
Types
@type request_params() :: %{user: term()}
Functions
Returns postgres table configurations (multi-table support).
Returns storage configuration for this subscription.
Returns metadata about this subscription endpoint.
Build a cache key from event data using the configured pattern.
Returns nil if cache is not enabled or no pattern is configured.
@spec build_request(map()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
@spec build_request(map()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
Build and validate a subscription request.
Parameters
params- Map with keys: [:user]
Returns
{:ok, request_map}- Valid subscription request{:error, changeset}- Validation errors
Returns true if cache storage is enabled.
Returns the configured cache fields for partial storage, or nil for all fields.
Returns the cache TTL if configured.
Changeset for validating webData2 event data.
Generate a unique subscription key for this parameter set.
Parameters
params- Map of subscription parameters
Returns
String key that uniquely identifies this subscription variant.
Parses raw WebSocket event data into structured format.
Returns true if postgres storage is enabled.
Returns the configured postgres fields for partial storage, or nil for all fields.
Returns the postgres table name if configured (primary table for legacy support).
Returns true if any storage backend is enabled.
Subscribe to webData2 events for a specific user.
Parameters
params: Map with:userkey (Ethereum address)callback: Function to handle incoming events
Returns
{:ok, subscription}- Subscription handle{:error, reason}- If subscription fails
Example
WebData2.subscribe(
%{user: "0x1234..."},
fn event ->
IO.puts("Vault equity: #{event.total_vault_equity}")
end
)