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'; | Type | Description |
|---|---|
'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;
} | Value | Behavior |
|---|---|
true | Enable 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 }; // Deprecated
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 that extends the base options with request-specific fields.
interface RezoRequestConfig {
url?: string | URL;
method?: HttpMethod;
fullUrl?: string;
} 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
Internal configuration type that combines request config with URL information. Used in error objects and adapters.
interface RezoConfig {
url?: string;
method?: string;
} 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;
} | Property | Type | Description |
|---|---|---|
data | T | The parsed response body. Type depends on responseType. |
status | number | HTTP status code (e.g., 200, 404). |
statusText | string | HTTP status text (e.g., "OK", "Not Found"). |
finalUrl | string | The final URL after all redirects. |
cookies | Cookies | Cookies from the response in multiple formats. |
headers | RezoHeaders | Response headers. |
contentType | string \| undefined | The Content-Type header value. |
contentLength | number | The Content-Length value. |
urls | string[] | The redirect chain (all URLs visited). |
config | RezoConfig | The 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 for intercepting and transforming requests and responses.
interface RezoHooks {
init: ((options: Partial<RezoRequestConfig>, processedOptions: RezoRequestConfig) => void)[];
beforeRequest: ((config: RezoRequestConfig, context: BeforeRequestContext) => void | RezoResponse)[];
afterResponse: ((response: RezoResponse, config: RezoRequestConfig, context: AfterResponseContext) => RezoResponse | void)[];
beforeError: ((error: RezoError) => RezoError | void)[];
beforeCache: ((event: CacheEvent) => boolean | void)[];
} | Hook | Description |
|---|---|
init | Runs synchronously after config merging, before any processing. |
beforeRequest | Runs before the adapter executes. Return a response to short-circuit. |
afterResponse | Runs after a successful response. Can transform the response. |
beforeError | Runs when an error occurs. Can transform or replace the error. |
beforeCache | Runs before caching a response. Return false to skip caching. |
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 {
id: string;
family: 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera' | 'brave';
version: string;
device: 'desktop' | 'mobile';
userAgents: Record<string, string[]>;
headerOrder: string[];
pseudoHeaderOrder: string[];
tls: TlsFingerprint;
h2Settings: Http2Settings;
navigator: {
platform: Record<string, string>;
maxTouchPoints: Record<string, number>;
};
defaultHeaders: Record<string, string>;
} TlsFingerprint
TLS fingerprint configuration used by the stealth module.
interface TlsFingerprint {
ciphers: string[];
extensions: number[];
supportedGroups: string[];
signatureAlgorithms: string[];
alpnProtocols: string[];
minVersion?: string;
maxVersion?: string;
} Http2Settings
HTTP/2 SETTINGS frame values used by the stealth module.
interface Http2Settings {
headerTableSize: number;
enablePush: boolean;
maxConcurrentStreams: number;
initialWindowSize: number;
maxFrameSize: number;
maxHeaderListSize: 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.