make_gmx_api_request

Documentation for eth_defi.gmx.retry.make_gmx_api_request function.

make_gmx_api_request(chain, endpoint, params=None, timeout=10.0, retry_config=None, max_retries=None, retry_delay=None)

Make a GMX API request with full-cycle retry.

This is the SINGLE centralised function for all GMX API calls. It handles:

  • Retry with exponential backoff per endpoint

  • Automatic failover from primary to backup to fallback APIs

  • Full-cycle retry: primary → backup → fallback → fallback-2 → wait → repeat

Retry flow:

  1. Try primary API (max_retries attempts with exponential backoff)

  2. Try backup API (max_retries attempts with exponential backoff)

  3. Try fallback API (max_retries attempts with exponential backoff)

  4. Try fallback-2 API (max_retries attempts with exponential backoff)

  5. Wait initial_delay, then repeat full cycle

  6. After full_cycle_retries full cycles, raise RuntimeError

Parameters
  • chain (str) – Chain name (e.g., “arbitrum”, “avalanche”)

  • endpoint (str) – API endpoint path (e.g., “/tokens”, “/signed_prices/latest”)

  • params (dict[str, Any] | None) – Optional query parameters

  • timeout (float) – HTTP request timeout in seconds

  • retry_config (eth_defi.gmx.retry.GMXRetryConfig | None) – Retry behaviour configuration. Uses DEFAULT_RETRY_CONFIG when None.

  • max_retries (int | None) – Deprecated. Kept for backwards compatibility but ignored.

  • retry_delay (float | None) – Deprecated. Kept for backwards compatibility but ignored.

Returns

Parsed JSON response

Raises

RuntimeError – If all retries and backup attempts fail

Return type

dict[str, Any]