Type declarations included
No@types/ package is needed. When you install okx-api, the type declarations are included automatically:
src/types/ and are exported from the package root, so you can import them directly.
Typed REST requests
Every request parameter object has a corresponding TypeScript interface. Import and annotate your variables to get inline documentation and catch mistakes at compile time.Typed order submission
OrderRequest interface captures all available fields including optional ones:
Typed REST responses
Return types are inferred automatically — no casting needed. Your IDE will offer autocomplete on every response field.Typed WebSocket event handling
TheWebsocketClient is event-driven. Subscription data arrives on the 'update' event.
Shared type utilities
The SDK exports a collection of shared types for common OKX concepts. Import them to type your own application code:Client options types
Both clients export their options interfaces for use in factory functions or dependency injection:Tips for maximum IDE benefit
Use IntelliSense
Hover over any client method in VSCode to see its parameter types and return type inline, without consulting external docs.
Annotate your variables
Explicitly typing request objects (e.g.
const order: OrderRequest = { ... }) triggers IntelliSense suggestions for every available field.Strict mode
Enable
strict_param_validation: true in RestClientOptions to have the SDK throw at runtime if any parameters are undefined.Go to definition
Use your IDE’s “Go to Definition” on any SDK type to browse the full interface directly in
src/types/.
