Skip to Content
SdksTypeScript SDK

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 into develop.

What it gives you

  • Fully typed request / response models, generated from the public OpenAPI 3.1 document.
  • A thin openapi-fetch client.
  • Bearer token injection when apiKey is configured.
  • AsiriError.from() for parsing API error envelopes.
  • Type re-exports for paths, components, and operations.

Installation

pnpm add @asiri-ng/sdk-ts # or npm install @asiri-ng/sdk-ts

The 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';
  • paths is the OpenAPI path-method-status map.
  • components is the schema namespace.
  • operations is keyed by OpenAPI operation id.
  • AsiriClient is the return type of createAsiriClient.

For the full public endpoint list, use the generated API reference.