Use Case

Generate E-commerce Test Data with MockHero

The Problem

E-commerce applications have some of the most complex data models in web development: customers, products, categories, orders, order items, reviews, and coupons, all tightly linked with foreign keys. Building test data for this by hand means managing six or more interconnected tables where every ID has to match.

Most teams give up and test with two products and one order. The result: your product listing page has never been tested with 100 items, your cart calculations have never been verified with edge-case prices, and your admin dashboard shows empty charts.

The Solution: MockHero API

MockHero handles the relational complexity for you. Define customers, products, and orders with ref fields, and get back a complete, consistent e-commerce dataset in one call. Or use the built-in ecommerce template for zero-config data.

Quick Setup

curl -X POST https://api.mockhero.dev/api/v1/generate \
  -H "x-api-key: mh_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "template": "ecommerce",
  "scale": 3,
  "format": "json"
}'

Step-by-Step Guide

1. Use the ecommerce template

The fastest way is MockHero's built-in template. It generates customers, products, orders, and order items with correct relationships.

2. Get your MockHero API key

Sign up at mockhero.dev/sign-up.

3. Custom schema for more control

Define tables for categories, products, customers, orders, and order_items with ref fields linking order_items to both orders and products, and orders to customers.

4. Insert into your database

Use any of the database-specific guides in this blog (Supabase, Prisma, Drizzle, etc.) to insert the returned JSON.

5. Verify relationships

Check that order items reference valid orders and products, and that orders reference valid customers.

Complete Example

The template approach is a one-liner. The custom schema gives you full control over field types, counts, and table structure. Both produce relationally consistent data.

Why MockHero vs Faker / Manual Seeds

  • Built-in template — one line for a complete e-commerce dataset.
  • Multi-table refs — order_items correctly reference both orders and products.
  • Scale parameter — multiply all counts with a single number for load testing.

Get Started

Free tier, no credit card. Sign up at mockhero.dev and generate a complete e-commerce dataset in seconds.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles