coinglecko/rate_limit

Rate limit information parsing from CoinGecko response headers.

This module extracts rate limit metadata from HTTP response headers. It does NOT implement actual rate limiting or timers. Instead, it provides the information so users can implement their own throttling.

Types

Rate limit information extracted from response headers.

pub type RateLimitInfo {
  RateLimitInfo(
    limit: option.Option(Int),
    remaining: option.Option(Int),
    reset_at: option.Option(Int),
  )
}

Constructors

Values

pub fn is_rate_limited(status: Int) -> Bool

Check if a status code indicates rate limiting.

pub fn parse_rate_limit_headers(
  headers: List(#(String, String)),
) -> RateLimitInfo

Parse rate limit information from HTTP response headers. CoinGecko uses standard rate limit headers:

  • x-ratelimit-limit
  • x-ratelimit-remaining
  • x-ratelimit-reset (Unix timestamp)
pub fn retry_after(
  headers: List(#(String, String)),
) -> option.Option(Int)

Extract the Retry-After header value in seconds.

Search Document