Generating Realistic Mock Data for API Development
Why Realistic Mock Data Matters
Generating test data with "test", "foo", "123" hides bugs that only appear
with real-world inputs — names with unicode characters, emails with plus-aliases,
phone numbers with country codes.
Realistic mock data surfaces edge cases early, makes demos more convincing, and saves hours of manual fixture creation.
What the API Generates
- People — names, emails, phone numbers, addresses (locale-aware)
- Internet — URLs, IPs, user agents, slugs
- Finance — credit card numbers (Luhn-valid but not real), IBANs
- Dates — past, future, relative ranges
- Text — lorem ipsum, sentences, paragraphs
- IDs — UUID, Nanoid, ULID
Basic Usage
curl -X POST https://api.toolkitapi.io/v1/devtools/mock-data \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"count": 5,
"schema": {
"id": { "type": "uuid" },
"name": { "type": "name" },
"email": { "type": "email" },
"score": { "type": "integer", "min": 0, "max": 100 }
}
}'
Response:
[
{ "id": "550e8400...", "name": "Elena Voss", "email": "[email protected]", "score": 74 },
...
]
Locale Support
Pass "locale": "de_DE" to generate German names and addresses,
"locale": "ja_JP" for Japanese, etc.
Seeded Randomness
Pass "seed": 42 to get deterministic output. The same seed always produces
the same data — useful for snapshot tests.
Integration with Pytest
import httpx, pytest
@pytest.fixture(scope="session")
def mock_users():
r = httpx.post(
"https://api.toolkitapi.io/v1/devtools/mock-data",
headers={"X-API-Key": API_KEY},
json={"count": 20, "schema": {"name": {"type": "name"}, "email": {"type": "email"}}, "seed": 1},
)
return r.json()
This keeps your test fixtures realistic without maintaining static JSON files.