SDK (TypeScript)
@tridafactory/sdk is the TypeScript client, generated from the OpenAPI contract: its types cannot drift from the API. It carries the platform's rules so you do not have to:
- every call is bounded to 10 seconds;
- a call is retried, with jitter, only if it is safe to repeat: a read, or a write that carries an
Idempotency-Key; - every write gets an
Idempotency-Keyautomatically, one per logical call, reused by each retry (idempotencyKey: falseremoves it, and the call is then never retried); - an error from the platform is typed by its stable code (
TridaApiError), a network failure or a timeout byTridaNetworkError.
Install
Published on GitHub Packages. Create a GitHub token with the read:packages scope and add to your .npmrc:
@tridafactory:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN_READ}
bun add @tridafactory/sdk
Use
import { createClient, TridaApiError } from '@tridafactory/sdk';
const trida = createClient({ baseUrl: 'https://api.trida.lu', apiKey: process.env.TRIDA_API_KEY! });
try {
await trida.projects.me();
} catch (e) {
if (e instanceof TridaApiError && e.code === 'API_KEY_REVOKED') {
/* ... */
}
}
What it covers
| Call | Route |
|---|---|
trida.projects.me() |
GET /core/v1/projects/me |
trida.webhookEndpoints.create / list / delete |
/core/v1/webhook-endpoints |
trida.webhookEndpoints.rotateSecret / retirePreviousSecret / test |
/core/v1/webhook-endpoints/{id}/... |
trida.events.replay(eventId) |
POST /core/v1/events/{id}/replay |
trida.usage.get({ from, to }) |
GET /core/v1/usage |
trida.subjects.erase(subject) |
POST /core/v1/subjects/erase |
trida.request(method, path, init) |
any route, with the same rules |
verifyWebhook(rawBody, headers, secrets) |
verifies a webhook signature, see Webhooks |
The SDK covers what the API reference describes. A Dart client for Flutter apps will follow.