CLI Integration

Automate your API client setup with the Igniter CLI.

The Igniter CLI allows you to generate a fully typed Caller and its corresponding Zod schemas directly from an OpenAPI 3 specification. This is the fastest way to integrate third-party APIs or sync with your own backend.

Generation Command

Use the generate caller command:

npx @igniter-js/cli generate caller --name facebook --url https://api.facebook.com/openapi.json
pnpm igniter generate caller --name facebook --url https://api.facebook.com/openapi.json
yarn igniter generate caller --name facebook --url https://api.facebook.com/openapi.json
bunx @igniter-js/cli generate caller --name facebook --url https://api.facebook.com/openapi.json

Command Options

OptionDescription
--namePrefix for the generated variables and file naming.
--urlRemote URL of the OpenAPI JSON/YAML.
--pathLocal file path to the OpenAPI spec.
--outputOverride output directory (default: src/callers/<hostname>).

Generated Assets

The command generates two main files in your project:

  1. schema.ts: Contains all Zod schemas derived from components/schemas and a path-first IgniterCallerSchema builder.
  2. index.ts: Exports a pre-configured IgniterCaller instance.

Using the Generated Caller

import { facebookCaller } from '@/callers/facebook'
import type { FacebookCallerSchemas } from '@/callers/facebook/schema'

// Making a request (URL is typed!)
const result = await facebookCaller.get('/me').execute()

// Type inference for responses
type MeResponse = ReturnType<
  typeof FacebookCallerSchemas.$Infer.Response<'/me', 'GET', 200>
>

Why use CLI Generation?

  • Zero Manual Typing: Keep your TS types perfectly in sync with the API documentation.
  • Runtime Safety: Automatic validation ensures the data you receive matches the code you wrote.
  • Speed: Go from an URL to a production-ready client in seconds.

Manual Schemas

If you don't have an OpenAPI spec, you can still define Manual Schemas using the IgniterCallerSchema builder.