npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

axigen

v1.3.0

Published

Generate typed Axios client functions from OpenAPI / Swagger specs

Readme

axigen

Generate typed Axios client functions from your OpenAPI / Swagger spec — in one command.

npm version license node

Overview

axigen reads your OpenAPI (or Swagger) spec and generates fully-typed Axios wrapper functions, so you never have to write boilerplate API calls by hand again.

  • ✅ Supports OpenAPI 3.x and Swagger 2.x (YAML or JSON)
  • ✅ Generates typed request/response interfaces
  • ✅ Works with your own Axios instance
  • ✅ TypeScript and JavaScript output
  • ✅ JSDoc comments from your spec's summaries
  • ✅ Filter endpoints by tag
  • ✅ Zero runtime dependencies in generated code

Installation

npm install -D axigen
# or
pnpm add -D axigen
# or
yarn add -D axigen

Quick Start

1. Create a config file:

npx axigen init

2. Edit axigen.config.js:

/** @type {import('axigen').AxigenConfig} */
module.exports = {
  // Path to your OpenAPI spec (YAML or JSON)
  input: "./openapi.yaml",

  output: {
    // Generated Axios client functions
    client: "./src/api/client.ts",
    // Generated TypeScript types
    types: "./src/api/types.ts",
  },

  // Import path to your Axios instance inside your project
  axiosInstancePath: "../lib/axios",
  axiosInstanceExport: "axiosInstance",

  language: "ts",
  jsdoc: true,
  functionName: {
    transforms: [{ match: "-([a-zA-Z])", flags: "g", replacement: "upper:$1" }],
    appendMethod: ["post", "put", "delete", "patch", "get", "head", "options"],
  },
};

3. Run:

npx axigen generate
# or simply:
npx axigen

Example

Given this OpenAPI spec:

paths:
  /users:
    get:
      operationId: getUsers
      summary: Get user list
      tags: [users]
      parameters:
        - name: page
          in: query
          schema:
            type: integer
        - name: limit
          in: query
          schema:
            type: integer
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/User"
                  total:
                    type: integer

  /users/{userId}:
    get:
      operationId: getUserById
      summary: Get user by ID
      tags: [users]
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/User"

axigen generates:

// This file is auto-generated by axigen. DO NOT EDIT.
// Generated at: 2026-06-26T11:56:19.002Z

import type { AxiosRequestConfig, AxiosResponse } from "axios";
import { axiosInstance } from "../lib/axios";
import type { GetUserByIdPathParams, GetUserByIdResponse, GetUsersQueryParams, GetUsersResponse } from "./types";

/**
 * Get user list
 * `GET /users`
 * @tags users
 */
export async function getGetUsers(
  params?: GetUsersQueryParams,
  config?: AxiosRequestConfig,
  options?: AxiosRequestConfig,
): Promise<AxiosResponse<GetUsersResponse>> {
  const mergedConfig: AxiosRequestConfig = { ...config, params: { ...params, ...config?.params } };
  return axiosInstance({ method: "GET", url: "/users", ...mergedConfig }, options);
}

/**
 * Get user by ID
 * `GET /users/{userId}`
 * @tags users
 */
export async function getGetUserById(
  userId: GetUserByIdPathParams["userId"],
  config?: AxiosRequestConfig,
  options?: AxiosRequestConfig,
): Promise<AxiosResponse<GetUserByIdResponse>> {
  return axiosInstance({ method: "GET", url: `/users/${userId}`, ...config }, options);
}

Configuration

| Option | Type | Default | Description | | --------------------------- | -------------- | --------------- | ------------------------------------------------------------------------ | | input | string | — | Path to your OpenAPI spec file (YAML or JSON) | | output.client | string | — | Output path for the generated client functions | | output.types | string | — | Output path for generated TypeScript types (optional) | | axiosInstancePath | string | — | Import path to your Axios instance | | axiosInstanceExport | string | axiosInstance | Named export of your Axios instance | | language | 'ts' \| 'js' | 'ts' | Output language | | jsdoc | boolean | true | Add JSDoc comments to generated functions | | tags | string[] | — | Only generate endpoints matching these tags | | functionName | object | — | Control generated function name transforms and method suffix (see below) | | functionName.transforms | Transform[] | [] | Array of regex transform rules applied to the operationId | | functionName.appendMethod | string[] | [] | HTTP methods whose name is appended as a suffix to the function name |

Axios Instance

axigen does not create an Axios instance for you — it imports the one you already have in your project. The generated functions expect your instance to follow this call signature:

axiosInstance(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<AxiosResponse>

This is intentional: it lets you intercept or merge options at the instance level (e.g. passing per-request auth headers or timeout overrides as a second argument), keeping generated code decoupled from your instance's internal logic.

A typical instance looks like this:

// src/lib/axios.ts
import axios, { type AxiosRequestConfig } from "axios";

const instance = axios.create({
  baseURL: "https://api.example.com/v1",
  headers: {
    "Content-Type": "application/json",
  },
});

export const axiosInstance = (config: AxiosRequestConfig, options?: AxiosRequestConfig) => instance({ ...config, ...options });

Then in your config:

axiosInstancePath: '../lib/axios',
axiosInstanceExport: 'axiosInstance', // default, can be omitted

Note: If you use a plain axios.create() instance without the two-argument wrapper, the options parameter passed by generated functions will be ignored. The wrapper pattern above is the recommended approach.


CLI

# Generate client from config (default command)
axigen generate [--config <path>] [--cwd <path>]

# Create a starter config file
axigen init

# Show version
axigen --version

# Show help
axigen --help

Programmatic Usage

You can also use axigen directly in Node.js scripts:

import { generate, loadConfig } from "axigen";

const config = await loadConfig(process.cwd());
const result = await generate(config, process.cwd());

console.log(`✓ Generated ${result.endpointCount} endpoints`);
console.log(`  client → ${result.clientPath}`);
console.log(`  types  → ${result.typesPath}`);

License

MIT