View Source Hyperliquid.Api.Info.AllPerpMetas (hyperliquid v0.2.2)

Metadata for perpetual assets across all or a specific DEX.

This is similar to the meta endpoint but allows querying metadata for a specific builder-deployed DEX.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals

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 perp metas data.

Get all coin names in the universe.

Fetch data and persist to configured storage backends.

Fetch data and persist. Raises on error.

Find a universe entry by coin name.

Get the margin table by ID.

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.

Store margin tables to the margin_tables table.

Transform margin tables for storage.

Types

@type t() :: %Hyperliquid.Api.Info.AllPerpMetas{
  collateral_token: non_neg_integer(),
  margin_tables: [MarginTable.t()],
  universe: [Universe.t()]
}

Functions

Returns metadata about this endpoint.

Example

iex> Hyperliquid.Api.Info.AllPerpMetas.__endpoint_info__()
%{
  endpoint: "allPerpMetas",
  type: :info,
  rate_limit_cost: 2,
  params: [],
  optional_params: [],
  doc: "Retrieve metadata for perpetual assets across all or a specific DEX",
  returns: "Universe of perp assets with margin tables and collateral token"
}

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.

@spec build_request() :: map()

Build the request payload.

Returns true if cache storage is enabled.

Returns the cache TTL if configured.

Link to this function

changeset(all_perp_metas \\ %__MODULE__{}, attrs)

View Source
@spec changeset(t(), map()) :: Ecto.Changeset.t()

Creates a changeset for all perp metas data.

Parameters

  • all_perp_metas: The all perp metas struct
  • attrs: Map of attributes to validate

Returns

  • Ecto.Changeset.t()
Link to this function

coin_names(all_perp_metas)

View Source
@spec coin_names(t()) :: [String.t()]

Get all coin names in the universe.

Parameters

  • all_perp_metas: The all perp metas struct

Returns

  • List of coin names
@spec fetch() :: {:ok, t()} | {:error, term()}

Fetch data and persist to configured storage backends.

This calls request/0 and then stores the result using Storage.Writer.

@spec fetch!() :: t()

Fetch data and persist. Raises on error.

Link to this function

find_universe(all_perp_metas, name)

View Source
@spec find_universe(t(), String.t()) :: {:ok, map()} | {:error, :not_found}

Find a universe entry by coin name.

Parameters

  • all_perp_metas: The all perp metas struct
  • name: Coin name (e.g., "BTC", "ETH")

Returns

  • {:ok, Universe.t()} if found
  • {:error, :not_found} if not found
Link to this function

get_margin_table(all_perp_metas, id)

View Source
@spec get_margin_table(t(), integer()) :: {:ok, map()} | {:error, :not_found}

Get the margin table by ID.

Parameters

  • all_perp_metas: The all perp metas struct
  • id: Margin table ID

Returns

  • {:ok, MarginTable.t()} if found
  • {:error, :not_found} if not found
@spec parse_response(map()) :: {:ok, t()} | {:error, term()}

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).

Link to this function

postgres_upsert_config()

View Source

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.

@spec request() :: {:ok, t()} | {:error, term()}

Make the API request and parse the response.

@spec request!() :: t()

Make the API request, raising on error.

@spec request_raw() :: {:ok, map()} | {:error, term()}

Make the API request and return the raw response map (no key transformation).

@spec request_raw!() :: map()

Make the API request returning raw map, raising on error.

Returns true if any storage backend is enabled.

Link to this function

store_margin_tables(all_perp_metas)

View Source
@spec store_margin_tables(t()) :: {:ok, non_neg_integer()} | {:error, term()}

Store margin tables to the margin_tables table.

This is separate from the main storage (perp_assets) since we need to store to two different tables from one API response.

Parameters

  • all_perp_metas: The AllPerpMetas struct with margin_tables

Returns

  • {:ok, count} - Number of margin tables stored/updated
  • {:error, term()} - Error details
Link to this function

transform_margin_tables(tables)

View Source

Transform margin tables for storage.

Converts margin_tiers embedded list to JSONB-compatible format. This function is called automatically by the storage layer when using fetch/0.