Interface NessyClientConfig

Constructor options for NessyClient.

interface NessyClientConfig {
    apiKey: string;
    baseUrl?: string;
    timeoutMs?: number;
    retries?: number | RetryConfig;
    userAgent?: string;
    fetch?: (
        input: string | URL | Request,
        init?: RequestInit,
    ) => Promise<Response>;
    logger?: Logger;
    allowBrowser?: boolean;
    defaultHeaders?: Record<string, string>;
}

Properties

apiKey: string

API key. Must match nsy_(live|test)_.... Test keys are validated separately and are free; live keys require email verification and are billed.

The key is stored in a Symbol-keyed private property — JSON.stringify(client) and util.inspect(client) both redact it to [REDACTED].

baseUrl?: string

Override the API base URL. Must be HTTPS (except localhost / 127.0.0.1 / [::1] for local dev). Defaults to the production URL.

timeoutMs?: number

Per-attempt timeout in milliseconds. Default 30_000.

retries?: number | RetryConfig

Retry policy. Pass a number for shorthand (retries: 5) or a full RetryConfig object. Default 3 retries, exponential backoff with decorrelated jitter, capped at 60s.

userAgent?: string

Suffix to append to the SDK's built-in User-Agent string. Example: "my-app/1.2.0".

fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>

Custom fetch implementation — useful for connection pooling via undici.Agent, corporate proxies, or test mocks. Defaults to global fetch (Node 18.17+).

logger?: Logger

Structured logger. Any object with debug/info/warn/error methods works (pino, winston, bunyan, console). Default: no-op (silent). The SDK never logs request bodies or the Authorization header.

allowBrowser?: boolean

Escape hatch for running in a browser environment. Normally the SDK refuses to instantiate if window is defined, because API keys would leak to end users. Only set true for trusted internal tools where the browser is behind authentication and the user is the key owner.

defaultHeaders?: Record<string, string>

Extra headers applied to every request (lowest precedence — per-call RequestOptions.headers override these).