Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork264
🌀 OpenAPI to TypeScript code generator. Generate API clients, SDKs, validators, and more.
License
hey-api/openapi-ts
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Demo • Docs • Issues • Contribute
@hey-api/openapi-ts is anopen source OpenAPI to TypeScript code generator trusted by companies like Google, Amazon, and PayPal to generate API clients, SDKs, validators, and more. We also build complementary tools andservices that help teams design, manage, and distribute APIs more effectively.
- runs in CLI, Node.js 20+, or npx
- works with OpenAPI 2.0, 3.0, and 3.1
- core plugins for types, SDKs, and schemas
- clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.)
- plugin ecosystem to reduce third-party boilerplate
- custom plugins and custom clients
- integration with Hey API Platform
Access your projects and OpenAPI specifications in theHey API Platform.
Want to see your code in products used by millions?
Start with ourContributing guide and release your first feature.
Help Hey API stay around for the long haul by becoming asponsor.
|
scalar.com | fastapi.tiangolo.com |
![]() |
The fastest way to use@hey-api/openapi-ts is via npx
npx @hey-api/openapi-ts -i hey-api/backend -o src/client
Congratulations on creating your first client! 🎉 You can learn more about the generated files on theOutput page.
You can download@hey-api/openapi-ts from npm using your favorite package manager.
npm install @hey-api/openapi-ts -D -E
pnpm add @hey-api/openapi-ts -D -E
yarn add @hey-api/openapi-ts -D -E
bun add @hey-api/openapi-ts -D -E
This package does NOT follow thesemantic versioning strategy. Please pin an exact version so you can safely upgrade when you're ready.
Due to the nature of the package, we use the following versioning strategy.
1.x.x: significant breaking changes, reserved for v1 releasex.1.x: breaking changesx.x.1: new features, bug fixes, and non-breaking changes
We publishmigration notes for every breaking release. You might not be impacted by a breaking release if you don't use the affected plugin(s).
Most people run@hey-api/openapi-ts via CLI. To do that, add a script to yourpackage.json file which will makeopenapi-ts executable through script.
"scripts": {"openapi-ts":"openapi-ts"}
The above script can be executed by runningnpm run openapi-ts or equivalent command in other package managers. Next, we will create aconfiguration file and move our options from Quick Start to it.
You can also generate output programmatically by callingcreateClient() in a JavaScript/TypeScript file.
import{createClient}from'@hey-api/openapi-ts';createClient({input:'hey-api/backend',// sign up at app.heyapi.devoutput:'src/client',});
@hey-api/openapi-ts supports loading configuration from any file inside your project root folder supported byjiti loader. Below are the most common file formats.
import{defineConfig}from'@hey-api/openapi-ts';exportdefaultdefineConfig({input:'hey-api/backend',// sign up at app.heyapi.devoutput:'src/client',});
/**@type {import('@hey-api/openapi-ts').UserConfig} */module.exports={input:'hey-api/backend',// sign up at app.heyapi.devoutput:'src/client',};
/**@type {import('@hey-api/openapi-ts').UserConfig} */exportdefault{input:'hey-api/backend',// sign up at app.heyapi.devoutput:'src/client',};
Alternatively, you can useopenapi-ts.config.js and configure the export statement depending on your project setup.
You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
If you use an HTTPS URL with a self-signed certificate in development, you will need to set
NODE_TLS_REJECT_UNAUTHORIZED=0in your environment.
You must set the output so we know where to generate your files. It can be a path to the destination folder or an object containing the destination folder path and optional settings.
You should treat the output folder as a dependency. Do not directly modify its contents as your changes might be erased when you run
@hey-api/openapi-tsagain.
We parse your input before making it available to plugins. While configuring the parser is optional, it's the perfect place to modify or validate your input if needed.
Plugins are responsible for generating artifacts from your input. By default, Hey API will generate TypeScript interfaces and SDK from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so!
Clients are responsible for sending the actual HTTP requests. Using clients is not required, but you must add a client toplugins if you're generating SDKs (we default to Fetch).
@hey-api/client-fetch@hey-api/client-angular@hey-api/client-axios@hey-api/client-next@hey-api/client-nuxt
The following clients are planned but not in development yet. You can help us prioritize them by voting onGitHub.
Don't see your client?Build your own or let us know your interest byopening an issue.
These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue onGitHub if you'd like us to support your favorite package.
@angular/common@hey-api/schemas@hey-api/sdk@hey-api/transformers@hey-api/typescript@pinia/colada@tanstack/angular-query-experimental@tanstack/react-query@tanstack/solid-query@tanstack/svelte-query@tanstack/vue-queryfastifyvalibotzod
The following plugins are planned but not in development yet. You can help us prioritize them by voting onGitHub.
- Adonis
- Ajv
- Arktype
- Chance
- Elysia
- Express
- Faker
- Falso
- Hono
- Joi
- Koa
- MSW
- Nest
- Nock
- Superstruct
- Supertest
- SWR
- TypeBox
- Yup
- Zustand
Don't see your plugin?Build your own or let us know your interest byopening an issue.
You can learn more on theMigrating page.
Released under theMIT License.
About
🌀 OpenAPI to TypeScript code generator. Generate API clients, SDKs, validators, and more.
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.


