View Source Hyperliquid.Api.Registry (hyperliquid v0.2.2)

Registry for discovering and introspecting API endpoints.

This module provides functions to list all available endpoints and get their documentation, rate limits, and other metadata.

Usage

# List all endpoints
Hyperliquid.Api.Registry.list_endpoints()

# Get info for a specific endpoint
Hyperliquid.Api.Registry.get_endpoint_info("allMids")

# List endpoints by type
Hyperliquid.Api.Registry.list_by_type(:info)

# Get total rate limit cost for multiple endpoints
Hyperliquid.Api.Registry.total_rate_limit_cost(["allMids", "l2Book"])

Summary

Functions

Get endpoint documentation as formatted string.

Get endpoint info by endpoint name.

Get endpoint module by snake_case name without context.

List endpoints by type.

List all endpoints for a specific context.

List all registered endpoints with their metadata.

Print formatted documentation for an endpoint.

Returns a summary of rate limits for all endpoints.

Resolve an endpoint module from context and endpoint name.

Calculate total rate limit cost for a list of endpoints.

Functions

Get endpoint documentation as formatted string.

Parameters

  • name - The endpoint name

Returns

Formatted documentation string or error.

Get endpoint info by endpoint name.

Parameters

  • name - The endpoint name (e.g., "allMids", "l2Book")

Returns

  • {:ok, info} - Endpoint info map
  • {:error, :not_found} - Endpoint not found
Link to this function

get_endpoint_module(endpoint_name)

View Source

Get endpoint module by snake_case name without context.

Searches all contexts for the endpoint.

Parameters

  • endpoint_name - Atom in snake_case

Returns

  • {:ok, module} - The endpoint module
  • {:error, :not_found} - Endpoint not found
  • {:error, {:ambiguous, modules}} - Multiple endpoints with same name

List endpoints by type.

Parameters

  • type - :info, :exchange, or :subscription

Returns

List of endpoint info maps of the specified type.

Link to this function

list_context_endpoints(context)

View Source

List all endpoints for a specific context.

Parameters

  • context - Atom: :info, :exchange, :explorer, or :stats

Returns

List of endpoint modules for the context.

List all registered endpoints with their metadata.

Returns

List of endpoint info maps.

Example

iex> Hyperliquid.Api.Registry.list_endpoints()
[
  %{endpoint: "allMids", type: :info, rate_limit_cost: 2, ...},
  %{endpoint: "l2Book", type: :info, rate_limit_cost: 2, ...}
]

Returns a summary of rate limits for all endpoints.

Groups endpoints by their rate limit cost.

Link to this function

resolve_endpoint(context, endpoint_name)

View Source

Resolve an endpoint module from context and endpoint name.

Converts the endpoint name from snake_case to the corresponding module name.

Parameters

  • context - Atom: :info, :exchange, :explorer, or :stats
  • endpoint_name - Atom in snake_case (e.g., :all_mids, :l2_book)

Returns

  • {:ok, module} - The endpoint module
  • {:error, :not_found} - Endpoint not found

Examples

iex> Hyperliquid.Api.Registry.resolve_endpoint(:info, :all_mids)
{:ok, Hyperliquid.Api.Info.AllMids}

iex> Hyperliquid.Api.Registry.resolve_endpoint(:info, :l2_book)
{:ok, Hyperliquid.Api.Info.L2Book}

iex> Hyperliquid.Api.Registry.resolve_endpoint(:info, :nonexistent)
{:error, :not_found}
Link to this function

total_rate_limit_cost(names)

View Source

Calculate total rate limit cost for a list of endpoints.

Parameters

  • names - List of endpoint names

Returns

Total rate limit cost as integer.

Example

iex> Hyperliquid.Api.Registry.total_rate_limit_cost(["allMids", "l2Book"])
4