RESTyped is a TypeScript specification and lightweight library for end-to-end typing of REST APIs. Current stable version is 1.1.0. It enables sharing request and response types between server and client via a single interface definition, ensuring type safety across HTTP boundaries. Unlike alternatives like tRPC or GraphQL codegen, RESTyped is unopinionated, works with any existing REST API, and adds no runtime overhead for most implementations. It supports common HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS) and allows typing params, query, body, and response per route. Requires TypeScript 2.4+. The library itself is just type definitions; integrations exist for Axios and Express (the latter as WIP).
npm install restypedNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates defining a typed REST API interface with GET and POST endpoints, then using TypedAxiosInstance from restyped-axios for type-safe HTTP calls.
Ensure route paths in the interface and HTTP calls are identical (e.g., '/users' not '/users/').
Only define 'params' when the route has placeholders like ':id'. For static routes, omit 'params' entirely.
Use runtime validation (e.g., zod, io-ts) alongside RESTyped for runtime safety.
Use 'RouteShape' from 'restyped' to define routes, or update your API definitions to match the new specification (interface per route).
Verify the server response matches the type in your interface, or adjust the interface to match the actual response.
Upgrade to restyped@1.1.0: npm install restyped@latest
No dependency data recorded yet.