Tutorial

How to Create a Mock API for Testing in 60 Seconds
No Code Required

Need a mock REST API right now? MockHub lets you generate a fully working mock API endpoint in under 60 seconds — no code, no backend, no Docker, no server setup.

5 min read  ·  Works for frontend devs, backend devs, QA engineers

Whether you're building a frontend app and the backend isn't ready yet, testing edge cases in your mobile app, or onboarding a new teammate who needs a safe sandbox — a mock API is the fastest solution.

This guide shows you how to create a mock API for testing using MockHub, a free online mock API generator. No terminal, no code, no configuration files.

Table of Contents

  1. What is a Mock API?
  2. Why Use MockHub as Your Mock API Generator
  3. Step-by-Step: Create a Mock REST API in 60 Seconds
  4. Use Dynamic Variables for Realistic Data
  5. Simulate Errors and Delays with Scenarios
  6. Common Use Cases
  7. FAQ
?

What is a Mock API?

A mock API is a fake API endpoint that returns pre-defined responses, simulating the behavior of a real backend. It lets developers and QA engineers work independently without waiting for the real service to be ready.

A mock REST API is useful when you need to:

Why Use MockHub as Your Mock API Generator

MockHub is an online mock API generator built for developers who want speed. No installation, no CLI, no YAML files. You fill in a form and get a live URL in seconds.

Feature MockHub Postman Mock Mockoon
No install required ✔ Online ✔ Online ✘ Desktop app
Free tier ✔ 5 APIs free ✘ Limited ✔ Open source
SOAP mock support
AI-generated responses
Dynamic variables ✔ 24+ variables
Error / delay simulation ✔ Scenarios
OpenAPI import ✔ Premium
1

Step-by-Step: Create a Mock REST API in 60 Seconds

1.1

Create a free account

Go to mockhub.ovh/api-generator/register.html and sign up with your email. No credit card required. The free plan gives you 5 mock API endpoints instantly.

1.2

Open the Mock API Generator

From your dashboard, click "Generate REST Mock" or go directly to mockhub.ovh/api-generator/generate_api.html.

1.3

Name your endpoint

Enter a path prefix for your endpoint, for example users or products-api. MockHub will generate a unique URL like:

https://mockhub.ovh/users_a1b2c3d4
Tip: Use a descriptive prefix so you can identify the endpoint at a glance in your dashboard.
1.4

Select HTTP methods

Choose which HTTP methods the endpoint should accept: GET, POST, PUT, DELETE, or any combination. MockHub rejects requests using unlisted methods with a clear error response.

1.5

Define the JSON response body

Paste the JSON you want the endpoint to return. This is the response your app or test will receive every time it calls the endpoint.

{ "status": "success", "data": { "id": 1, "name": "Alice Johnson", "email": "alice@example.com", "role": "admin" } }
Tip: Not sure what JSON to write? Use the AI Generator — describe the endpoint in plain English and MockHub creates the response body for you.
1.6

Click "Create" — your mock API is live

Hit the Create button. MockHub generates a live URL immediately. You can call it from your app, Postman, curl, or any HTTP client right away.

curl https://mockhub.ovh/users_a1b2c3d4

The endpoint stays active for 10 days and auto-renews every time it receives a request.

2

Use Dynamic Variables for Realistic Data

Static JSON returns the same values on every request. MockHub supports 24+ dynamic variables that generate fresh random values on each call. Just use the {{variableName}} syntax inside your JSON.

VariableExample output
{{uuid}}550e8400-e29b-41d4-a716-446655440000
{{email}}john.doe@example.com
{{firstName}}Alice
{{timestamp}}2026-03-24T10:00:00Z
{{randomNumber}}4821
{{IBAN}}GB29NWBK60161331926819
{{IPv4}}192.168.1.42

Example — a dynamic user profile response:

{ "requestId": "{{uuid}}", "user": { "firstName": "{{firstName}}", "lastName": "{{lastName}}", "email": "{{email}}", "city": "{{city}}", "registeredAt": "{{timestamp}}" } }
Result: Every call returns a different realistic user — perfect for populating UI components or stress-testing pagination logic.
3

Simulate Errors and Delays with Scenarios

Real APIs fail. Your app should handle errors gracefully. MockHub's Scenarios feature lets you switch your endpoint between different response profiles with one click — no code changes needed.

Each scenario can define:

Example scenarios for a /payment endpoint:

Scenario A (default): 200 OK → { "status": "paid" } Scenario B (failure): 402 Error → { "error": "insufficient_funds" } Scenario C (timeout): 200 OK, delay 8000ms Scenario D (unstable): 500 error, error_rate 0.4
Tip: Switch to the error scenario before running your test suite to verify your app handles failures correctly, then switch back to the happy path. No code deploy needed.
4

Common Use Cases for Mock REST APIs

Frontend development without a backend

Your backend team is still building the API. Create a mock REST API with the agreed contract, point your frontend at MockHub, and ship features without waiting.

Automated testing and CI/CD pipelines

Use a MockHub endpoint in your Jest, Cypress, or Playwright tests. Since the response is deterministic, your tests are reliable and don't depend on external services being available.

Testing error handling

Switch to a 500-error scenario and run your test suite to verify your app shows the right error messages, retries correctly, and doesn't crash.

API prototyping and client demos

Before writing a single line of backend code, generate a mock API and share the URL with stakeholders. Get feedback on the contract early.

Mobile app development

iOS and Android developers can hit a live MockHub endpoint from day one, with realistic dynamic data, without any backend infrastructure.

5

FAQ

Is MockHub free?
Yes. The free plan gives you 5 mock API endpoints with 40 calls/day each — enough for most testing needs. The premium plan unlocks 100 endpoints, 15,000 calls/day, AI generation, SOAP mocking, and OpenAPI import.

Do I need to install anything?
No. MockHub is fully online at mockhub.ovh. Open your browser and start creating.

How long does a mock endpoint stay active?
Endpoints are valid for 10 days and auto-renew every time they receive a request. Inactive endpoints expire automatically.

Can I use MockHub in CI/CD?
Yes. The endpoint URL is stable as long as the endpoint is active. You can hardcode it in your test config or environment variables.

Does MockHub support SOAP?
Yes. Upload a WSDL file and MockHub generates a fully working SOAP mock service with all operations. Available on the premium plan.

Can I import an OpenAPI / Swagger spec?
Yes. MockHub can parse an OpenAPI 3.x or Swagger 2.0 spec and create all endpoints automatically — available on the premium plan.

Create Your First Mock API Now

Free account. No credit card. Live endpoint in under 60 seconds.

Get Started Free