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.
dm.keymaps.list() and dm.keymaps.entries() act on one project and take no project argument, so set projectId on the client (or use a project-scoped key) before calling them. Without it the API answers 400, with a message naming the places a project id can go.
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: Array<Record<string, unknown>>;
dependencies: unknown[];
}>("/datamaker", { fields: template.fields, quantity: 3, seed: 42 });
const rows = result.live_data;live_data holds one object per row, keyed by field name.
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.