TypeScript SDK
Use the current official TypeScript and JavaScript SDK.
Install the official package, @automators/datamaker. This guide targets version 1.1.0, which uses resource clients and returns parsed JSON. Examples for the older generateFromTemplateId() API do not apply to this release.
npm install @automators/datamaker@1.1.0Use Node.js 18 or later with fetch available. Keep privileged API keys in server-side code.
Authenticate and list resources
import { DataMaker } from "@automators/datamaker";
const dm = new DataMaker({
apiKey: process.env.DATAMAKER_API_KEY,
baseURL: process.env.DATAMAKER_API_URL,
projectId: process.env.DATAMAKER_PROJECT_ID,
});
const templates = await dm.templates.list();
console.log(templates.map(template => template.name));apiKey and baseURL fall back to DATAMAKER_API_KEY and DATAMAKER_API_URL. The default host is https://api.datamaker.automators.com. Optional projectId and teamId set scope headers; they do not grant access beyond the key's scope.
Resource clients
| Client | Methods |
|---|---|
dm.projects | list, get, create, update, delete |
dm.templates | list, get, create, update, delete |
dm.sets | list, get, create, update, delete, save |
dm.keymaps | list, put, lookup, entries, delete |
dm.maskingPolicies | list, get, create, update, delete |
dm.plans | list, get, update, delete |
These methods return data directly: do not call .json() on the result.
Generate through the transport
For routes without a resource wrapper, use dm.http. This example uses a saved template and defines the response shape explicitly:
const template = await dm.templates.get("<template-id>");
const result = await dm.http.post<{
live_data: Record<string, unknown[]>;
dependencies: Record<string, unknown>;
}>("/datamaker", { fields: template.fields, quantity: 3, seed: 42 });
const names = Object.keys(result.live_data);
const lengths = new Set(names.map(name => result.live_data[name]!.length));
if (lengths.size > 1) throw new Error("Generation returned unequal column lengths");
const count = names.length ? result.live_data[names[0]!]!.length : 0;
const rows = Array.from({ length: count }, (_, i) =>
Object.fromEntries(names.map(name => [name, result.live_data[name]![i]])),
);Inspect the generated values before saving or exporting. To save a small reusable set:
const saved = await dm.sets.save({ name: "Regression customers", data: rows });Errors
Non-2xx responses throw DataMakerError, with status, body and url. The transport does not automatically retry writes.
import { DataMakerError } from "@automators/datamaker";
try {
await dm.sets.delete("<set-id>");
} catch (error) {
if (error instanceof DataMakerError && error.status === 409) {
console.error("The set is locked; review its state before deleting it.");
} else {
throw error;
}
}See the official SDK source for generated types and the complete method signatures, and REST API for route behavior.