Skip to content
tutorial

Generate typed mock data from any JSON schema with one API call

| 5 min read
Spreadsheet with user data rows
Photo by Mika Baumeister on Unsplash

Every frontend developer, QA engineer, and backend builder runs into the same friction: you need realistic data to test a UI, seed a database, or verify an API integration, but writing seed scripts by hand is tedious and the results look fake. Hardcoded "John Doe" entries across every table. Identical timestamps. Prices that are always 9.99.

The Botoi mock data generator API takes a different approach. You define a JSON schema describing the shape of the data you want, and the API returns an array of records that match that shape with randomized, realistic values. One HTTP call. No libraries to install, no faker setup, no seed files to maintain.

How it works: define a schema, get data back

The endpoint accepts a standard JSON Schema object and a count parameter. It returns an array of generated records matching your schema, with types, formats, and constraints respected.

Request

curl -X POST https://api.botoi.com/v1/mock/generate \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "properties": {
        "id": { "type": "integer" },
        "name": { "type": "string" },
        "email": { "type": "string", "format": "email" },
        "age": { "type": "integer", "minimum": 18, "maximum": 80 }
      },
      "required": ["id", "name", "email"]
    },
    "count": 5
  }'

Response

{
  "success": true,
  "data": {
    "data": [
      { "id": 42, "name": "Sarah Chen", "email": "sarah@example.com", "age": 34 },
      { "id": 87, "name": "Marcus Johnson", "email": "marcus.j@example.com", "age": 28 },
      { "id": 15, "name": "Priya Patel", "email": "priya.patel@example.com", "age": 51 },
      { "id": 63, "name": "David Kim", "email": "dkim@example.com", "age": 45 },
      { "id": 91, "name": "Elena Rodriguez", "email": "elena.r@example.com", "age": 22 }
    ],
    "count": 5
  }
}
Data visualization dashboard with user metrics
Photo by Mika Baumeister on Unsplash

The schema follows JSON Schema conventions. Set type to control the data type, format for hints like "email" or "date-time", and minimum/maximum for numeric ranges. The required array tells the generator which fields must appear in every record.

Example: e-commerce orders

Testing an order management dashboard? You need orders with line items, prices in cents, and status values. Here is a schema for that.

curl -X POST https://api.botoi.com/v1/mock/generate \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string" },
        "customer_email": { "type": "string", "format": "email" },
        "total_cents": { "type": "integer", "minimum": 500, "maximum": 50000 },
        "currency": { "type": "string" },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "sku": { "type": "string" },
              "quantity": { "type": "integer", "minimum": 1, "maximum": 10 },
              "price_cents": { "type": "integer", "minimum": 100, "maximum": 9999 }
            }
          }
        },
        "status": { "type": "string" }
      },
      "required": ["order_id", "customer_email", "total_cents", "currency"]
    },
    "count": 3
  }'

Response (first record shown):

{
  "success": true,
  "data": {
    "data": [
      {
        "order_id": "ord_7f3a2b",
        "customer_email": "lena.watts@example.com",
        "total_cents": 12450,
        "currency": "usd",
        "items": [
          { "sku": "TSHIRT-BLK-M", "quantity": 2, "price_cents": 2999 },
          { "sku": "HOODIE-GRY-L", "quantity": 1, "price_cents": 6452 }
        ],
        "status": "fulfilled"
      }
    ],
    "count": 3
  }
}

Each order gets a different ID, email, total, and set of line items. The minimum and maximum constraints on quantity and price_cents keep values within realistic bounds.

Example: blog posts

Building a CMS or a blog listing page? Generate posts with titles, slugs, authors, timestamps, and tags.

curl -X POST https://api.botoi.com/v1/mock/generate \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "properties": {
        "id": { "type": "integer" },
        "title": { "type": "string" },
        "slug": { "type": "string" },
        "author": { "type": "string" },
        "published_at": { "type": "string", "format": "date-time" },
        "tags": {
          "type": "array",
          "items": { "type": "string" }
        },
        "excerpt": { "type": "string" }
      },
      "required": ["id", "title", "slug", "author"]
    },
    "count": 10
  }'

Ten blog posts with different authors, titles, tag arrays, and publication dates. Enough to test pagination, filtering, and sorting logic without writing a single fixture by hand.

Seed a database in one script

