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.
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-datarequest bodiesJSON, text, blob, arrayBuffer, formData, file, stream and raw response types
Upload progress (via
XMLHttpRequest) and download progressMiddleware pipeline
Built-in retry engine with backoff strategies
Timeout and
AbortControllersupportStatic tokens and dynamic token providers
Mock mode for development and testing
Response wrapper support for API envelopes
Normalized error handling with
RichErrorTyped per-endpoint error responses via an optional
errorsmapStable 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 transportZero 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