Skip to main content

How to Create a Mock API for Testing

Use mockforme to instantly create mock REST API endpoints for development and testing. Define endpoint paths, HTTP methods, and add features like custom response delays or public access options.

Steps to Create a Mock API Endpoint

Follow these steps to create a mock API using the mockforme platform:

  • Click on "Collections" in the left sidebar.
  • Select a collection, then click on the "APIs" button.
  • On the API listing page, click the "Create New" button.
  • Enter your API Endpoint, HTTP Method, and an optional Description.
  • Click Save to finalize the mock endpoint.
info

Use relative URLs (e.g., /user/getSession) and avoid including query parameters in the endpoint definition.

API listing in mockforme – mock REST APIs for development

Add a Simple Mock API Endpoint

In the screenshot below, we define a basic mock endpoint:

  • Endpoint: /user/getSession
  • Method: GET

This lets you simulate a GET request to /user/getSession for frontend testing.

Create simple mock API endpoint – simulate GET request

Expression-Based Mock API Endpoints

You can also create dynamic endpoints using parameterized paths. Use :any in the endpoint to match any value after the defined route:

For example, /user/:any will match:

  • /user/1
  • /user/663623f769e6f02f3736d298

This is useful for testing dynamic route handling in your app.

Create expression-based mock API endpoint with :any pattern