Collection Overview
Collections are the core organizational unit in DoMock. Learn how to structure and manage your mock API endpoints effectively.
What is a Collection?
A Collection is a group of related mock API endpoints within a Workspace. Collections help you organize your mock APIs by feature, service, or any logical grouping that makes sense for your project.
Think of Collections as:
- • A microservice or API module (e.g., "User Service", "Payment API")
- • A feature domain (e.g., "Authentication", "Orders", "Products")
- • A version of your API (e.g., "API v1", "API v2")
- • Any logical grouping that helps your team organize endpoints
Collection Structure
Each Collection contains endpoints with configurable Responses. A Response defines how your mock API behaves when called.
Workspace
Top-level container for all your mock APIs
Collection
Group of related API endpoints
Response Components
Each endpoint in a Collection has a Response configuration with three main components:
Templates
Dynamic response body generation with template syntax. Use faker functions, repeat blocks, and variables to create realistic mock data.
{
"user": {
"id": "{{faker 'string.uuid'}}",
"name": "{{faker 'person.fullName'}}",
"email": "{{faker 'internet.email'}}"
}
}Rules
Conditional logic to return different responses based on request data. Check query parameters, headers, body, cookies, and form data.
Query Parameter | userId | = Match | 123
HTTP Header | Authorization | ✓ Has value
JSON Body | user.role | = Match | adminHeaders
HTTP response headers for Content-Type, CORS, caching, authentication, and custom headers. Configure how clients should handle your responses.
Content-Type: application/json
Access-Control-Allow-Origin: *
Cache-Control: no-cache
X-API-Version: 2.0Common Use Cases
Frontend Development
Build UI components before the backend API is ready. Create realistic mock data that matches your API specification.
API Testing
Test edge cases, error scenarios, and different response conditions without modifying your backend.
API Documentation
Create interactive examples for API documentation. Let developers test API calls with realistic responses.
Third-Party API Simulation
Mock external APIs to avoid rate limits, reduce costs, or work offline during development.
Best Practices
📁 Organize by Domain
Group related endpoints in Collections based on features or services. This makes it easier to find and manage endpoints.
✅ Match Real API Structure
Design your Collections to mirror your actual API structure. This makes transitioning from mock to real API seamless.
⚡ Use Realistic Data
Leverage faker functions in Templates to generate realistic data. This helps catch issues that only appear with real-world data patterns.
🎯 Test Edge Cases
Use Rules to create multiple response scenarios for the same endpoint. Test success, error, and edge cases without backend changes.
Next Steps
Explore Response configuration options:
- → Templates - Generate dynamic response bodies with template syntax
- → Rules - Add conditional logic to return different responses
- → Headers - Configure HTTP response headers