currency_api.session

Documentation for eth_defi.currency_api.session Python module.

HTTP session factory for the fawazahmed0 Exchange API.

The endpoints are static JSON files served from a CDN (jsDelivr) with a Cloudflare Pages fallback, and the provider documents no rate limit. We therefore only need retry/backoff on the transport, not the SQLite rate-limiter used by the GRVT/Hyperliquid sessions.

Canonical API documentation: https://github.com/fawazahmed0/exchange-api

Module Attributes

DEFAULT_RETRIES

Default number of transport-level retries.

DEFAULT_BACKOFF_FACTOR

Default exponential backoff factor between retries.

DEFAULT_POOL_MAXSIZE

Default connection pool size.

Functions

create_currency_api_session([retries, ...])

Create a requests.Session configured for the Exchange API.

DEFAULT_RETRIES = 5

Default number of transport-level retries.

DEFAULT_BACKOFF_FACTOR = 0.5

Default exponential backoff factor between retries.

DEFAULT_POOL_MAXSIZE = 16

Default connection pool size.

create_currency_api_session(retries=5, backoff_factor=0.5, pool_maxsize=16)

Create a requests.Session configured for the Exchange API.

Installs an LoggingRetry policy with exponential backoff that retries on 429 and 5xx responses, and a connection pool sized for the threaded scanner. Host fallback (jsDelivr → pages.dev) is handled by the client, not here.

Parameters
  • retries (int) – Maximum number of transport-level retries per request.

  • backoff_factor (float) – Exponential backoff factor passed to the retry policy.

  • pool_maxsize (int) – Connection pool size; should be >= the scanner max_workers.

Returns

A configured session. Safe to share across threads.

Return type

requests.sessions.Session