zodios: OpenAPI-Style Type-Safe REST
What you'll learn: How zodios bridges the gap between traditional REST APIs and end-to-end type safety by generating TypeScript clients from Zod-validated REST endpoints.
The REST Type Safety Challenge
You've mastered tRPC's end-to-end type safety, but what if you need or want a traditional REST API? You face a dilemma: REST gives you standard HTTP semantics and broad compatibility, but typically loses TypeScript's type safety at the network boundary.
What zodios Does
zodios takes a different approach to type-safe REST. Instead of code generation from OpenAPI specs or manual type duplication, it uses Zod schemas to define your API contract in TypeScript. From these schemas, zodios automatically generates:
- Fully typed client methods
- Runtime request/response validation
- Type inference for path parameters, query strings, and request bodies
- HTTP method-specific type checking
Think of it as "tRPC's type inference philosophy applied to REST" — you write your schema once with Zod, and zodios handles both the types and runtime validation.
The OpenAPI Connection
While zodios doesn't require OpenAPI specs, it follows similar conventions: you declare endpoints with HTTP methods, paths, request schemas, and response schemas. The difference? Everything stays in TypeScript, leveraging Zod's runtime validation and TypeScript's type inference together.
The client knows exactly what each endpoint expects and returns, giving you autocomplete, compile-time errors for invalid requests, and runtime validation — all without code generation steps.
Core Philosophy
zodios sits between pure tRPC (RPC-style procedures) and traditional REST clients (minimal types). You get REST's standard HTTP semantics with type safety comparable to tRPC, validated by Zod at runtime.
Key Takeaway: zodios provides end-to-end type safety for REST APIs by using Zod schemas as the single source of truth, generating typed clients that validate at both compile time and runtime without code generation.