# API Mock Server

Generate a runnable Redis-backed mock API server with 1-hour TTL, hot updates, and dynamic templated responses

> Canonical page: https://elysiatools.com/en/tools/api-mock-server

- **Category:** Development

- **Keywords:** api, mock, mock server, http, frontend, testing, redis, hot reload

## Overview

Create a temporary mock server for frontend and API testing.

- Input endpoint description as JSON
- Generate a unique mock server ID
- Store mock definition in Redis for 1 hour
- Test immediately through /mock/{id}
- Re-run with the same ID to hot-update responses without restarting

## Inputs

- **Mock Definition JSON** (textarea): { "name": "User Service Mock", "basePath": "/api", "endpoints": \[ { "method": "GET", "path": "/users/:id", "status": 200, "responseType": "json", "dynamicResponse": true, "responseBody": { "id": "{{params.id}}", "name": "Mock User", "requestedAt": "{{now}}" } }, { "method": "POST", "path": "/login", "status": 200, "responseType": "json", "responseBody": { "token": "mock-token", "username": "{{body.username}}" } } \] }
- **Existing Mock ID (Optional)** (text): Reuse an existing ID to hot-update the mock server

## When to use

- When backend development is delayed and you need to unblock frontend integration.
- When you need to test how your application handles specific API responses or dynamic data.
- When you want to quickly prototype an API contract without setting up a full local server environment.

## How it works

- Input your API endpoint definitions, including methods, paths, and response bodies, using the Mock Definition JSON format.
- Generate a unique mock server ID that hosts your endpoints at a temporary URL.
- Access your mock API immediately via the provided base URL.
- Re-run the tool with the same mock ID to apply hot updates to your endpoints without downtime.

## Use cases

- Simulating user authentication flows by mocking login POST requests.
- Testing frontend data binding with dynamic GET requests that include URL parameters.
- Rapidly iterating on API response structures during the design phase of a new feature.

## Frequently asked questions

### How long does the mock server stay active?

Each mock server instance is stored in Redis and remains active for 1 hour after creation or last update.

### Can I update my mock responses after creating the server?

Yes, simply re-run the tool using the same mockId to hot-update your endpoint definitions instantly.

### Does the server support dynamic responses?

Yes, you can use template tags like {{params.id}}, {{body.username}}, or {{now}} within your response body to generate dynamic data.

### Is there a limit to the number of endpoints I can define?

You can define multiple endpoints within a single JSON configuration to simulate a complete API service.

### What happens after the 1-hour TTL expires?

The mock server and its data are automatically removed from Redis once the 1-hour TTL is reached.

## Related tools

- [API Request Code Snippet Generator](https://elysiatools.com/en/tools/api-request-code-snippet-generator): Generate cURL and common language code snippets from a request URL, method, headers, query parameters, and body
- [OpenAPI to Postman Collection](https://elysiatools.com/en/tools/openapi-to-postman-collection): Turn an OpenAPI 3.x or Swagger 2.0 spec (JSON/YAML) into an importable Postman Collection v2.1.0 with folders, variables, auth and example responses.
- [Test Data Faker Builder](https://elysiatools.com/en/tools/test-data-faker-builder): Generate structured test data from field configuration with support for faker fields, regex rules, credit cards, IDs, and batch export
- [OpenAPI to TypeScript Generator](https://elysiatools.com/en/tools/openapi-to-typescript-generator): Convert OpenAPI or Swagger JSON/YAML specs into TypeScript API types, request payloads, and response models with configurable output and naming styles
- [CSV to Database Migration Planner](https://elysiatools.com/en/tools/csv-to-database-migration-planner): Infer a relational schema from CSV data and generate create-table plus ALTER migration plans for PostgreSQL, MySQL, SQLite, or SQL Server
- [Fitness Workout PDF Generator](https://elysiatools.com/en/tools/fitness-workout-pdf-generator): Generate a printable workout-plan PDF from JSON or CSV data with exercise tables, progress boxes, and optional QR video links
- [JSON Schema Generator](https://elysiatools.com/en/tools/json-schema-generator): Infer JSON Schema from sample JSON, optionally merge manual schema edits, and validate data against the active schema
- [PDF Financial Report](https://elysiatools.com/en/tools/pdf-financial-report): Generate a financial report PDF with balance sheet, income statement, and merged table cells

## Samples

- [Postman Collections - API Testing](https://elysiatools.com/en/samples/postman-collections): Comprehensive Postman collection examples including API testing, automation scripts, environment variables, mock servers, and advanced testing patterns for REST APIs
- [WebRTC Real-Time Communication Samples](https://elysiatools.com/en/samples/webrtc-samples): Comprehensive WebRTC samples for peer-to-peer audio/video communication, data channels, screen sharing, and signaling server implementation
- [macOS Networking Objective-C Samples](https://elysiatools.com/en/samples/macos-networking-objectivec): macOS Objective-C networking examples including URLSession, HTTP requests, WebSocket, and network reachability
- [Windows Networking - C++ Samples](https://elysiatools.com/en/samples/windows-networking-cpp): Comprehensive C++ networking examples for Windows platform including HTTP requests, TCP sockets, and HTTP server implementation

## Related content

- [API Mock Fixture Generation and Review](https://elysiatools.com/en/hubs/api-mock-fixture-generation-and-review): Build repeatable mock payloads, generate format-valid edge values, catch confusing field names, and review a temporary mock service before sharing it with a development team.
- [API Request Format, Replay Preparation, and Debugging Tools](https://elysiatools.com/en/hubs/api-request-replay-and-debugging): Check request structure, prepare a local replay, compare responses, and debug API clues. These tools analyze or generate locally and do not replace real authentication or server tests.
- [API Contract Definition, Schema Validation, and Change Testing](https://elysiatools.com/en/hubs/api-contract-testing): Define an API contract, validate schemas and captured payloads, detect compatibility risks, and record test acceptance.
