Documentation
Learn how to create dynamic mock APIs with powerful templates
What are Templates?
Templates in DoMock allow you to create dynamic, realistic mock API responses without writing code. Use template variables to capture request data, generate fake data with Faker, and create repeating structures with loops.
Key Features
Template Variables
Capture query parameters, POST data, and JSON fields from requests
Faker Functions
Generate realistic fake data for names, emails, addresses, and 20+ more fields
Repeat Loops
Create arrays of data with automatic indexing and incrementing values
Quick Start
1. Basic Template Variable
Capture a query parameter from the request:
Response Templatejson
{
"userId": {{get 'id'}},
"message": "Hello, user!"
}When calling ?id=123, returns:
Actual Responsejson
{
"userId": 123,
"message": "Hello, user!"
}2. Generate Fake Data
Use Faker to create realistic mock data:
Response Templatejson
{
"name": {{faker 'person.name'}},
"email": {{faker 'email'}},
"city": {{faker 'address.city'}}
}Returns random data like:
Example Responsejson
{
"name": "Jane Smith",
"email": "jane.smith@example.com",
"city": "New York"
}3. Create Lists with Repeat
Generate arrays of data automatically:
Response Templatejson
{
"users": [
{{#repeat 5}}
{
"id": {{@index}},
"name": {{faker 'person.name'}}
}
{{/repeat}}
]
}