Skip to content

TypeScript SDK

The TypeScript / Node.js SDK is @automators/datamaker.

Install

Terminal window
npm install @automators/datamaker
# or: pnpm add / yarn add / bun add @automators/datamaker

Authenticate

import { DataMaker } from "@automators/datamaker";
const datamaker = new DataMaker({ apiKey: process.env.DM_API_KEY });

Define a template and generate

A Template is a name, a quantity, and a list of fields. generate() resolves to a fetch Response, so call .json() for the rows:

import { DataMaker, type Template } from "@automators/datamaker";
const datamaker = new DataMaker({ apiKey: process.env.DM_API_KEY });
const template = {
name: "Customer",
quantity: 100,
fields: [
{ name: "first_name", type: "First Name" },
{ name: "last_name", type: "Last Name" },
{
name: "email",
type: "Derived",
options: { value: "{{first_name}}.{{last_name}}@example.com" },
},
],
} satisfies Template;
const res = await datamaker.generate(template);
const rows = await res.json();

Generate from an existing template

If the template already lives in your account, generate by id:

const res = await datamaker.generateFromTemplateId("<template-id>", 100);
const rows = await res.json();

Export

Push generated rows into a target:

// To a database connection (by connection id + table)
await datamaker.exportToDB("<connection-id>", "customers", rows);
// To a REST API (a saved endpoint name, or a CustomEndpoint object)
await datamaker.exportToApi("<endpoint>", rows);

See Connections for configuring the targets.

Types

The SDK exports the types you need to build templates and endpoints:

import type {
DataMaker,
Template,
Fields,
CustomEndpoint,
Data,
ClientOptions,
} from "@automators/datamaker";

Source

  • npm: @automators/datamaker
  • The package README and dist/index.d.ts are the authoritative, current API surface.