Get Started ​
@hey-api/openapi-ts is an OpenAPI to TypeScript codegen trusted over 2,000,000 times each month to generate reliable API clients and SDKs. The code is MIT-licensed and free to use. Discover available features below or view our roadmap to learn what's coming next.
Demo ​
Features ​
- runs in CLI, Node.js 18+, or npx
- works with OpenAPI 2.0, 3.0, and 3.1
- customizable types and SDKs
- clients for your runtime (Fetch API, Axios, Next.js, Nuxt, etc.)
- plugin ecosystem to reduce third-party boilerplate
- custom plugins and custom clients
- integration with Hey API Platform
Quick Start ​
The fastest way to use @hey-api/openapi-ts
is via npx
npx @hey-api/openapi-ts \
-i https://get.heyapi.dev/hey-api/backend \
-o src/client
Congratulations on creating your first client! 🎉 You can learn more about the generated files on the Output page.
Installation ​
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
Versioning ​
This package does NOT follow the semantic 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 publish migration notes for every breaking release. You might not be impacted by a breaking release if you don't use the affected plugin(s).
Usage ​
CLI ​
Most people run @hey-api/openapi-ts
via CLI. To do that, add a script to your package.json
file which will make openapi-ts
executable through script.
"scripts": {
"openapi-ts": "openapi-ts"
}
The above script can be executed by running npm run openapi-ts
or equivalent command in other package managers. Next, we will create a configuration file and move our options from Quick Start to it.
Node.js ​
You can also generate output programmatically by importing @hey-api/openapi-ts
in a JavaScript/TypeScript file.
import { createClient } from '@hey-api/openapi-ts';
createClient({
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
});
Configuration ​
It's a good practice to extract your configuration into a separate file. Learn how to do that and discover available options on the Configuration page.
Examples ​
You can view live examples on StackBlitz.
Sponsors ​
Help Hey API stay around for the long haul by becoming a sponsor.