# SDK API

> Every function the Node.js SDK exports — generate, prove, inspect, read a file, manage packs — with what each returns.

Section: Reference · Type: reference · Last updated: 2026-09-17

The Node.js SDK is the same engine the CLI and the MCP server use, as a CommonJS module; the WebAssembly instantiates synchronously when it is required, so every call is an ordinary synchronous function.

## The functions

- generate(recipe, { rows, seed, scenario }) — one table (the first entity) as rows.
- generateAll(recipe, { rows, seed, scenario }) — every table; rows[0] of each is the header.
- generateNested(recipe, { root }) and generateSlice(recipe, { root, keepN }) — a nested document from a root entity, or a referential slice of N root rows with everything they point at.
- exportFixedWidth(recipe, opts) — byte-positional output for recipes that declare a fixed-width layout.
- prove(recipe, { rows, seed, scenario }) — the proof report: passed, realism, privacy, receipt.
- scoreRealism(recipe, opts), privacyScore(recipe, opts), sampleWorld(recipe, { seed }) — inspect a recipe without keeping the data.
- deriveGraph(bytes, format) — reads a CSV, XLSX, JSON or XML file for its shape and produces a draft recipe.
- recipeLeakFindings(recipe) — prove a recipe is data-free; this is what worklens check runs.
- listDomainPacks(), getDomainPack(id), registerPack(pack), packRegistry(), registeredLocales() — packs. registerPack takes a locale, type or format pack, refuses one that carries code, and registered packs are process-local.
- buildReceipt, verifyReceipt, computeAuditHash, version() — receipts (verifyReceipt recomputes the content hash) and the engine version.

## Common questions

**Is it asynchronous?**

No. The engine loads at require time and every call is synchronous, which keeps a build script or a test fixture simple. A million-row run blocks for as long as it takes.

**What shape do tables come back in?**

generateAll returns { tables: [{ entity, rows }] } where rows is an array of arrays and rows[0] is the header. generate returns one table for the first entity.

## Related

- [Examples](https://theworklens.com/docs/sdk/examples): Three short Node.js scripts, each run in this repository: generate every table, prove the run, and check that two runs are identical.
- [Runtimes](https://theworklens.com/docs/sdk/runtimes): Which languages and runtimes exist today: Node.js, the browser via the studio, and the MCP server that wraps the same module.
- [Generate](https://theworklens.com/docs/cli/generate): worklens generate — recipe → data. Read from the CLI’s own header, with every option it accepts.

_← Previous: [Recipe schema](https://theworklens.com/docs/reference/recipe-schema)_

_Canonical: https://theworklens.com/docs/reference/sdk-api · This copy: https://theworklens.com/docs/reference/sdk-api.md_
