What is API mocking?
A mock API returns predefined responses in place of a real service so that a frontend, an integration or a test suite can be built and exercised before the backend exists, or without depending on it. Good mocks reproduce the real contract — status codes, headers, pagination, error bodies — otherwise the tests pass against the mock and fail against production.
Read the guide: What is API Testing? How to Test a REST API
How to use Mock API Dataset Generator
- Describe each resource as name(count) -> parent: field, field.
- Choose the id style and optionally a seed.
- Generate, download db.json and run npx json-server db.json.
Mock API Dataset Generator features
- Related resources with consistent foreign keys (users → posts → comments)
- json-server compatible db.json with integer or UUID ids
- Field placeholders inferred from names or given explicitly
- Default shapes for users, posts, comments, products, orders, customers, invoices and tasks
- Relation table, record counts and a ready-to-run usage snippet
Mock API Dataset Generator example
Blog dataset
Input:
users(3): name, email
posts(5) -> users: title
comments(6) -> posts, users: bodyOutput:
{
"users": [{ "id": 1, "name": "Mia Bennett", "email": "mia.bennett@example.com" }, …],
"posts": [{ "id": 1, "userId": 2, "title": "Notes on granite pipelines" }, …],
"comments": [{ "id": 1, "postId": 4, "userId": 1, "body": "Thank you for contacting our support team." }, …]
}Frequently asked questions about Mock API Dataset Generator
How do I define resources and relations?
One line per resource: users(10): name, email, then posts(30) -> users: title, body. Children receive a <parent>Id foreign key that points to an existing parent record; several parents are allowed.
Is the output compatible with json-server?
Yes. Save it as db.json and run npx json-server db.json — you get REST routes with filtering (?userId=1), sorting and pagination for free. The usage panel lists the routes.
How are field values chosen?
From the field name (email, price, createdAt, isActive…) or an explicit placeholder such as price:price:5-500. Resources named users, posts, comments, products, orders or customers have sensible defaults.
How big can the dataset be?
Up to 20,000 records in total. Use a seed for reproducible datasets in tests and demos.
References
- OpenAPI SpecificationThe standard for describing REST APIs: paths, operations, parameters, schemas, responses and security schemes.
- RFC 9110: HTTP SemanticsThe meaning of HTTP methods, header fields, status codes and content negotiation, independent of the wire version.
- RFC 8288: Web LinkingThe Link header and link relations (next, prev, first, last) used for API pagination.