JavaScript SDK
aegis-api — a typed client for every Aegis endpoint.
aegis-api wraps the whole API reference with types
generated from the same OpenAPI document the reference is built from. It has
no runtime dependencies and is ESM-only.
Two things it does for you that raw fetch does not:
- Successful responses arrive already unwrapped. The API answers
{ data }; the SDK resolves to the inner value. - Anything the API rejects arrives as an
AegisError, carrying a status, a code, and the request id.
Install
Needs a runtime with a global fetch (Node 18+). The event
socket additionally needs a global WebSocket (Node 22+), unless
you supply your own.
Create a client
Passing neither apiKey nor baseUrl throws immediately — it is always a
mistake, and failing at construction beats failing on the first request.
A first call
The method signature is derived from the operation, so a misspelled field or a value of the wrong type is a compile error rather than a runtime surprise.
Resources
Each namespace maps to a path prefix, and method names follow the path:
The full method-by-method listing is on SDK resources.
Any endpoint, by path
aegis.request reaches any route directly, still typed:
Passing a query to a route that has none is a type error, so the compiler keeps you honest even on the escape hatch.
Errors
There is one error class, not a hierarchy — branch on status or code. See
SDK errors.
Events
aegis.music carries the events socket:
Types
The package re-exports the generated schema, so any response shape is reachable by name:
Types are regenerated from the live API, so a field the API renames shows up as
a type error on your next build rather than as undefined at runtime.