CLI
@opra/cli provides the oprimp command — a code generator that connects to a running OPRA service, reads its API schema, and produces typed TypeScript client code automatically.
Instead of writing API client code by hand and keeping it in sync with the server, you run oprimp whenever the API changes and get up-to-date, fully typed models and controller proxies in seconds.
npx oprimp https://api.example.com ./src/generated
What gets generated
For every resource exposed by the service, oprimp generates:
- Model types — TypeScript interfaces and classes for all data types defined in the API schema
- Controller proxies — Typed wrappers around each HTTP controller, so you call methods instead of constructing URLs manually
The generated files are placed in the output directory and should be treated as build artifacts — committed or not, depending on your project's conventions.
Why it matters
In a classic setup, a frontend developer reads API documentation, manually writes fetch calls, maps response shapes to local types, and hopes nothing drifts. When the backend changes a field name, renames an endpoint, or drops a parameter, the frontend has no way to know. The application compiles cleanly and fails at runtime — often in production, often silently.
This problem scales with the application. A small project can absorb the cost of a few mismatched types. A large one, with dozens of endpoints and multiple frontend teams, turns every API change into a coordination exercise where something inevitably slips through.
oprimp eliminates this category of error. The generated code is derived directly from the live API schema, so the TypeScript types are always accurate. When the backend changes, re-running oprimp produces updated types immediately — and any part of the frontend that relied on the old shape fails at compile time, not at runtime. The compiler becomes your integration test.
There is a secondary benefit that has grown more significant recently: AI-assisted development. When an agent or a coding assistant needs to interact with an API, raw HTTP endpoints are opaque — the agent must infer intent from URL patterns and JSON shapes. Generated typed methods are self-describing. An agent can read ordersApi.create(input) and understand exactly what it does, what it accepts, and what it returns. This makes AI-assisted development on the frontend substantially more reliable and productive.
When to use it
- After any API change that adds, removes, or modifies endpoints or data types
- As a step in your CI/CD pipeline to ensure the client is always in sync with the deployed service
- During initial project setup to bootstrap the client layer
Installation
Global
npm install -g @opra/cli
oprimp https://api.example.com ./src/generated
Local (recommended)
npm install --save-dev @opra/cli
npx oprimp https://api.example.com ./src/generated
Without installation
npx @opra/cli https://api.example.com ./src/generated
See also
- oprimp CLI — full command reference
- Generating TypeScript Clients — step-by-step guide
- TsGenerator — programmatic API