@drttix/drt-sdk
v1.4.1
Published
DRT SDK
Keywords
Readme
DRT Public API
A unified NPM package for typed API clients generated from OpenAPI specs.
This package provides typed access to public services via fetch.
📦 Installation
npm install @drttix/drt-sdk📦 Usage
import { DRT } from "@drttix/drt-sdk";
DRT.init({
shopperGuid: "your-shopper-guid",
accountId: "your-account-id",
apiKey: "your-api-key",
});
const theme = await DRT.shopper.account.getTheme();Backend serving many shoppers/accounts
By default the SDK is a singleton: one shopperGuid/accountId for the whole
process, set once via DRT.init(). A backend that proxies calls on behalf of
many different shoppers can opt into shopperScope: 'per-request' instead,
and pass { shopperGuid, accountId } as the last argument to each shopper
call:
import { DRT } from "@drttix/drt-sdk";
DRT.init({ apiKey: "your-api-key", shopperScope: "per-request" });
await DRT.shopper.product.addProduct(productBody, {
shopperGuid: req.shopperGuid,
accountId: req.accountId,
});apiKey is still set once at init — it identifies your backend, not the
shopper. shopperGuid/accountId are the only values that become
per-request. Portal and scanner are unaffected and remain singleton-scoped.
🛠️ Local Development (Developer Only)
For SDK contributors testing against a local API server:
// Option 1: Use localhost:3000
process.env.DRT_API_LOCAL = "true";
// Option 2: Use a custom base URL
process.env.DRT_API_BASE_URL = "http://localhost:8080";
import { DRT } from "@drttix/drt-sdk";Or via command line:
# Use localhost:3000
DRT_API_LOCAL=true npx tsx test.ts
# Use custom base URL
DRT_API_BASE_URL=http://localhost:8080 npx tsx test.tsNpm run generate Npm login Increment package.lock version Npm publish
