How to Test a REST API Without a Backend: Step-by-Step Guide

Testing a REST API before the backend is ready is possible with mock APIs. This step-by-step guide shows you exactly how to do it.

How to Test a REST API Without a Backend: Step-by-Step Guide

The Problem: Front End Needs Data, Back End Isn't Ready

One of the most frustrating bottlenecks in software development is waiting for the backend team to finish building an API before the frontend team can start their work. In a world of agile sprints and tight deadlines, this sequential dependency is a productivity killer.

The solution is REST API mocking — creating a fake but realistic API endpoint that your frontend or test suite can interact with immediately, without any real server infrastructure.

What You Will Need

  • A mock API tool (we will use Mockable in this tutorial)
  • A REST client such as Postman, Insomnia, or cURL
  • Basic understanding of HTTP methods and JSON

Step 1: Define Your API Contract

Before creating any mock endpoints, document the API you expect to receive from the backend. This is called an API contract or API specification. At a minimum, define:

  • Endpoint paths (e.g. GET /api/products)
  • Request parameters and headers
  • Expected response structure and data types
  • HTTP status codes for success and error cases

Even a simple Markdown document or a shared spreadsheet serves this purpose. The goal is alignment between the frontend and backend teams before coding starts.

Step 2: Create Your Mock API

Sign in to your Mockable account and create a new mock service. Give it a descriptive name like ecommerce-api-v1. Mockable assigns a unique subdomain to your service — something like https://demo1234.mockable.io.

Now add your first endpoint:

  1. Click Add Response
  2. Set the HTTP method to GET
  3. Enter the path: /products
  4. Paste the following JSON as the response body:
{
  "data": [
    { "id": 1, "name": "Wireless Headphones", "price": 79.99, "inStock": true },
    { "id": 2, "name": "USB-C Hub",           "price": 34.99, "inStock": true },
    { "id": 3, "name": "Mechanical Keyboard",  "price": 119.00, "inStock": false }
  ],
  "total": 3,
  "page": 1
}

Set the status code to 200 and save the endpoint.

Step 3: Test the Endpoint with Postman

Open Postman and create a new GET request to https://demo1234.mockable.io/products. Hit Send — you should receive the JSON response you defined in under 100 ms. Congratulations: you have a working REST API with no backend.

Step 4: Mock Error States

Real-world APIs fail. Your frontend must handle errors gracefully, which means you also need to mock error responses. Add a second endpoint:

  • Method: GET
  • Path: /products/999
  • Status: 404
  • Body: {"error": "Product not found", "code": 404}

Now test your application's error handling against this endpoint before the real backend exists. If your UI shows a friendly "Product not found" message, your error handling is working correctly.

Step 5: Simulate Network Latency

Lightning-fast mock responses can hide latency-sensitive bugs in your UI. Mockable lets you add a response delay (in milliseconds) per endpoint. Set a 800 ms delay on your products endpoint and see whether your loading spinners and skeleton screens behave correctly under realistic network conditions.

Step 6: Integrate the Mock URL Into Your Application

Replace the real API base URL in your application's configuration with the Mockable URL. For a React application using environment variables:

REACT_APP_API_BASE_URL=https://demo1234.mockable.io

Your application will now call the mock API. All network requests, loading states, and data rendering are now fully testable — without a single line of backend code written.

Step 7: Switch Back to the Real API When Ready

When the backend team finishes their implementation, updating your configuration to point at the real API base URL is all that is required. If you built against an agreed API contract, the switch should be seamless.

Tips for Effective REST API Testing Without a Backend

  • Use realistic data that matches production shapes — avoid "string" and 123 as placeholder values.
  • Mock all the HTTP methods your application uses: GET, POST, PUT, PATCH, DELETE.
  • Include both happy-path and error-path responses.
  • Share your mock service URL with the whole team so everyone uses consistent test data.
  • Lock down the mock URL in CI/CD so automated tests always run against known responses.

Conclusion

Testing a REST API without a live backend is not just possible — it is a professional best practice that speeds up delivery and improves quality. Mock API tools like Mockable give you full control over your API responses so you can build, test, and ship faster than ever.

Try Mockable for free and have your first mocked REST endpoint live in two minutes.