Skip to content
TypeWire

@tahanabavi/typefetch

documents v1.10.0

The typed HTTP client every other package is built around.

TypeFetch is a strongly typed HTTP client for TypeScript projects, built around Zod contracts.

Define your API once with Zod schemas, then TypeFetch generates a fully typed client with request validation, response validation, middleware support, retries, mock data, response wrappers, token handling, structured request support, contract-driven API testing, CLI workflows, and report generation.

ts
const user = await api.user.getUser({
path: { id: "123" },
});

Using NestJS on the backend? @tahanabavi/typefetch-nestjs validates the same contracts server-side. See Backend (NestJS).


Features

  • End-to-end TypeScript inference from Zod schemas

  • Runtime request and response validation

  • Structured request model: { path, query, body, headers }

  • Automatic path parameter injection

  • Automatic query string generation

  • JSON and form-data request bodies

  • JSON, text, blob, arrayBuffer, formData, file, stream and raw response types

  • Upload progress (via XMLHttpRequest) and download progress

  • Middleware pipeline

  • Built-in retry engine with backoff strategies

  • Timeout and AbortController support

  • Static tokens and dynamic token providers

  • Mock mode for development and testing

  • Response wrapper support for API envelopes

  • Normalized error handling with RichError

  • Typed per-endpoint error responses via an optional errors map

  • Stable endpoint identifiers and contract metadata on every generated method

  • Runtime instrumentation with structured request lifecycle events

  • Per-request runtime overrides for mock, error, latency, and schema swapping

  • Pluggable transports — HTTP built in, gRPC and GraphQL as optional packages

  • Normalized error taxonomy (RichError.kind) shared across every transport

  • Zero runtime dependencies

  • Field-level encryption middleware (optional package)

  • Backward-compatible flat request schemas

  • Contract-driven API test runner

  • Automatic test input generation from Zod schemas

  • Schema, mock, live, and full API test modes

  • Markdown, HTML, and JSON test reports

  • CLI commands for project setup, endpoint listing, API testing, and release documentation (optional package)

  • Versioned release documentation under docs/releases