glassnode-api - v0.29.3
    Preparing search index...

    Type Alias GlassnodeConfig

    GlassnodeConfig: {
        apiKey?: string;
        apiKeyLocation?: "header" | "query";
        apiUrl?: string;
        fetch?: GlassnodeFetch;
        hooks?: {
            onError?: (event: GlassnodeErrorEvent) => void;
            onRequest?: (event: GlassnodeHookEventBase) => void;
            onResponse?: (event: GlassnodeResponseEvent) => void;
            onRetry?: (event: GlassnodeRetryEvent) => void;
        };
        logger?: Logger;
        maxRetries?: number;
        maxRetryDelay?: number;
        retryDelay?: number;
        timeout?: number;
        x402?: boolean;
    }

    Configuration for the Glassnode API client

    Type Declaration

    • OptionalapiKey?: string

      API key for authentication. Required unless x402 is enabled.

    • OptionalapiKeyLocation?: "header" | "query"

      Where the API key is sent: 'query' (default) as the api_key query parameter, or 'header' as the X-Api-Key request header, which keeps the key out of URLs (and so out of access logs, proxies, tracing and transport errors). 'header' is for server-side use: the Glassnode API's CORS preflight does not allow X-Api-Key, so browsers block it.

      With 'header', redirects are not followed (the request is sent with redirect: 'manual'): fetch would otherwise resend X-Api-Key to whatever origin a 3xx names. A 3xx surfaces as a non-retried GlassnodeApiError with that status; point apiUrl at the final URL. 'query' keeps fetch's default redirect handling (the URL, key included, goes wherever the server's Location says, which only the server that already received the key controls).

    • OptionalapiUrl?: string

      Base URL for the Glassnode API. Default https://api.glassnode.com, or https://x402.glassnode.com when x402 is set. An explicit value always wins over the x402 preset.

    • Optionalfetch?: GlassnodeFetch

      Optional custom fetch function (e.g. an x402-wrapped fetch, or for testing). Called with a string URL as fetch(url) or fetch(url, init); see GlassnodeFetch.

    • Optionalhooks?: {
          onError?: (event: GlassnodeErrorEvent) => void;
          onRequest?: (event: GlassnodeHookEventBase) => void;
          onResponse?: (event: GlassnodeResponseEvent) => void;
          onRetry?: (event: GlassnodeRetryEvent) => void;
      }

      Optional structured observability hooks (onRequest, onResponse, onRetry, onError), called synchronously and never awaited; a failing hook never affects the call. See GlassnodeHooks.

    • Optionallogger?: Logger

      Optional logger for API call debugging; its own failures (throw/rejection) are ignored.

    • OptionalmaxRetries?: number

      Maximum number of retries for retryable failures: a 429/5xx response, or a transport failure (GlassnodeNetworkError, including a per-attempt timeout). Default 0 (no retries).

    • OptionalmaxRetryDelay?: number

      Upper bound (ms) for a single retry wait, after exponential growth.

    • OptionalretryDelay?: number

      Base delay in milliseconds between retries (doubles each attempt, then full jitter).

    • Optionaltimeout?: number

      Per-request timeout in milliseconds. When set, each attempt is aborted via AbortSignal.timeout() after this many ms (a fresh signal per retry). Unset = no timeout.

    • Optionalx402?: boolean

      Route requests through the x402 paid endpoint (https://x402.glassnode.com).