zodios is a free, open source api development & testing project written in TypeScript and released under MIT. It has 1,917 GitHub stars, 57 forks and 23 open issues, and was last pushed 7 hours ago. On this registry it ranks #114 of 178 tracked projects in API Development & Testing, with 5 head-to-head comparisons available.

What is zodios?

Zodios is a TypeScript API client and optional API server that derives end-to-end type safety and runtime validation from Zod schemas, built for TypeScript developers who define REST APIs and want typed URLs, parameters, and responses in the same codebase.

What it is

Zodios is an axios-compatible HTTP client paired with an optional Express-compatible API server, both driven by a single centralized API declaration. The declaration describes each endpoint as an object with method, path, an optional alias, an optional description, a Zod response schema, and an optional errors array, and the client consumes that array directly. Because the definition is ordinary TypeScript, the types flow through to call sites: the path string auto-completes, :id parameters are detected and demanded by the call signature, and the resolved value is typed from the response schema. Response schema validation runs at runtime, so a payload that does not match the declared Zod shape is caught rather than silently trusted.

The concrete problem it solves is the gap between a hand-written API client and the API it talks to. In a typical axios setup, endpoint paths, query parameters, and response shapes live in the developer's head or in a separate type file, and drift the moment the server changes. Zodios replaces the handwritten, manually typed axios client with one generated from the same schema that a Zod validator already expresses, and, through @zodios/express, extends that single source of truth to the server side. The ecosystem also provides openapi-zod-client, which generates a Zodios client from an existing OpenAPI specification, so projects do not need to abandon an existing spec to adopt the client. It lives in the TypeScript and Node.js ecosystem, alongside Zod, axios, and Express.

Key capabilities

  • Centralized API declaration as an array of endpoint objects with method, path, alias, description, response, status, and errors fields.
  • TypeScript autocompletion for URL paths and parameters in the IDE, with response types inferred from the declared Zod schema.
  • Runtime response schema validation using Zod, including zod transform support to reshape a response value before it is returned.
  • axios compatibility, so all axios features remain available, plus plugins including a fetch adapter and automatic auth injection.
  • An optional Express-compatible server through @zodios/express, retaining Express features such as middlewares, and documented Next.js integration.
  • @tanstack/query wrappers published as @zodios/react and @zodios/solid, with Vue and Svelte wrappers listed as coming soon.
  • Client generation from OpenAPI specifications via the openapi-zod-client project, and additional plugins under @zodios/plugins.

Who uses it and how

  • TypeScript teams building REST APIs who want the tRPC-style end-to-end type safety that @zodios/express advertises, but over REST rather than RPC.
  • Client developers who already use axios and want to keep axios behavior while adding typed paths, typed parameters, and validated responses.
  • React and Solid applications that pair a Zodios client with @tanstack/query through @zodios/react or @zodios/solid for data fetching and caching.
  • Backend teams with an existing OpenAPI specification who generate a typed client with openapi-zod-client instead of writing one by hand.
  • Full-stack Node.js projects that declare the API once and share it between an Express server and a browser or server-side client.

Getting started

Install the client and the API definition package with npm install @zodios/core or yarn add @zodios/core; for the server side, install @zodios/core together with @zodios/express using the same package manager. Full documentation, including API definition, client, server, React hooks, Solid hooks, and Next.js integration guides, is published at zodios.org.

How it compares

Zodios occupies the same ground as tRPC in aiming for end-to-end type safety, but it targets REST APIs over HTTP rather than RPC-style procedures, which keeps it compatible with existing REST endpoints and OpenAPI specifications. Where tRPC owns both ends of the contract, Zodios builds on axios on the client and Express on the server, so it slots into stacks that already depend on those libraries and can adopt validation incrementally through @zodios/core alone.

When to use it — and when not to

Adopting the server side means running and operating your own Node.js and Express service, along with whatever infrastructure that service already requires; Zodios adds typing and validation but no hosting, database, or mail layer. Teams that do not write TypeScript, or that want a hosted API platform rather than a library, will get little from it, and anyone needing Vue or Svelte query wrappers today should note that only React and Solid wrappers are published, with the others listed as coming soon. The published roadmap for v11 covering Zod and Io-Ts support is unfinished, and the project carries 23 open issues, so buyers should weigh the maintenance surface against the typing benefit before committing.

project readme (upstream, from github) — read inline

Zodios

Zodios logo

Zodios is a typescript api client and an optional api server with auto-completion features backed by axios and zod and express
Documentation

langue typescript npm GitHub GitHub Workflow Status

Bundle Size Bundle Size Bundle Size Bundle Size Bundle Size Bundle Size Bundle Size

https://user-images.githubusercontent.com/633115/185851987-554f5686-cb78-4096-8ff5-c8d61b645608.mp4

What is it ?

