TypeScript SDK
@asiri-ng/sdk-ts is the official TypeScript client for the Asiri API. It works in Node 20+,
Bun, Deno, and Edge runtimes that provide fetch.
Status: The package builds to
dist/from the same OpenAPI document as the public API reference. GitHub publishes new package versions to npm after a PR is merged intodevelop.
What it gives you
- Fully typed request / response models, generated from the public OpenAPI 3.1 document.
- A thin
openapi-fetchclient. - Bearer token injection when
apiKeyis configured. AsiriError.from()for parsing API error envelopes.- Type re-exports for
paths,components, andoperations.
Installation
pnpm add @asiri-ng/sdk-ts
# or
npm install @asiri-ng/sdk-tsThe package bundles its own openapi-fetch runtime.
Usage
import { AsiriError, createAsiriClient } from '@asiri-ng/sdk-ts';
const asiri = createAsiriClient({
baseUrl: 'https://api.asiri.ng',
apiKey: process.env.ASIRI_API_KEY,
});
const { data, error, response } = await asiri.GET('/v1/reports/overview');
if (error) {
throw AsiriError.from(error, response.status);
}
console.log(data);The returned client follows the openapi-fetch shape: GET, POST, PUT, PATCH,
DELETE, HEAD, OPTIONS, TRACE, use, and eject.
Mutating requests
The SDK does not generate idempotency keys for you. Pass your own deterministic
Idempotency-Key on mutating requests so retries do not duplicate work:
await asiri.POST('/v1/reports/build', {
body: {
type: 'audit_summary',
format: 'json',
},
headers: {
'Idempotency-Key': crypto.randomUUID(),
},
});Custom fetch
Use fetch to inject tracing, proxying, or tests:
const asiri = createAsiriClient({
baseUrl: 'https://api.asiri.ng',
apiKey: process.env.ASIRI_API_KEY,
fetch: instrumentedFetch,
});Type exports
import type { AsiriClient, components, operations, paths } from '@asiri-ng/sdk-ts';pathsis the OpenAPI path-method-status map.componentsis the schema namespace.operationsis keyed by OpenAPI operation id.AsiriClientis the return type ofcreateAsiriClient.
For the full public endpoint list, use the generated API reference.