Skip to main content

Exports

wreq-js exports the following functions and classes:
import {
  // Core functions
  fetch,
  request,
  get,
  post,
  createTransport,
  createSession,
  withSession,
  websocket,
  
  // Utilities
  getProfiles,
  getOperatingSystems,
  
  // Classes
  Headers,
  Response,
  Transport,
  Session,
  WebSocket,
  
  // Errors
  RequestError,
} from 'wreq-js';

Quick reference

FunctionDescription
fetch()Make HTTP requests with browser profile options
get() / post()Convenience wrappers around fetch()
request()Deprecated helper kept for compatibility
createTransport()Create a reusable transport context
createSession()Create a persistent session with cookie storage
withSession()Auto-disposing session helper
websocket()Connect to WebSocket servers
getProfiles()List available browser profiles
getOperatingSystems()List available operating systems

TypeScript support

wreq-js includes TypeScript definitions for its public API:
import type {
  BrowserProfile,
  EmulationOS,
  RequestInit,
  CreateTransportOptions,
  CreateSessionOptions,
  Transport,
  Session,
} from 'wreq-js';

Fetch style surface

wreq-js provides a fetch like API surface with additional transport and profile options:
Surfacewreq-js
fetch(url, init)Available
fetch(Request, init)Available
Request class exportNot currently exposed
Response classAvailable from the package
Headers classAvailable from the package
AbortControllerStandard signal inputs are accepted
ReadableStream bodyAvailable on response bodies
Session, Transport, and WebSocket are exported classes, but you should create them via createSession(), createTransport(), and websocket() or new WebSocket(url, ...). Detailed compatibility notes live at /concepts/compatibility-matrix.

wreq-js extensions

Additional options beyond the standard Fetch API:
interface RequestInit {
  // Standard options
  method?: string;
  headers?: HeadersInit;
  body?: BodyInit | null;
  signal?: AbortSignal | null;
  redirect?: 'follow' | 'manual' | 'error';

  // wreq-js extensions
  transport?: Transport;         // Reusable transport (pool/proxy/browser/os)
  browser?: BrowserProfile;      // Browser fingerprint profile
  os?: EmulationOS;              // Operating system emulation
  proxy?: string;                // Proxy URL
  timeout?: number;              // Request timeout in ms
  session?: Session;             // Bind to an existing session
  sessionId?: string;            // Bind to a session by ID
  cookieMode?: 'session' | 'ephemeral'; // Cookie scoping strategy
  disableDefaultHeaders?: boolean; // Disable auto-added headers
  insecure?: boolean;            // Accept invalid certificates
}