Skip to main content

SDK Reference

Ductape provides server SDKs for TypeScript and NestJS.

Install​

npm install @ductape/sdk@latest

Current versions​

LanguagePackage / moduleVersion
TypeScript@ductape/sdkInstall with the latest dist-tag
NestJS@ductape/nestjsInstall with the latest dist-tag

Changelog: TypeScript.

Check the registry rather than copying a stale pinned version:

npm install @ductape/sdk@latest

Node module interoperability​

The current package is compiled as CommonJS. Native Node ESM may expose the CommonJS namespace as the default value, so normalize it explicitly:

// Native Node ESM
import DuctapeModule from '@ductape/sdk';
const Ductape = DuctapeModule.default ?? DuctapeModule;
// CommonJS
const Ductape = require('@ductape/sdk').default;

Both forms are covered by the package interoperability regression check. Do not use an unnormalized default import in native ESM until the package publishes a dedicated ESM export.

Documentation by language​

LanguagePackage / moduleRepo docs
TypeScript@ductape/sdkThis site (Backend sections)
NestJS@ductape/nestjsNestJS integration on this site

Runtime defaults (TypeScript)​

Set product and env on the Ductape constructor only (not via configure(), env vars, or product.init). Omitted fields on connect() and queries inherit from the constructor or active connection.

const ductape = new Ductape({
accessKey: process.env.DUCTAPE_ACCESS_KEY!,
product: 'my-product',
env: 'dev',
});
await ductape.databases.connect({ database: 'users-db' });
await ductape.api.run({
app: 'stripe',
action: 'create-charge',
input: { amount: 1000, currency: 'usd' },
});

NestJS​

For NestJS apps, use @ductape/nestjs — modules, injectable handles, and decorators such as @Api, @Database, @Storage, and @Webhook. See the NestJS integration guide. NestJS examples are TypeScript only (not included in the multi-language SDK tabs above).

npm install @ductape/nestjs@latest @ductape/sdk@latest

Quickstart​