Skip to content
TypeWire

@tahanabavi/typefetch

v2.0.0

A strongly typed TypeScript HTTP client powered by Zod contracts, middleware, retries, mock data, contract testing, CLI tooling, and report generation.

Installation

bash
npm install @tahanabavi/typefetch zod

Or with Yarn:

bash
yarn add @tahanabavi/typefetch zod

Or with pnpm:

bash
pnpm add @tahanabavi/typefetch zod

zod is the only peer dependency. The core itself has zero runtime dependencies.

Optional packages

Install only what you use — nothing below is bundled unless you register it.

PackageAdd when you need
@tahanabavi/typefetch-graphqlGraphQL routes
@tahanabavi/typefetch-grpcgRPC / Connect routes
@tahanabavi/typefetch-encryptionencryptionMiddleware
@tahanabavi/typewire-clithe typewire command

Quick Start

ts
import { z } from 'zod'
import { ApiClient } from '@tahanabavi/typefetch'

const contracts = {
user: {
getUser: {
method: 'GET',
path: '/users/:id',
auth: true,
request: z.object({
path: z.object({
id: z.string(),
}),
}),
response: z.object({
id: z.string(),
name: z.string(),
}),
},
},
} as const

const client = new ApiClient(
{
baseUrl: 'https://api.example.com',
tokenProvider: async () => 'your-token',
},
contracts
)

client.init()

const api = client.modules

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

console.log(user.name)