The exact API contract type, preserving all endpoint
builder generics so that params, body, query, and response types
are fully inferred.
The API contract created with defineApi().
Client configuration (base URL, auth token, custom fetch, etc.).
A TypedClient whose shape mirrors the contract.
import { api } from 'todo-shared';
import { createClient } from '@cleverbrush/web';
const client = createClient(api, {
baseUrl: 'https://api.example.com',
getToken: () => localStorage.getItem('token'),
onUnauthorized: () => { window.location.href = '/login'; },
});
// Fully typed — params, body, and response types are inferred.
const todos = await client.todos.list();
const todo = await client.todos.get({ params: { id: 1 } });
const created = await client.todos.create({ body: { title: 'Buy milk' } });
Creates a fully typed HTTP client from an API contract.
The returned object mirrors the shape of the contract: each group becomes a namespace and each endpoint within that group becomes an async callable function.
At runtime, endpoint metadata (HTTP method, path template, schemas) is read from each
EndpointBuildervia.introspect(). Path parameters are serialized through theParseStringSchemaBuilder.serialize()method when aroute()template is used; query parameters are serialized to a query string; and the request body is JSON-encoded for methods that accept a body.