Get Started
此内容尚不支持你的语言。
@hey-api/openapi-python generates Python code from OpenAPI specifications. Point it at your spec, pick your plugins, and get production-grade code in seconds.
“The ecosystem trusted by TypeScript developers is coming to Python codebases.”
— Lubos, Founder of Hey API
Features
Section titled “Features”- production-grade code that compiles
- runs in any Node.js 22+ environment
- accepts any OpenAPI specification
- core plugin for SDKs
- HTTP client for HTTPX
- highly customizable via plugins
- sync with Hey API Registry for spec management
Quick Start
Section titled “Quick Start”The fastest way to use @hey-api/openapi-python is via npx
npx @hey-api/openapi-python -i hey-api/backend -o src/clientCongratulations on creating your first client! 🎉 You can learn more about the generated files on the Output page.
Installation
Section titled “Installation”You can download @hey-api/openapi-python from npm using your favorite package manager.
npm install @hey-api/openapi-python -D -Epnpm add @hey-api/openapi-python -D -Eyarn add @hey-api/openapi-python -D -Ebun add @hey-api/openapi-python -DVersioning
Section titled “Versioning”This package is in initial development. Please pin an exact version so you can safely upgrade when you’re ready.
We publish migration notes for every breaking release. You might not be impacted by a breaking change if you don’t use the affected features.
Most people run @hey-api/openapi-python via CLI. To do that, add a script to your package.json file which will make openapi-python executable through script.
"scripts": { "openapi-python": "openapi-python"}The above script can be executed by running npm run openapi-python 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
Section titled “Node.js”You can also generate output programmatically by calling createClient() in a JavaScript/TypeScript file.
import { createClient } from '@hey-api/openapi-python';
createClient({ input: 'hey-api/backend', // sign up at app.heyapi.dev output: 'src/client',});Configuration
Section titled “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.