View Source Hyperliquid.Api.Info.AllMids (hyperliquid v0.2.2)
Mapping of coin symbols to mid prices.
This endpoint returns a dynamic map where keys are coin symbols (e.g., "BTC", "ETH") and values are mid prices as strings.
Usage
{:ok, all_mids} = AllMids.request()
{:ok, price} = AllMids.get_mid(all_mids, "BTC")
# => {:ok, "43250.5"}
# Or with bang variant
all_mids = AllMids.request!()
Summary
Functions
Returns metadata about this endpoint.
Returns postgres table configurations (multi-table support).
Returns storage configuration for this endpoint.
Build a cache key from response data using the configured pattern.
Returns nil if cache is not enabled or no pattern configured.
Build the request payload.
Returns true if cache storage is enabled.
Returns the cache TTL if configured.
Creates a changeset for all mids data.
Fetch is an alias for request when no storage is configured.
Get all coin symbols.
Get the mid price for a specific coin.
Parse and validate the API response.
Returns true if postgres storage is enabled.
Returns the postgres table name if configured (primary table for legacy support).
Returns the upsert config for postgres (primary table for legacy support).
Get the rate limit cost for this endpoint.
Make the API request and parse the response.
Make the API request, raising on error.
Make the API request and return the raw response map (no key transformation).
Make the API request returning raw map, raising on error.
Returns true if any storage backend is enabled.
Convert the mids map to a list of {coin, price} tuples.
Types
Functions
Returns metadata about this endpoint.
Example
iex> Hyperliquid.Api.Info.AllMids.__endpoint_info__()
%{
endpoint: "allMids",
type: :info,
rate_limit_cost: 2,
params: [],
optional_params: [:dex],
doc: "Retrieve mid prices for all actively traded coins",
returns: "Map of coin symbols to mid prices as strings"
}
Returns postgres table configurations (multi-table support).
Returns storage configuration for this endpoint.
Build a cache key from response data using the configured pattern.
Returns nil if cache is not enabled or no pattern configured.
Build the request payload.
Returns true if cache storage is enabled.
Returns the cache TTL if configured.
@spec changeset(t(), map()) :: Ecto.Changeset.t()
Creates a changeset for all mids data.
Parameters
all_mids: The all mids structattrs: Map of coin symbols to mid prices
Fetch is an alias for request when no storage is configured.
Get all coin symbols.
Example
iex> get_coins(%AllMids{mids: %{"BTC" => "43250.5", "ETH" => "2280.75"}})
["BTC", "ETH"]
Get the mid price for a specific coin.
Example
iex> get_mid(%AllMids{mids: %{"BTC" => "43250.5"}}, "BTC")
{:ok, "43250.5"}
iex> get_mid(%AllMids{mids: %{"BTC" => "43250.5"}}, "DOGE")
{:error, :not_found}
Parse and validate the API response.
Returns true if postgres storage is enabled.
Returns the postgres table name if configured (primary table for legacy support).
Returns the upsert config for postgres (primary table for legacy support).
@spec rate_limit_cost() :: non_neg_integer()
Get the rate limit cost for this endpoint.
Make the API request and parse the response.
Make the API request, raising on error.
Make the API request and return the raw response map (no key transformation).
Make the API request returning raw map, raising on error.
Returns true if any storage backend is enabled.
Convert the mids map to a list of {coin, price} tuples.
Example
iex> to_list(%AllMids{mids: %{"BTC" => "43250.5", "ETH" => "2280.75"}})
[{"BTC", "43250.5"}, {"ETH", "2280.75"}]