Skip to content

API Reference

Entry points

super-http has two factory APIs. Both return an HttpClient and share the same singleton cache per baseURL.

APIImportWhen to use
createClientimport { createClient }Recommended — single object, preset support
HttpClientFactoryimport { HttpClientFactory }Explicit three-arg signature, advanced use
typescript
// createClient — recommended
import { createClient } from 'super-http'
const api = createClient({ baseURL: 'https://api.example.com', preset: 'resilient-api' })

// HttpClientFactory — explicit
import { HttpClientFactory } from 'super-http'
const api = HttpClientFactory.create('https://api.example.com', httpConfig, poolConfig)

Same cache

createClient is built on HttpClientFactory. Both share the same singleton cache — same baseURL always returns the same HttpClient. HttpClientFactory.clear() resets both.


All exports

typescript
import {
  // ─── Entry points ──────────────────────────────────────────────────────────
  createClient,           // recommended factory with preset support
  HttpClientFactory,      // low-level singleton factory
  HttpClient,             // the HTTP client class

  // ─── Resilience ────────────────────────────────────────────────────────────
  CircuitBreaker,
  Bulkhead,
  RateLimiter,
  RequestDedup,

  // ─── Retry strategies ──────────────────────────────────────────────────────
  FixedRetryStrategy,
  ExponentialRetryStrategy,
  ExponentialJitterRetryStrategy,   // ← recommended
  RetryAfterStrategy,

  // ─── Plugins ───────────────────────────────────────────────────────────────
  LoggerPlugin,
  MetricsReporterPlugin,

  // ─── Types ─────────────────────────────────────────────────────────────────
  type Preset,
  type CreateClientOptions,
  type PoolConfig,
  type RequestPolicy,
  type CircuitBreakerConfig,
  type BulkheadConfig,
  type RateLimitConfig,
  type RetryStrategy,
  type SuperHttpPlugin,
  type ResilienceEvents,
  type MetricsSnapshot,
  type CircuitState,
  type HttpClientRequestConfig,
  type HttpClientResponse,
} from 'super-http'

ExportDescription
createClientRecommended factory — preset support, single options object
HttpClientFactoryLow-level factory — explicit three-arg signature, shared cache
HttpClientAll methods, fluent config, metrics, plugins
CircuitBreakerThree-state circuit breaker
BulkheadConcurrency limiter
RateLimiterToken-bucket rate limiter
Retry StrategiesFixed · Exponential · Jitter · RetryAfter
RequestDedupRequest deduplication
ResilienceEventsAll observability hook interfaces
MetricsSnapshotBuilt-in metrics interface
PoolConfigConnection pool options

Released under the MIT License.