Combine the mock data generator with a database client and you have a complete seed script. Here is a bash version that inserts 50 users into a PostgreSQL database:

#!/bin/bash
set -euo pipefail

API="https://api.botoi.com/v1/mock/generate"
DB_URL="postgresql://localhost:5432/myapp_dev"

echo "Generating 50 user records..."
USERS=$(curl -s -X POST "$API" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "email": { "type": "string", "format": "email" },
        "age": { "type": "integer", "minimum": 18, "maximum": 80 },
        "signup_date": { "type": "string", "format": "date-time" }
      },
      "required": ["name", "email"]
    },
    "count": 50
  }')

echo "$USERS" | jq -c '.data.data[]' | while read -r row; do
  NAME=$(echo "$row" | jq -r '.name')
  EMAIL=$(echo "$row" | jq -r '.email')
  AGE=$(echo "$row" | jq -r '.age')
  SIGNUP=$(echo "$row" | jq -r '.signup_date')

  psql "$DB_URL" -c "INSERT INTO users (name, email, age, signup_date) VALUES ('$NAME', '$EMAIL', $AGE, '$SIGNUP');"
done

echo "Seeded 50 users into $DB_URL"

The script generates 50 unique user records, parses each one with jq, and inserts them one at a time. For larger datasets, pipe the output into a bulk COPY command or a batch insert.

Node.js version

If your stack is JavaScript or TypeScript, call the API with fetch and pass the results to your ORM:

const API = "https://api.botoi.com/v1/mock/generate";

async function generateMockData(schema, count) {
  const response = await fetch(API, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ schema, count }),
  });
  const result = await response.json();
  return result.data.data;
}

const userSchema = {
  type: "object",
  properties: {
    name: { type: "string" },
    email: { type: "string", format: "email" },
    role: { type: "string" },
    created_at: { type: "string", format: "date-time" },
  },
  required: ["name", "email", "role"],
};

const users = await generateMockData(userSchema, 25);
console.log(users);

// Pass directly to your ORM
// await db.insert(usersTable).values(users);

The generateMockData function is reusable. Call it with any schema and count, then insert the results into Drizzle, Prisma, Knex, or whichever ORM you use.

Why use an API instead of a library?

  • No dependencies. You don't need to install faker.js, factory_bot, or any language-specific library. A single HTTP call works from any language, shell script, or CI pipeline.
  • Schema-driven. The same JSON Schema you use for validation can drive your test data. Change the schema, and the generated data changes with it. No factory definitions to keep in sync.
  • Consistent format. Every team member gets data from the same source. No "works on my machine" differences between hand-written fixtures.
  • Shareable. Copy the curl command into a Slack thread, a README, or a CI config. Anyone can run it without installing anything.

Practical tips

  • Save responses as fixture files. Run the API once, save the JSON output to fixtures/users.json, and load that file in your tests. This keeps tests deterministic and avoids network calls during test runs.
  • Use format hints. Setting "format": "email" produces email-shaped strings. Other useful formats include "date-time", "uri", and "uuid".
  • Nest objects for complex data. The schema supports objects within objects and arrays of objects. Model your real database relations by nesting an address object inside a customer object.
  • Combine with other Botoi endpoints. Generate mock users, then pass each email to /v1/disposable-email/check to test your email validation flow end to end.

Frequently asked questions

Do I need an API key to use the mock data generator API?
No. Anonymous access is available at 5 requests per minute with IP-based rate limiting. For higher throughput, sign up for a free API key at botoi.com/api.
What JSON schema features does the endpoint support?
The endpoint supports standard JSON Schema types (string, integer, number, boolean, object, array), format hints like "email" and "uri", min/max constraints for numbers, and required field declarations. Nested objects and arrays of objects work as expected.
How many records can I generate in a single request?
Set the "count" field in the request body to the number of records you want. The endpoint supports generating up to 100 records per call.
Is the generated data deterministic?
No. Each request produces different random values. If you need reproducible data, save the response to a fixture file and load it in your tests.
Can I use this to seed a production database?
The endpoint generates fake data for development and testing purposes. The names, emails, and other values are fictional. Do not use generated data as production records.

Try this API

Random Data API — interactive playground and code examples

More tutorial posts

Start building with botoi

150+ API endpoints for lookup, text processing, image generation, and developer utilities. Free tier, no credit card.