Why Type Safety Matters
IntelliSense Support
Complete autocomplete for all API methods, parameters, and response data
Compile-time Checking
Catch errors during development, not at runtime
Self-Documenting Code
Types serve as always up-to-date documentation
Refactoring Safety
Confidently refactor with IDE support for finding all usages
Auto-Generated Types
All types are automatically generated from the OpenAPI specification, ensuring they’re always in sync with the API:Response Types vs Input Types
The SDK exports context-aware types to distinguish between data you read from the API and data you send to the API:| Type name | Used for | Example |
|---|---|---|
SchemaName | Response data (reading) | CustomerAddress, Cart, Product |
SchemaNameInput | Request bodies (writing) | CustomerAddressInput, AnalyticsEventInput |
- Response-only schemas — export the base name only (e.g.
Cart) - Request + response schemas — export both (e.g.
CustomerAddress+CustomerAddressInput) - Request-only schemas — export the
Inputname only (e.g.AnalyticsEventInput)
The { data, error } Pattern
Every API operation returns a type-safe object with data and error properties:
IntelliSense in Action
Method Parameters
Complete autocomplete for all API parameters with OpenAPI-generated types:Response Data Access
Full type safety when accessing response data:Cart Operations
Type-safe cart management with correct API structure:Advanced Type Features
Discriminated Unions
Type-safe handling of different response states:Generic Type Constraints
Type-safe configuration with OpenAPI-generated interfaces:Framework Integration Types
React Hook Types
Component Props
Type Utilities
Exported Utility Types
Readable & Writable Utility Types
The SDK re-exportsReadable and Writable utility types for advanced use cases where the generated exports don’t cover your needs:
In most cases you won’t need
Readable or Writable directly — the generated base-name and Input exports cover standard usage. These are provided as escape hatches.Type Guards
Development Experience
IDE Integration
The SDK works seamlessly with popular IDEs:- VSCode: Full IntelliSense, error squiggles, auto-imports
- WebStorm: Complete type information, refactoring support
- Vim/Neovim: TypeScript LSP provides full type information
Compile-Time Validation
Type Safety vs Direct API
- With SDK (Type-Safe)
- Direct API (No Types)
Best Practices
Enable Strict TypeScript
Enable Strict TypeScript
Configure TypeScript for maximum type safety:
tsconfig.json
Use OpenAPI-Generated Types
Use OpenAPI-Generated Types
Always import and use the generated types from the SDK:
Handle API Responses Properly
Handle API Responses Properly
Always check for both success and error conditions:
Migration Benefits
When migrating from direct API calls:Catch Errors Early
Find API usage errors during development, not production
Always Current Documentation
Types are auto-generated from OpenAPI spec and always up-to-date
Faster Development
IntelliSense speeds up development with accurate autocomplete
Confident Refactoring
Change APIs with confidence using IDE refactoring tools
All SDK types are automatically generated from the OpenAPI specification, ensuring they’re always accurate and up-to-date with the actual API. Response types use the base schema name (e.g.
CustomerAddress), while request body types use the Input suffix (e.g. CustomerAddressInput). The Readable and Writable utility types are also available for advanced use cases.