Building modern web applications often requires a backend API, but what do you do when the backend isn't ready yet? Enter the Mock API Generator a powerful tool that lets you create custom REST API endpoints with realistic data, IP restriction, and simulation features. In this comprehensive guide, we'll explore how to use our Mock API Generator to supercharge your development workflow.
๐ What is a Mock API Generator?
A Mock API Generator is a tool that creates simulated REST API endpoints that behave like real APIs but return fake (yet realistic) data. This is incredibly useful for:
- Frontend developers who need to build UIs before the backend is ready
- QA engineers who need predictable API responses for testing
- Demo applications that need realistic data without a real database
- Prototyping new features without backend investment
- Training new developers on API integration
Our Mock API Generator takes this a step further with IP restriction, allowing you to create secure endpoints that only respond to specific IP addresses perfect for private testing and team collaboration.
๐ The Power of IP Restriction
Unlike other mock API tools, our generator includes a built-in IP restriction feature. This means you can:
- Create private endpoints that only your team can access
- Test IP-based access control before implementing it in production
- Secure sensitive mock data from unauthorized access
- Simulate production environments where IP whitelisting is common
How IP Restriction Works
When you enable IP restriction on a mock endpoint:
- The system checks the incoming request's IP address
- If the IP is in your allowed list, the request proceeds normally
- If the IP is NOT allowed, the server returns a
403 Forbiddenerror
// Response when IP is NOT allowed (403 Forbidden)
{
"error": "Forbidden",
"message": "Your IP address is not authorized to access this endpoint",
"your_ip": "192.168.1.100",
"allowed_ips": ["10.0.0.1", "203.0.113.50"],
"status": 403
}
๐ Step-by-Step: Creating Your First Mock Endpoint
Step 1: Configure Your Endpoint
Start by setting up the basic endpoint configuration:
- Endpoint Path: Define your API path (e.g.,
/api/users) - HTTP Method: Choose GET, POST, PUT, PATCH, or DELETE
- Status Code: Set the HTTP response status (200, 201, 404, etc.)
// Example configuration
Endpoint Path: /api/users
HTTP Method: GET
Status Code: 200
Step 2: Create Your Response Template
Define the JSON response your endpoint will return. You can use plain JSON or leverage our template variables for dynamic data:
{
"success": true,
"data": [
{
"id": "{{uuid}}",
"firstName": "{{firstName}}",
"lastName": "{{lastName}}",
"email": "{{email}}",
"phone": "{{phone}}",
"company": "{{company}}",
"jobTitle": "{{jobTitle}}",
"avatar": "{{avatar}}",
"createdAt": "{{isoDate}}"
}
],
"meta": {
"total": "{{number:100}}",
"page": 1,
"perPage": 10
}
}
Step 3: Set Number of Records
Use the Number of Records field to specify how many items should be generated in your response array. Set it to 5, 10, 50, or even 100 records each with unique randomized data!
Step 4: Configure Simulation Options (Optional)
To make your testing more realistic, configure simulation options:
- Latency: Add a delay (0-5000ms) to simulate network conditions
- Error Rate: Set a percentage chance of returning a 500 error
These features help you test loading states, error handling, and user experience under various conditions.
Step 5: Enable IP Restriction (Optional)
For secure endpoints:
- Your public IP is auto-detected and shown on the page
- Click "Add My IP" to whitelist your current IP
- Check "Enable IP Restriction" to activate the feature
- Add multiple IPs by separating them with commas
// Example: Multiple allowed IPs
192.168.1.1, 10.0.0.1, 203.0.113.50, 45.33.32.156
Step 6: Create the Server Endpoint
Click "Create Server Endpoint" to generate your mock API. You'll receive a unique URL like:
https://jsonformatterspro.com/api/mock/abc12xyz/
This URL is immediately usable in your application, Postman, curl, or any HTTP client!
๐ Template Variables Reference
Our Mock API Generator supports a rich set of template variables that generate realistic fake data on each request:
| Variable | Description | Example Output |
|---|---|---|
{{uuid}} | Unique identifier | a1b2c3d4-e5f6-4789-abcd-123456789012 |
{{firstName}} | Random first name | Emma, Liam, Olivia |
{{lastName}} | Random last name | Smith, Johnson, Williams |
{{fullName}} | Full name combination | Emma Johnson |
{{email}} | Email address | emma.johnson@gmail.com |
{{phone}} | Phone number | +1 555-123-4567 |
{{company}} | Company name | TechCorp, Innovate Inc |
{{jobTitle}} | Job title | Software Engineer |
{{city}} | City name | New York, San Francisco |
{{country}} | Country name | United States, Canada |
{{isoDate}} | ISO 8601 date | 2024-06-15T14:30:00 |
{{boolean}} | Random true/false | true, false |
{{number:100}} | Random number (0-100) | 42, 73, 15 |
{{avatar}} | Avatar URL | https://i.pravatar.cc/150?img=42 |
{{imageUrl}} | Random image URL | https://picsum.photos/seed/123/400/300 |
{{zipCode}} | ZIP/Postal code | 10001, 90210 |
๐ Real-World Response Examples
Example 1: User List API
// Template
{
"success": true,
"data": [
{
"id": "{{uuid}}",
"name": "{{fullName}}",
"email": "{{email}}",
"avatar": "{{avatar}}",
"isActive": {{boolean}}
}
]
}
// Generated Response (5 records)
{
"success": true,
"data": [
{
"id": "8f2e9a4b-c3d1-4e5f-a6b7-c8d9e0f1a2b3",
"name": "Emma Johnson",
"email": "emma.johnson@gmail.com",
"avatar": "https://i.pravatar.cc/150?img=23",
"isActive": true
},
{
"id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"name": "Liam Williams",
"email": "liam.williams@outlook.com",
"avatar": "https://i.pravatar.cc/150?img=45",
"isActive": false
},
// ... 3 more records
]
}
Example 2: E-commerce Products API
{
"products": [
{
"sku": "{{uuid}}",
"name": "Premium {{company}} Widget",
"price": {{number:500}},
"inStock": {{boolean}},
"image": "{{imageUrl}}",
"createdAt": "{{isoDate}}"
}
],
"pagination": {
"page": 1,
"totalItems": {{number:1000}},
"hasMore": true
}
}
Example 3: Authentication Response
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.{{uuid}}",
"user": {
"id": "{{uuid}}",
"email": "{{email}}",
"firstName": "{{firstName}}",
"lastName": "{{lastName}}"
},
"expiresAt": "{{isoDate}}"
}
๐งช Testing Your Mock Endpoints
Using cURL
# Simple GET request
curl https://jsonformatterspro.com/api/mock/abc12xyz/
# POST request with data
curl -X POST https://jsonformatterspro.com/api/mock/abc12xyz/ -H "Content-Type: application/json" -d '{"name": "Test User"}'
Using JavaScript (Fetch)
// In your React/Vue/Angular app
fetch('https://jsonformatterspro.com/api/mock/abc12xyz/')
.then(response => response.json())
.then(data => {
console.log('Mock API Response:', data);
setUsers(data.data);
})
.catch(error => console.error('Error:', error));
Using Axios
import axios from 'axios';
const getMockUsers = async () => {
const response = await axios.get('https://jsonformatterspro.com/api/mock/abc12xyz/');
return response.data;
};
โก Testing Latency and Error Handling
Our Mock API Generator lets you simulate real-world conditions:
Latency Simulation
Set latency to test loading states in your application. For example:
- 0ms: Instant response (ideal conditions)
- 500ms: Typical API response time
- 2000ms: Slow network simulation
- 5000ms: Very slow / timeout edge case testing
Error Rate Simulation
Set an error rate percentage to test your app's error handling:
- 0%: Always success
- 10%: Occasional failures (realistic)
- 50%: Frequent failures (stress testing)
- 100%: Always fails (error handling verification)
// Error response (when error simulation triggers)
{
"error": "Internal Server Error",
"message": "Simulated server error (based on configured error rate)",
"status": 500
}
๐พ Managing Your Endpoints
All your created endpoints are saved and visible in the "My Saved Endpoints" section. You can:
- Copy URL: Quick copy to clipboard
- Edit: Update name, IP restriction settings, and allowed IPs
- Delete: Remove endpoints you no longer need
- View Stats: See how many times each endpoint was accessed
Your endpoints persist on our servers and are associated with your IP address, so you'll see them even after refreshing the page.
๐ IP Restriction Best Practices
For Development Teams
- Collect the public IP addresses of all team members
- Add all IPs to the allowed list (comma-separated)
- Share the endpoint URL with your team
For Production-like Testing
- Use IP restriction to simulate production access control
- Test your application's handling of 403 responses
- Verify your error messages and redirects work correctly
For Personal Use
- Click "Add My IP" to auto-add your current IP
- Enable IP restriction to protect your mock data
- Remember to update the IP if you change networks!
๐ CORS Support
All mock endpoints include proper CORS headers, making them usable from any domain:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
This means you can call your mock endpoints from:
- Localhost development servers
- Deployed applications on any domain
- CodePen, JSFiddle, and other online editors
- Mobile applications
๐ง Common Use Cases
1. Frontend Development Before Backend
Start building your UI immediately using mock APIs that match your planned backend structure. When the real backend is ready, simply swap the endpoint URLs.
2. UI/UX Prototyping
Create realistic prototypes with dynamic data to demonstrate to stakeholders. The random data makes each demo feel fresh and real.
3. Automated Testing
Use mock endpoints in your Jest, Cypress, or Playwright tests for consistent, reliable test data.
4. Demo Applications
Build portfolio projects or demos that look real without needing a production database.
5. Learning API Integration
New developers can practice API integration without setting up a backend server.
๐ Why Choose Our Mock API Generator?
| Feature | Our Tool | Others |
|---|---|---|
| IP Restriction | โ | โ |
| No Signup Required | โ | โ |
| Multiple Record Generation | โ | Limited |
| Latency Simulation | โ | Some |
| Error Rate Simulation | โ | Rare |
| Edit Saved Endpoints | โ | โ |
| CORS Enabled | โ | โ |
| 100% Free | โ | Often limited |
๐ Get Started Now
Ready to create your first mock endpoint? Here's what to do:
- Configure your endpoint path and method
- Create a response template with dynamic variables
- Set the number of records you need
- Optionally enable IP restriction for security
- Click "Create Server Endpoint" and copy your URL
- Use the URL in your application immediately!
Try the Mock API Generator Now โ
๐ Related Tools You Might Like
- API Response Tester Test any API endpoint and view responses
- Swagger/OpenAPI Viewer Visualize your API documentation
- JSON Diff Tool Compare two JSON documents
- Dummy JSON Generator Generate sample JSON data
- JSON Formatter Format and validate JSON data