It's an axios compatible API client and an optional expressJS compatible API server with the following features:

  • really simple centralized API declaration
  • typescript autocompletion in your favorite IDE for URL and parameters
  • typescript response types
  • parameters and responses schema thanks to zod
  • response schema validation
  • powerfull plugins like fetch adapter or auth automatic injection
  • all axios features available
  • @tanstack/query wrappers for react and solid (vue, svelte, etc, soon)
  • all expressJS features available (middlewares, etc.)

Table of contents:

Install

Client and api definitions :

> npm install @zodios/core

or

> yarn add @zodios/core

Server :

> npm install @zodios/core @zodios/express

or

> yarn add @zodios/core @zodios/express

How to use it on client side ?

For an almost complete example on how to use zodios and how to split your APIs declarations, take a look at dev.to example.

Declare your API with zodios

Here is an example of API declaration with Zodios.

import { Zodios } from "@zodios/core";
import { z } from "zod";

const apiClient = new Zodios(
  "https://jsonplaceholder.typicode.com",
  // API definition
  [
    {
      method: "get",
      path: "/users/:id", // auto detect :id and ask for it in apiClient get params
      alias: "getUser", // optional alias to call this endpoint with it
      description: "Get a user",
      response: z.object({
        id: z.number(),
        name: z.string(),
      }),
    },
  ],
);

Calling this API is now easy and has builtin autocomplete features :

//   typed                     auto-complete path   auto-complete params
//     ▼                               ▼                   ▼
const user = await apiClient.get("/users/:id", { params: { id: 7 } });
console.log(user);

It should output

{ id: 7, name: 'Kurtis Weissnat' }

You can also use aliases :

//   typed                     alias   auto-complete params
//     ▼                        ▼                ▼
const user = await apiClient.getUser({ params: { id: 7 } });
console.log(user);

API definition format

type ZodiosEndpointDescriptions = Array<{
  method: 'get'|'post'|'put'|'patch'|'delete';
  path: string; // example: /posts/:postId/comments/:commentId
  alias?: string; // example: getPostComments
  immutable?: boolean; // flag a post request as immutable to allow it to be cached with react-query
  description?: string;
  requestFormat?: 'json'|'form-data'|'form-url'|'binary'|'text'; // default to json if not set
  parameters?: Array<{
    name: string;
    description?: string;
    type: 'Path'|'Query'|'Body'|'Header';
    schema: ZodSchema; // you can use zod `transform` to transform the value of the parameter before sending it to the server
  }>;
  response: ZodSchema; // you can use zod `transform` to transform the value of the response before returning it
  status?: number; // default to 200, you can use this to override the sucess status code of the response (only usefull for openapi and express)
  responseDescription?: string; // optional response description of the endpoint
  errors?: Array<{
    status: number | 'default';
    description?: string;
    schema: ZodSchema; // transformations are not supported on error schemas
  }>;
}>;

Full documentation

Check out the full documentation or following shortcuts.

Ecosystem

Roadmap for v11

for Zod/Io-Ts` :

  • By using the TypeProvider pattern we can now make zodios validation agnostic.

  • Implement at least ZodTypeProvider and IoTsTypeProvider since they both support input and output type inferrence

  • openapi generation will only be compatible with zod though

  • Not a breaking change so no codemod needed

  • MonoRepo:

    • Zodios will become a really large project so maybe migrate to turbo repo + pnpm

    • not a breaking change

  • Transform:

    • By default, activate transforms on backend and disable on frontend (today it's the opposite), would make server transform code simpler since with this option we could make any transforms activated not just zod defaults.

    • Rationale being that transformation can be viewed as business code that should be kept on backend

    • breaking change => codemod to keep current defaults by setting them explicitly

  • Axios:

    • Move Axios client to it's own package @zodios/axios and keep @zodios/core with only common types and helpers

    • Move plugins to @zodios/axios-plugins

    • breaking change => easy to do a codemod for this

  • Fetch:

    • Create a new Fetch client with almost the same features as axios, but without axios dependency @zodios/fetch

    • Today we have fetch support with a plugin for axios instance (zodios maintains it's own axios network adapter for fetch). But since axios interceptors are not used by zodios plugins, we can make fetch implementation lighter than axios instance.

    • Create plugins package @zodios/fetch-plugins

    • Not sure it's doable without a lot of effort to keep it in sync/compatible with axios client

    • new feature, so no codemod needed

  • React/Solid:

    • make ZodiosHooks independant of Zodios client instance (axios, fetch)

    • not a breaking change, so no codemod needed

  • Client Request Config

    • uniform Query/Mutation

readme truncated — read the full docs on github

Frequently asked questions

Is zodios free to use?

zodios is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does zodios do?

typescript http client and server with zod validation

What is zodios written in?

zodios is primarily written in TypeScript. Its source is publicly available at https://github.com/ecyrbe/zodios, and it has 1,917 GitHub stars.