ts-rest is a TypeScript toolkit for building type-safe APIs by defining a shared contract that connects client and server code. The core idea is to specify endpoints, methods, request and response shapes in a single contract, then use that contract to generate fully typed clients and enforce server implementations that match the contract at compile time.
The project provides a way to consume remote APIs through a client that infers request and response shapes from the shared contract, offering autocompletion and compile-time checks. On the server side, it enforces that handlers return correct status codes and response shapes as defined in the contract. Additionally, it includes runtime request validation against predefined schemas to catch mismatches before they reach business logic.
The documentation covers defining contracts, implementing servers, and consuming APIs with type safety, providing a complete workflow for end-to-end type safety in API development.