OpenAPI to code in seconds. | Hey API
Skip to content<br>For the complete documentation index, see llms.txt.
Host your specs. Generate from anywhere. Get Started
Menu
Products Codegen OpenAPI to TypeScript code generator
Docs TypeScript Get started, guides, and reference Python soon Get started, guides, and reference
Community Sponsors Fund open-source development GitHub
Search
soon Python code generator OpenAPI<br>to<br>TypeScript<br>TypeScript✓<br>Python✓
in seconds.
Production-grade API infrastructure. Typed SDKs, Zod schemas, TanStack Query hooks, and 20+ plugins. Free and open source.<br>$ npx @hey-api/openapi-ts
2.8M downloads last week
Get Started →<br>View Demo ↗
types Zod Valibot SDK TanStack Query
export type Order = {
id: string;
symbol: string;
side: 'buy' | 'sell';
type: 'market' | 'limit' | 'stop' | 'stop_limit';
quantity: number;
price?: number;
status: 'pending' | 'open' | 'filled' | 'partially_filled' | 'cancelled' | 'rejected';
createdAt: string;
};
export type CreateOrderData = {
body: Order;
};
export type CreateOrderResponse = Order;
import { z } from 'zod';
export const zOrder = z.object({
id: z.string().uuid(),
symbol: z.string(),
side: z.enum(['buy', 'sell']),
type: z.enum(['market', 'limit', 'stop', 'stop_limit']),
quantity: z.number(),
price: z.number().optional(),
status: z.enum(['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']),
createdAt: z.string().datetime(),
});
export type Order = z.infertypeof zOrder>;
;">
import * as v from 'valibot';
export const vOrder = v.object({
id: v.pipe(v.string(), v.uuid()),
symbol: v.string(),
side: v.picklist(['buy', 'sell']),
type: v.picklist(['market', 'limit', 'stop', 'stop_limit']),
quantity: v.number(),
price: v.optional(v.number()),
status: v.picklist(['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']),
createdAt: v.pipe(v.string(), v.isoTimestamp()),
});
export type Order = v.InferOutputtypeof vOrder>;
;">
import { createOrder } from './sdk.gen';
const { data, error } = await createOrder({
symbol: 'AAPL',
side: 'buy',
type: 'limit',
quantity: 10,
price: 189.5,
});
if (error) {
console.error('Order failed:', error.message);
return;
console.log('Order placed:', data.id);
import { useMutation } from '@tanstack/react-query';
import { createOrderMutation } from './react-query.gen';
const { mutate, data, isPending } = useMutation({
...createOrderMutation(),
});
mutate({
body: {
symbol: 'AAPL',
side: 'buy',
type: 'limit',
quantity: 10,
price: 189.5,
},
});
Pydantic SDK
from pydantic import BaseModel, AwareDatetime
from typing import Literal
from uuid import UUID
class Order(BaseModel):
id: UUID
symbol: str
side: Literal['buy', 'sell']
type: Literal['market', 'limit', 'stop', 'stop_limit']
quantity: float
price: float | None = None
status: Literal['pending', 'open', 'filled', 'partially_filled', 'cancelled', 'rejected']
createdAt: AwareDatetime
from client import Client, CreateOrderData
client = Client()
order, error = client.create_order(CreateOrderData(
symbol='AAPL',
side='buy',
type='limit',
quantity=10,
price=189.50,
))
if error:
print(f'Order failed: {error.message}')
else:
print(f'Order placed: {order.id}')
GR<br>"OpenAPI codegen that just works."<br>Guillermo Rauch CEO of Vercel
Trusted by
Vercel<br>OpenCode
PayPal
Amazon
Autodesk
Up and running in minutes<br>One config file. One command. Every time your spec changes.
01 / 04 Define your API
Define your API<br>Start with an existing spec or create one from scratch. OpenAPI is the foundation that powers everything.<br>openapi: 3.2.0
info:
title: Equity Trading API
version: 1.2.0
paths:
/orders:
post:
operationId: createOrder
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
responses:
'201':
description: Order placed
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
Connect your spec<br>Pass a local path, remote URL, or an API registry shorthand. All valid OpenAPI versions and file formats supported, including inline spec objects.<br>export default defineConfig({
input: 'https://api.tradespark.io/openapi.json',
output: 'src/trading-client',
});
Compose your output<br>Choose exactly what gets generated – nothing more, nothing less. Each plugin is independent and composable.<br>export default defineConfig({
input: 'https://api.tradespark.io/openapi.json',
output: 'src/trading-client',
plugins: ['@hey-api/sdk', 'zod', '@tanstack/react-query'],
});
Use it<br>Run once or integrate into CI. Generated code is fully typed and deterministic. Same spec, same output, every time.<br>import { createOrder, zOrder } from './trading-client';
const { data, error } = await createOrder({
body: {
symbol: 'AAPL',
side: 'buy',
type: 'limit',
quantity: 10,
price: 189.5,
},
});
if (error) {
console.error('Order rejected:', error.message);
return;
const order = zOrder.parse(data);
console.log(`Order...