Developer Tools

Complete Guide to Mock API Generator with IP Restriction

๐Ÿ“… December 13, 2025 โฑ๏ธ 10 min read ๐Ÿ‘๏ธ 15 views ๐Ÿท๏ธ Developer Tools

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.

Mock API Generator Interface

๐Ÿš€ 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:

  1. The system checks the incoming request's IP address
  2. If the IP is in your allowed list, the request proceeds normally
  3. If the IP is NOT allowed, the server returns a 403 Forbidden error
// 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:

  1. Your public IP is auto-detected and shown on the page
  2. Click "Add My IP" to whitelist your current IP
  3. Check "Enable IP Restriction" to activate the feature
  4. 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 identifiera1b2c3d4-e5f6-4789-abcd-123456789012
{{firstName}}Random first nameEmma, Liam, Olivia
{{lastName}}Random last nameSmith, Johnson, Williams
{{fullName}}Full name combinationEmma Johnson
{{email}}Email addressemma.johnson@gmail.com
{{phone}}Phone number+1 555-123-4567
{{company}}Company nameTechCorp, Innovate Inc
{{jobTitle}}Job titleSoftware Engineer
{{city}}City nameNew York, San Francisco
{{country}}Country nameUnited States, Canada
{{isoDate}}ISO 8601 date2024-06-15T14:30:00
{{boolean}}Random true/falsetrue, false
{{number:100}}Random number (0-100)42, 73, 15
{{avatar}}Avatar URLhttps://i.pravatar.cc/150?img=42
{{imageUrl}}Random image URLhttps://picsum.photos/seed/123/400/300
{{zipCode}}ZIP/Postal code10001, 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

  1. Collect the public IP addresses of all team members
  2. Add all IPs to the allowed list (comma-separated)
  3. Share the endpoint URL with your team

For Production-like Testing

  1. Use IP restriction to simulate production access control
  2. Test your application's handling of 403 responses
  3. Verify your error messages and redirects work correctly

For Personal Use

  1. Click "Add My IP" to auto-add your current IP
  2. Enable IP restriction to protect your mock data
  3. 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:

  1. Configure your endpoint path and method
  2. Create a response template with dynamic variables
  3. Set the number of records you need
  4. Optionally enable IP restriction for security
  5. Click "Create Server Endpoint" and copy your URL
  6. Use the URL in your application immediately!

Try the Mock API Generator Now โ†’


๐Ÿ“š Related Tools You Might Like

๐Ÿท๏ธ Tags:
mock api api testing ip restriction mock server rest api api generator fake api json api frontend development api mocking postman alternative developer tools

๐Ÿ“š Related Articles