API Reference

Types Reference

This page covers all key TypeScript types, interfaces, and enums exported by Rezo.


HttpMethod

Standard HTTP methods supported by Rezo.

type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';

ResponseType

Controls how the response body is parsed and returned in response.data.

type ResponseType = 'json' | 'text' | 'blob' | 'arrayBuffer' | 'buffer' | 'auto';
TypeDescription
'json'Parse response as JSON. Returns parsed object/array.
'text'Return response as string. No parsing.
'blob'Return as Blob (browser environments).
'arrayBuffer'Return as ArrayBuffer.
'buffer'Return as Node.js Buffer.
'auto'Auto-detect based on Content-Type header (default). JSON for application/json, text for text/*, buffer otherwise.

CacheOption

Configuration for response and DNS caching.

type CacheOption = boolean | CacheConfig;

interface CacheConfig {
  response?: boolean | ResponseCacheConfig;
  dns?: boolean | DNSCacheOptions;
}
ValueBehavior
trueEnable both response and DNS cache with defaults.
{ response: true, dns: true }Same as true.
{ response: { enable: true, ttl: 60000 } }Fine-grained response cache config.
{ dns: { enable: true, ttl: 30000 } }DNS-only caching.

RezoDefaultOptions

Instance-level defaults applied to every request. Passed to new Rezo(config).

interface RezoDefaultOptions {
  baseURL?: string;
  hooks?: Partial<RezoHooks>;
  disableJar?: boolean;
  jar?: RezoCookieJar;
  cookies?: Cookies;
  cookieFile?: string;
  queue?: RezoQueue | HttpQueue | QueueConfig | HttpQueueConfig;
  queueOptions?: { enable: boolean; options?: QueueConfig }; // Legacy enable/options wrapper — `queue` is preferred
  headers?: RezoHeadersInit;
  responseType?: ResponseType;
  responseEncoding?: string;
  auth?: { username: string; password: string };
  timeout?: number;
  rejectUnauthorized?: boolean;
  retry?: RetryConfig;
  followRedirects?: boolean;
  maxRedirects?: number;
  decompress?: boolean;
  keepAlive?: boolean;
  enableRedirectCycleDetection?: boolean;
  withCredentials?: boolean;
  proxy?: ProxyOptions | string;
  maxBodyLength?: number;
  maxRate?: number | [number, number];
  beforeRedirect?: RedirectCallback;
  onRedirect?: RedirectCallback;
  transformRequest?: TransformFunction[];
  transformResponse?: TransformFunction[];
  browser?: BrowserConfig;
  debug?: boolean;
  verbose?: boolean;
  trackUrl?: boolean;
  httpAgent?: HttpAgent;
  httpsAgent?: HttpsAgent;
  encoding?: BufferEncoding;
  cache?: CacheOption;
  proxyManager?: ProxyManager | ProxyManagerConfig;
  stealth?: RezoStealth;
}

RezoRequestConfig

Per-request configuration. The full shape is large (≈80 fields) — every option you can pass to rezo.request(config) lives here. The summary below groups them by category. See the Request Configuration page for the per-field reference.

interface RezoRequestConfig<D = any> {
  // Core
  url: string | URL;
  fullUrl: string;
  method: HttpMethod;
  headers?: Headers | RezoHeaders | OutgoingHttpHeaders | Record<string, string> | [string, string][];
  params?: Record<string | number, any>;
  paramsSerializer?: (params: Record<string, any>) => string;
  baseURL?: string;

  // Body (one of)
  body?: D;
  json?: Record<string, any>;
  form?: Record<string, any>;
  formData?: Record<string, any> | RezoFormData;
  multipart?: Record<string, any> | RezoFormData;
  contentType?: ContentType | string;
  withoutContentType?: boolean;

  // Auth
  auth?: { username: string; password: string };

  // Response
  responseType?: ResponseType;
  responseEncoding?: string;
  validateStatus?: ((status: number) => boolean) | null;
  decompress?: boolean;
  encoding?: BufferEncoding;
  transformResponse?: Array<(data: any) => any>;

  // Time / abort
  timeout?: number;
  signal?: AbortSignal;

  // Redirects
  followRedirects?: boolean;
  maxRedirects?: number;
  enableRedirectCycleDetection?: boolean;
  beforeRedirect?: (opts: OnRedirectOptions) => OnRedirectResponse;
  onRedirect?:     (opts: OnRedirectOptions) => OnRedirectResponse;

  // Retry / wait-on-status
  retry?: boolean | number | RetryConfig;
  waitOnStatus?: boolean | number[];
  waitTimeSource?: 'retry-after' | { header: string } | { body: string }
                 | ((response: { status: number; headers: RezoHeaders; data?: any }) => number | null);
  maxWaitTime?: number;
  defaultWaitTime?: number;
  maxWaitAttempts?: number;

  // Connection
  keepAlive?: boolean;
  keepAliveMsecs?: number;
  httpAgent?: HttpAgent;
  httpsAgent?: HttpsAgent;
  rejectUnauthorized?: boolean;
  useSecureContext?: boolean;
  secureContext?: SecureContext;

  // Cookies
  jar?: RezoCookieJar;
  cookies?: Cookie[] | string | string[] | SerializedCookie[];
  useCookies?: boolean;
  withCredentials?: boolean;

  // Proxy
  proxy?: string | ProxyOptions;
  useProxyManager?: boolean;

  // Caching
  cache?: boolean | { cacheDir?: string; ttl?: number; maxEntries?: number; methods?: string[]; respectHeaders?: boolean };
  dnsCache?: boolean | { ttl?: number; maxEntries?: number };

  // Streaming / files
  saveTo?: string;
  fileName?: string;
  onUploadProgress?: (event: any) => void;
  onDownloadProgress?: (event: any) => void;

  // Limits
  maxBodyLength?: number;
  maxRate?: number | [number, number];

  // Hooks / queue
  hooks?: Partial<RezoHooks>;
  queue?: RezoQueue | null;

  // Debug
  debug?: boolean;
  verbose?: boolean;
  trackUrl?: boolean;

  // Misc / advanced
  xsrfCookieName?: string;
  xsrfHeaderName?: string;
  withoutBodyOnRedirect?: boolean;
  autoSetReferer?: boolean;
  autoSetOrigin?: boolean;
  treat302As303?: boolean;
  startNewRequest?: boolean;
  transformRequest?: Array<(data: any, headers: RezoHeaders) => any>;
  dnsLookup?: (hostname: string, options: any, cb: (err: Error | null, address: string, family: number) => void) => void;
  transitional?: { silentJSONParsing?: boolean; forcedJSONParsing?: boolean; clarifyTimeoutError?: boolean };
}

RezoHttpRequest

The primary request options type used for per-request configuration. Includes all options that can be passed to HTTP methods.

interface RezoHttpRequest {
  // URL and Method
  url?: string | URL;
  method?: HttpMethod;
  baseURL?: string;

  // Body
  body?: string | Buffer | FormData | RezoFormData | Record<string, any>;
  formData?: RezoFormData;

  // Headers and Auth
  headers?: RezoHeadersInit;
  auth?: { username: string; password: string };

  // Response
  responseType?: ResponseType;
  responseEncoding?: string;

  // Timeouts
  timeout?: number;

  // Query Parameters
  params?: Record<string, any>;
  paramsSerializer?: (params: any) => string;

  // Redirects
  followRedirects?: boolean;
  maxRedirects?: number;
  beforeRedirect?: RedirectCallback;
  onRedirect?: RedirectCallback;

  // Proxy
  proxy?: ProxyOptions | string;

  // TLS
  rejectUnauthorized?: boolean;
  secureContext?: SecureContext;

  // Retry
  retry?: RetryConfig;

  // Transforms
  transformRequest?: TransformFunction[];
  transformResponse?: TransformFunction[];

  // Cookies
  jar?: RezoCookieJar;
  cookies?: string | string[] | Cookie[] | SerializedCookie[];

  // Queue
  queue?: RezoQueue;

  // Hooks
  hooks?: Partial<RezoHooks>;

  // Debugging
  debug?: boolean;
  verbose?: boolean;
  trackUrl?: boolean;

  // Limits
  maxBodyLength?: number;
  maxRate?: number | [number, number];

  // HTTP/2
  http2?: boolean;

  // Agents
  httpAgent?: HttpAgent;
  httpsAgent?: HttpsAgent;

  // Stealth (resolved internally)
  stealth?: RezoStealth;

  // Other
  decompress?: boolean;
  keepAlive?: boolean;
  withCredentials?: boolean;
  encoding?: BufferEncoding;
  saveTo?: string;
}

RezoConfig

The post-execution configuration object — what you get on response.config, error.config, and inside hooks. It’s a superset of the request config plus everything Rezo and the adapter learned while running the request: timing breakdown, the redirect chain, transfer sizes, the resolved adapter, the cookie jar, etc.

interface RezoConfig {
  // Core (echo of the request)
  url: string;
  method: HttpMethod;
  headers: RezoHeaders;
  data?: any;
  params?: Record<string | number, any>;
  baseURL?: string;
  timeout?: number | null;
  responseType?: ResponseType | 'stream' | 'download' | 'upload' | 'binary';
  auth?: { username: string; password: string } | null;
  proxy?: ProxyOptions | string | null;
  maxRedirects: number;
  http2: boolean;
  curl: boolean;
  rejectUnauthorized?: boolean;

  // Adapter / behavior
  retry?: NormalizedRetryConfig | null;
  compression?: { enabled?: boolean; threshold?: number; algorithms?: string[] };
  features?: Record<string, boolean>;
  insecureHTTPParser: boolean;
  isSecure?: boolean;
  maxRate: number | [number, number];

  // Cancellation
  cancelToken?: any | null;
  signal?: AbortSignal | null;
  setSignal: () => void;

  // Connection
  httpAgent?: HttpAgent | null;
  httpsAgent?: HttpsAgent | null;
  socketPath?: string | null;

  // Cookies / persistence
  disableJar?: boolean;
  withCredentials?: boolean;
  jar: RezoCookieJar;
  requestCookies: Cookie[];
  responseCookies: Cookies;
  cookieFile?: string | null;

  // Hooks
  hooks: Partial<RezoHooks> | null;

  // Execution tracking
  originalRequest: RezoRequestConfig;
  originalBody?: any;
  finalUrl: string;
  fileName?: string | null;
  adapterUsed: 'http' | 'https' | 'http2' | 'fetch' | 'xhr' | 'curl' | 'react-native';
  adapterMetadata?: { version?: string; features?: string[]; capabilities?: Record<string, any> };
  redirectHistory: Array<{
    url: string;
    statusCode: number;
    statusText: string;
    headers: RezoHeaders;
    cookies: Cookie[];
    duration: number;
    method: string;
    request: RezoRequestConfig;
  }>;
  redirectCount: number;
  maxRedirectsReached: boolean;

  // W3C-style timing ladder (matches PerformanceResourceTiming)
  timing: {
    startTime: number;
    domainLookupStart: number; domainLookupEnd: number;
    connectStart: number; secureConnectionStart: number; connectEnd: number;
    requestStart: number; responseStart: number; responseEnd: number;
  };

  // Network info populated by the adapter
  network: {
    localAddress?: string; localPort?: number;
    remoteAddress?: string; remotePort?: number;
    protocol: string;
    httpVersion?: string;
    family?: 4 | 6;
    lookup?: any;
  };

  // Bytes-on-wire stats
  transfer: {
    requestSize: number;
    requestHeaderSize?: number;
    requestBodySize?: number;
    responseSize: number;
    headerSize: number;
    bodySize: number;
    compressionRatio?: number;
  };
}

RezoResponse<T>

Standard HTTP response object returned by all non-streaming request methods.

interface RezoResponse<T = any> {
  data: T;
  status: number;
  statusText: string;
  finalUrl: string;
  cookies: Cookies;
  headers: RezoHeaders;
  contentType: string | undefined;
  contentLength: number;
  urls: string[];
  config: RezoConfig;
}
PropertyTypeDescription
dataTThe parsed response body. Type depends on responseType.
statusnumberHTTP status code (e.g., 200, 404).
statusTextstringHTTP status text (e.g., "OK", "Not Found").
finalUrlstringThe final URL after all redirects.
cookiesCookiesCookies from the response in multiple formats.
headersRezoHeadersResponse headers.
contentTypestring \| undefinedThe Content-Type header value.
contentLengthnumberThe Content-Length value.
urlsstring[]The redirect chain (all URLs visited).
configRezoConfigThe request configuration that produced this response.

RezoStreamResponse

Event-emitting interface for streaming responses. Returned by rezo.stream().

interface RezoStreamResponse {
  on(event: 'data', listener: (chunk: Uint8Array | string) => void): this;
  on(event: 'error', listener: (err: RezoError) => void): this;
  on(event: 'finish', listener: (info: StreamFinishEvent) => void): this;
  on(event: 'done', listener: (info: StreamFinishEvent) => void): this;
  on(event: 'start', listener: (info: RequestStartEvent) => void): this;
  on(event: 'initiated', listener: () => void): this;
  on(event: 'headers', listener: (info: ResponseHeadersEvent) => void): this;
  on(event: 'cookies', listener: (cookies: Cookie[]) => void): this;
  on(event: 'status', listener: (status: number, statusText: string) => void): this;
  on(event: 'redirect', listener: (info: RedirectEvent) => void): this;
  on(event: 'progress', listener: (progress: ProgressEvent) => void): this;
  isFinished(): boolean;
  setEncoding?(encoding: string): this;
  getEncoding?(): string | undefined;
}

RezoDownloadResponse

Event-emitting interface for file downloads. Returned by rezo.download().

interface RezoDownloadResponse {
  fileName: string;
  url: string;
  status?: number;
  statusText?: string;
  on(event: 'error', listener: (err: RezoError) => void): this;
  on(event: 'finish', listener: (info: DownloadFinishEvent) => void): this;
  on(event: 'done', listener: (info: DownloadFinishEvent) => void): this;
  on(event: 'start', listener: (info: RequestStartEvent) => void): this;
  on(event: 'headers', listener: (info: ResponseHeadersEvent) => void): this;
  on(event: 'cookies', listener: (cookies: Cookie[]) => void): this;
  on(event: 'status', listener: (status: number, statusText: string) => void): this;
  on(event: 'redirect', listener: (info: RedirectEvent) => void): this;
  on(event: 'progress', listener: (progress: ProgressEvent) => void): this;
  isFinished(): boolean;
}

RezoUploadResponse

Event-emitting interface for file uploads. Returned by rezo.upload().

interface RezoUploadResponse {
  url: string;
  fileName?: string;
  status?: number;
  statusText?: string;
  on(event: 'error', listener: (err: RezoError) => void): this;
  on(event: 'finish', listener: (info: UploadFinishEvent) => void): this;
  on(event: 'done', listener: (info: UploadFinishEvent) => void): this;
  on(event: 'start', listener: (info: RequestStartEvent) => void): this;
  on(event: 'headers', listener: (info: ResponseHeadersEvent) => void): this;
  on(event: 'cookies', listener: (cookies: Cookie[]) => void): this;
  on(event: 'status', listener: (status: number, statusText: string) => void): this;
  on(event: 'redirect', listener: (info: RedirectEvent) => void): this;
  on(event: 'progress', listener: (progress: ProgressEvent) => void): this;
  isFinished(): boolean;
}

RezoHooks

Lifecycle hooks. All 26 hooks are listed here; each is an array of handler functions called in order. See the Hooks reference for execution semantics (void / transform / boolean / early-return / event) and full handler signatures.

interface RezoHooks {
  // Core lifecycle
  init:           InitHook[];
  beforeRequest:  BeforeRequestHook[];
  beforeRedirect: BeforeRedirectHook[];
  beforeRetry:    BeforeRetryHook[];
  afterResponse:  AfterResponseHook[];
  beforeError:    BeforeErrorHook[];

  // Caching
  beforeCache:    BeforeCacheHook[];

  // Response processing
  afterHeaders:   AfterHeadersHook[];
  afterParse:     AfterParseHook[];

  // Cookie lifecycle
  beforeCookie:   BeforeCookieHook[];
  afterCookie:    AfterCookieHook[];

  // Proxy lifecycle (require a ProxyManager on the instance)
  beforeProxySelect:    BeforeProxySelectHook[];
  afterProxySelect:     AfterProxySelectHook[];
  beforeProxyError:     BeforeProxyErrorHook[];
  afterProxyError:      AfterProxyErrorHook[];
  beforeProxyDisable:   BeforeProxyDisableHook[];
  afterProxyDisable:    AfterProxyDisableHook[];
  afterProxyRotate:     AfterProxyRotateHook[];
  afterProxyEnable:     AfterProxyEnableHook[];
  onNoProxiesAvailable: OnNoProxiesAvailableHook[];

  // Low-level network events (fire-and-forget, errors swallowed)
  onSocket:  OnSocketHook[];
  onDns:     OnDnsHook[];
  onTls:     OnTlsHook[];
  onTimeout: OnTimeoutHook[];
  onAbort:   OnAbortHook[];

  // Rate-limit waiting
  onRateLimitWait: OnRateLimitWaitHook[];
}

Cookies

Multi-format cookie container returned by getCookies() and cookies().

interface Cookies {
  array: Cookie[];
  serialized: SerializedCookie[];
  netscape: string;
  string: string;
  setCookiesString: string[];
}

SerializedCookie

Plain object representation for JSON serialization.

interface SerializedCookie {
  key: string;
  value: string;
  domain?: string;
  path?: string;
  expires?: string | Date;
  maxAge?: number | string;
  secure?: boolean;
  httpOnly?: boolean;
  sameSite?: string;
  hostOnly?: boolean;
  creation?: string | Date;
  lastAccessed?: string | Date;
  extensions?: string[];
}

ProxyInfo

Proxy server connection details.

interface ProxyInfo {
  id?: string;
  protocol: 'socks4' | 'socks5' | 'http' | 'https';
  host: string;
  port: number;
  auth?: { username: string; password: string };
  label?: string;
  metadata?: Record<string, unknown>;
}

BrowserProfile

Browser fingerprint profile used by the stealth module.

interface BrowserProfile {
  // Identity
  id: string;
  family: 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera' | 'brave';
  engine: 'blink' | 'gecko' | 'webkit';
  version: string;
  majorVersion: number;
  device: 'desktop' | 'mobile';

  // Per-platform UA strings (one string each, not an array)
  userAgents: {
    windows: string;
    macos:   string;
    linux:   string;
    android?: string;     // mobile profiles only
    ios?:     string;     // iOS profiles only
  };

  // Default headers
  accept: string;
  acceptEncoding: string;
  acceptLanguage: string;

  // Wire fingerprint
  tls: TlsFingerprint;
  h2Settings: Http2Settings;

  // Header ordering — both regular and HTTP/2 pseudo-headers
  headerOrder: string[];
  pseudoHeaderOrder: string;   // shorthand string e.g. 'masp' (m=:method a=:authority s=:scheme p=:path)

  // Chromium-only client hints (null on Firefox / Safari)
  clientHints: ClientHints;

  // window.navigator emulation
  navigator: NavigatorProperties;
}

The fully-resolved profile (what RezoStealth.resolve() returns) is a separate type, ResolvedStealthProfile, which adds a defaultHeaders: Record<string, string> map and a normalized pseudoHeaderOrder: string[].


TlsFingerprint

TLS fingerprint configuration used by the stealth module. Cipher suites and signature algorithms are colon-separated strings (the format OpenSSL / BoringSSL accepts directly), not arrays.

interface TlsFingerprint {
  ciphers: string;          // e.g. 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:…'
  sigalgs: string;          // signature algorithms (colon-separated)
  ecdhCurve: string;        // supported groups (colon-separated)
  alpnProtocols: string[];  // ALPN list, e.g. ['h2', 'http/1.1']
  minVersion: 'TLSv1.2' | 'TLSv1.3';
  maxVersion: 'TLSv1.2' | 'TLSv1.3';
  sessionTimeout: number;   // seconds
}

Http2Settings

Values sent in the HTTP/2 SETTINGS frame. connectionWindowSize is sent as the connection-level WINDOW_UPDATE immediately after SETTINGS.

interface Http2Settings {
  headerTableSize: number;
  enablePush: boolean;
  maxConcurrentStreams: number;
  initialWindowSize: number;
  maxFrameSize: number;
  maxHeaderListSize: number;
  connectionWindowSize: number;
}

ErrorDetails

Error metadata from the ERROR_INFO database.

interface ErrorDetails {
  message: string;
  details: string;
  suggestion: string;
  errno: number;
}

RezoErrorCode

Enum of all known error codes. See the RezoError API reference for the full list.

enum RezoErrorCode {
  CONNECTION_REFUSED = 'ECONNREFUSED',
  CONNECTION_RESET = 'ECONNRESET',
  CONNECTION_TIMEOUT = 'ETIMEDOUT',
  DNS_LOOKUP_FAILED = 'ENOTFOUND',
  HTTP_ERROR = 'REZ_HTTP_ERROR',
  RATE_LIMITED = 'REZ_RATE_LIMITED',
  DOWNLOAD_FAILED = 'REZ_DOWNLOAD_FAILED',
  UPLOAD_FAILED = 'REZ_UPLOAD_FAILED',
  STREAM_ERROR = 'REZ_STREAM_ERROR',
  INVALID_JSON = 'REZ_INVALID_JSON',
  PROXY_CONNECTION_FAILED = 'REZ_PROXY_CONNECTION_FAILED',
  SOCKS_CONNECTION_FAILED = 'REZ_SOCKS_CONNECTION_FAILED',
  CERTIFICATE_EXPIRED = 'CERT_HAS_EXPIRED',
  NO_PROXY_AVAILABLE = 'REZ_NO_PROXY_AVAILABLE',
  // ... and more
}

RezoErrorCodeString

Union type of all known error code strings, plus an escape hatch for unknown OS/runtime codes.

type RezoErrorCodeString = `${RezoErrorCode}` | (string & {});

This provides full IDE autocomplete while still accepting unknown error codes at runtime.