DEV Community

Matej Štetiar
Matej Štetiar

Posted on Originally published at jsonfabrica.com

Why API-First Wins for Test Data Generation

Plenty of test data tools are built as a UI first and an API second, if
there's an API at all. You open a dashboard, configure some fields,
click "generate," and download a file. That works fine for a one-off
demo. It falls apart the moment test data generation needs to be part of
your actual engineering workflow — running in CI, seeding a database on
every branch, or producing ten thousand records instead of ten. That's
the case for a test data generation API over a click-driven dashboard:
the primary interface is a request you can make from code, and
everything else — a UI, a CLI — is built on top of that same API.

Automation and CI integration

A UI is something a person operates. CI doesn't have a person sitting at
it. If test data generation only exists behind a login screen and a
click, it can't run as a step in your pipeline — someone has to
generate the data ahead of time, commit it, and hope it doesn't drift
from what the tests actually need. An API-first tool is just another
HTTP call your pipeline makes: fetch fresh, schema-conformant data as
part of the build, every run, with no manual step in between.

Scriptability — no clicking required

Generating test data through a UI means clicking through the same
sequence of dropdowns and fields every time you need a new batch. That's
tedious for one dataset and untenable for the dozens of shapes a real
test suite needs — different entity types, different edge cases,
different volumes. An API call is a script. Write it once, parametrize
it, and reuse it for every collection you need, without a human
repeating the same clicks.

Wiring a test data generation API into pipelines and seed scripts

Seed scripts are code that runs at a specific point in a workflow —
before a test suite, on container startup, in a migration. They need a
function call or an HTTP request they can invoke programmatically, not
a browser tab. With a test data generation API, "seed the dev database
with realistic orders" is a line in a setup script, not a manual task
someone has to remember to do before each demo or test run.

Language and framework agnostic

A UI locks you into whatever the tool's frontend supports. An HTTP API
doesn't care what you're writing — a Python test suite, a Go seed
script, a Node.js CI job, or a shell script with curl, can all call
the same endpoint the same way. JsonFabrica is built this way
deliberately: the API is the product, so it works identically whether
you're calling it from a Jest test, a Django management command, or a
Makefile target. You're not choosing a data tool that happens to support
your stack; you're using a data tool that has no opinion about your
stack at all.

Versionable, reviewable requests

A UI configuration lives in a database somewhere, edited by clicking
through screens, with no diff and no history beyond an audit log if
you're lucky. An API request is a payload — JSON, typically — that you
can commit to a repo, put next to your test suite, and review in a pull
request like any other code change. When someone adjusts the shape of
generated test data, that change shows up as a diff, gets reviewed, and
has a commit message explaining why. Config-as-code isn't a nice-to-have
here, it's what makes test data changes auditable instead of invisible.

Scaling to bulk and synthetic data needs

Clicking "generate" in a UI is fine for ten records. It is not how
anyone produces the ten thousand records needed to load-test a database
or populate a staging environment with realistic volume. An API call
takes a count parameter. Generating 50,000 records programmatically is
the same amount of effort as generating 50 — one request, one number
changed. That gap is exactly where UI-only and template-only tools
without an API stop being useful, and it's exactly where an API-first
tool keeps working.

FAQ

What is a test data generation API, and how is it different from a UI tool?
A test data generation API is an HTTP endpoint your code calls to get
structured, schema-conformant data back, instead of a dashboard a person
clicks through. That makes it callable from CI pipelines, seed scripts, and
AI agents without a human in the loop, which a UI-only tool can't support.

Can I call a test data generation API with curl or from any language?
Yes — it's a plain HTTP endpoint, so anything that can make an HTTP
request, including curl, a Python test suite, a Go seed script, or a
Node.js CI job, can call it the same way, with no client library or
dashboard required.

How do I generate bulk test data instead of a handful of records?
Pass a count parameter on the generation request. Generating 50,000
records programmatically is the same amount of effort as generating 50 —
one request, one number changed, instead of clicking "generate" repeatedly
in a UI.

Can I run test data generation as part of a CI pipeline?
Yes — that's the core use case for an API-first tool. Because the
generation call is just an HTTP request, it can run as a step in a CI
pipeline or a container startup script, fetching fresh, schema-conformant
data on every run with no manual export step.

The takeaway

A UI is a convenience layer, and a good one is worth having. But it
can't be the foundation, because automation, CI, seed scripts, and bulk
generation all need something a browser click can't provide: a
programmatic, scriptable, versionable interface. Build the API first and
the UI can sit on top of it. Build the UI first and the API — if it
ever arrives — is usually an afterthought that doesn't cover everything
the UI does. JsonFabrica is built API-first for exactly this reason:
structured, schema-conformant data, generated by a request you can
script, version, and run anywhere.

Top comments (0)