Global client configuration.
Returns deduplication metrics.
An object with hits (coalesced request count), misses (actual network request count),
and inFlightCount (currently in-flight requests), or null if dedup is not enabled.
Number of requests that shared an in-flight or windowed response.
Number of requests that triggered a real network call.
Number of currently in-flight requests.
Get circuit breaker state snapshots for all tracked origins.
Register a request interceptor.
The interceptor function.
Eject function — call to remove this interceptor.
Attach a HookRegistry (from lifecycle.ts) to this client.
The registry's beforeRequest hooks run as request interceptors and
its onError hooks run as error interceptors, so the full priority /
once / conditional system from lifecycle.ts is available alongside
kinetex's native interceptor API.
The HookRegistry instance to attach.
A single eject function that removes all three bridge interceptors.
import { HookRegistry, createLoggingHooks } from "kinetex/lifecycle";
const registry = new HookRegistry();
const { beforeRequest, afterResponse, onError } = createLoggingHooks();
registry.addBeforeRequest(beforeRequest);
registry.addAfterResponse(afterResponse);
registry.addOnError(onError);
const client = kinetex({ baseURL: "https://api.example.com" });
client.attachHookRegistry(registry);
Register a response interceptor.
The interceptor function.
Eject function.
Register an error interceptor.
The interceptor function.
Eject function.
Clear all HAR entries.
Access the underlying cache instance. Returns null if no cache is configured. Protected by initialization lock to prevent concurrent creation.
The cache instance, or null if not configured.
Access the cookie jar instance. Returns null if no cookie jar is configured. Protected by initialization lock to prevent concurrent creation.
The cookie jar, or null if not configured.
Create a child client that inherits this instance's config, overriding with the provided options.
Partial config to override.
A new Kinetex child instance.
Set an OpenTelemetry-compatible tracer.
When set, kinetex automatically injects traceparent and tracestate
headers (W3C Trace Context) into every outgoing request, and creates
a child span for each request with standard HTTP semantic attributes.
This instance for chaining.
Enable in-flight request deduplication.
When multiple concurrent requests target the same URL with the same method, they are coalesced into a single network call. All callers receive the same response object once the request completes.
Only applies to safe methods (GET and HEAD by default).
Optionaloptions: DedupOptionsThis instance for chaining.
const client = kinetex({ baseURL: "https://api.example.com" });
client.enableDedup({ windowMs: 50 }); // also dedupe for 50ms after completion
// These three calls make exactly ONE network request:
const [a, b, c] = await Promise.all([
client.get("/users"),
client.get("/users"),
client.get("/users"),
]);
Disable in-flight request deduplication.
This instance for chaining.
Enable circuit breaker protection.
The circuit breaker tracks failures per origin. When failures exceed the
threshold, the circuit opens and requests are rejected immediately with
a CircuitOpenError — preventing cascading failures to struggling services.
Optionalconfig: CircuitBreakerConfigThis instance for chaining.
Disable circuit breaker protection.
This instance for chaining.
Manually trip the circuit breaker for a given origin. Useful during maintenance windows.
This instance for chaining.
Manually reset the circuit breaker for a given origin.
This instance for chaining.
Open a WebSocket connection that inherits this client's headers and auth.
WebSocket endpoint URL (ws:// or wss://).
WebSocket client configuration overrides.
A connected WSClient instance.
Execute an HTTP request.
This is the lowest-level public method. All convenience helpers
(get, post, etc.) delegate to this.
Expected parsed response body type.
Request URL (relative to baseURL or absolute).
HTTP method.
Per-request options.
A promise resolving to the parsed response.
Execute a GET request.
Optionaloptions: SendOptions<T>Execute a POST request.
Optionalbody: BodyInitOptionaloptions: SendOptions<T>Execute a PUT request.
Optionalbody: BodyInitOptionaloptions: SendOptions<T>Execute a PATCH request.
Optionalbody: BodyInitOptionaloptions: SendOptions<T>Execute a DELETE request.
Optionaloptions: SendOptions<T>Execute a HEAD request.
Optionaloptions: SendOptions<null>Execute an OPTIONS request.
Optionaloptions: SendOptions<T>Open a Server-Sent Events stream.
SSE endpoint URL.
SSE client configuration overrides.
An SSEClient instance connected via the full kinetex pipeline.
Create a GraphQL client bound to this kinetex instance.
GraphQL endpoint URL.
GraphQL client config overrides.
A GraphQLClient instance routed through the full kinetex pipeline.
Clean up all resources held by this client instance. Call this when the client is no longer needed to prevent memory leaks.
A promise that resolves when cleanup is complete.
The main HTTP client class.
Example