Skip to navigation
SDKs and toolsJavaScript and TypeScript SDK

JavaScript and TypeScript SDK

Install the versioned SDK and load DEFDEX_API_KEY privately. Node.js 22+ is required; TypeScript declarations are included.

import { DefDexClient, DefDexError } from '@defdex/sdk';
const api = new DefDexClient();
try {
const page = await api.list('organizations', {
filters: { type: 'agency' }, limit: 25
});
for (const record of page.data) {
console.log(record.attributes.id, record.attributes.name);
}
} catch (error) {
if (error instanceof DefDexError) {
console.error(error.status, error.requestId, error.retryAfter);
} else {
throw error;
}
}

Methods

MethodResult
datasets()Runtime catalog
list(dataset, {limit, cursor, q, filters}){data, next_cursor, build_id} and optional truncated
get(dataset, recordId){data, build_id}
awards({limit, cursor, q, company_id})Convenience award page
award(awardId)Convenience award detail
usage()Account activity summary
submitCorrection(proposal, idempotencyKey)Proposal receipt directly
corrections({limit, cursor})Own proposal page
correction(id)Own proposal directly

The client URL-encodes IDs and JSON-encodes filters. Keep record_id unchanged. Type declarations describe the generic transport; use each collection’s reference for its attributes. Correction methods require the matching scopes.

Configuration and failures

new DefDexClient({apiKey, baseUrl, timeoutMs, fetch}) accepts optional settings. The default timeout is 30,000 ms and the default transport is globalThis.fetch. Do not include credentials, query parameters or fragments in baseUrl.

DefDexError exposes status, requestId and retryAfter when available; transport failures use status 0. Clients do not retry automatically. Apply the bounded policy in errors. An aborted request is not proof that a correction was never received; reuse its idempotency key when retrying.

Keep decimal money as strings or use an exact decimal library. JavaScript Number can lose cents and large integer precision. Check nulls before performing arithmetic.