⌨️ Codingbeginnermockapitestingdeveloper-toolsfaker

Create a Mock API Server for Development

Build a mock API server that returns realistic fake data for frontend development without a real backend.

The Prompt

prompt.txt
Create a mock API server for the following endpoints. Include:
1. Realistic fake data using Faker.js or similar
2. Configurable delay to simulate network latency
3. Configurable error rate for testing error states
4. CORS headers for local development
5. Request logging
6. Stateful responses where needed (create, read, update, delete that persist in memory)

Framework: [JSON SERVER / EXPRESS / FASTAPI MOCK]
Endpoints to mock:
[LIST YOUR ENDPOINTS AND THEIR RESPONSE SHAPES — e.g.,
GET /api/users — returns array of 20 users with id, name, email, avatar, role
POST /api/users — accepts {name, email} and returns created user
GET /api/users/:id — returns single user or 404]

Example Output

Built an Express mock server with faker-generated user/product/order data, 200-800ms random delay, 5% random 500 error rate, in-memory store for POST/PUT/DELETE, and a /reset endpoint to clear state between tests.

FAQ

Which AI model is best for Create a Mock API Server for Development?

GPT-4o works well for mock servers. Claude Sonnet 4 for more complex stateful scenarios.

How do I use the Create a Mock API Server for Development prompt?

Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). Built an Express mock server with faker-generated user/product/order data, 200-800ms random delay, 5% random 500 error rate, in-memory store for POST/PUT/DELETE, and a /reset endpoint to clear state between tests.