When consuming APIs in your applications, you need to make HTTP requests and handle responses. You have several options for generating API clients, ranging from manual implementation to automated code generation from OpenAPI specifications.
Generating API clients from OpenAPI specifications provides several key benefits:
Type safety - Strongly-typed models prevent runtime errors
Reduced boilerplate - Eliminates repetitive HTTP client code
Automatic updates - Client stays in sync when API changes
Better developer experience - IntelliSense and compile-time error checking
Consistency - Standardized approach across your codebase
Automate generation - Include client generation in your build pipeline
Separate generated code - Keep generated clients in separate projects/folders
Don't modify generated code - Use partial classes or wrapper services for customizations
Use dependency injection - Register generated clients with your DI container
https://github.com/microsoft/kiota
Kiota is Microsoft's next-generation API client generator designed for modern cloud APIs.
How it works: Generates fluent clients from OpenAPI specifications with focus on Microsoft Graph APIs and modern patterns.
✅ Pros
Modern async/await patterns
Supports complex API scenarios - you can filter to the endpoints you care about
Growing ecosystem and active development
Extendable - easy to add handlers to the client
❌ Cons
https://orval.dev
Orval is a TypeScript-first OpenAPI generator, popular for Next.js and React projects. It integrates cleanly with TanStack Query (React Query), making API consumption highly ergonomic.
How it works: Reads your OpenAPI specification and generates TypeScript clients with optional React Query hooks, mocks, and strongly typed DTOs.
✅ Pros
Generates modern fetch-based clients compatible with Next.js and Edge runtimes
Optional React Query hooks out of the box
Type-safe DTOs and request/response validation
Can also generate API mocks for frontend testing
Generated code is clean, readable, and follows familiar HTTP conventions
Clients are easily extensible e.g. add interceptors for bearer tokens, custom headers, or logging with minimal effort
❌ Cons
https://github.com/RicoSuter/NSwag
NSwag generates strongly-typed C# and TypeScript clients from OpenAPI specifications.
How it works: Reads your OpenAPI/Swagger specification and generates complete client classes with methods, models, and error handling.
✅ Pros
Generates C# and TypeScript clients
Full-featured with extensive customization options
Handles complex scenarios (inheritance, polymorphism)
Strong tooling support (CLI, MSBuild, Visual Studio)
❌ Cons
https://github.com/reactiveui/refit
Refit generates HTTP client implementations from interface definitions using attributes.
How it works: You define interfaces with HTTP attributes, and Refit generates the implementation at runtime.
✅ Pros
Simple attribute-based API definitions
Lightweight and easy to learn
Great integration with .NET dependency injection
No code generation step required
❌ Cons
REST HTTP only (no GraphQL, gRPC, etc.)
Manual model definition required
Runtime generation (no compile-time validation of endpoints)
Hand-writing HTTP client code for each API endpoint without any code generation.
✅ Pros
❌ Cons
Time consuming and repetitive
Error prone (typos, wrong URLs, etc.)
No automatic updates when API changes
Manual serialization/deserialization
No compile-time validation