web development tools

The Fastest Way to Mock a REST API JSON Response

You’ve just found the Fastest Way to Mock a Rest API JSON Response. I know time is precious so I’ll be quick:

First Step: Install the Server

sudo npm install -g json-server

Second Step: Create the Mock Response

This will be depending on what you want the fastest mock REST API to be.
Create it in a file called db.json

  "posts": [
    { "id": 1, "title": "json-server", "author": "typicode" }
  "comments": [
    { "id": 1, "body": "some comment", "postId": 1 }
  "profile": { "name": "typicode" }

Third Step: Run the Server

json-server --watch db.json

Fourth Step: Test the API

USe Anything you want but postman, curl, python request will work well.

>>>import requests

You Can check your JSON Formatting with this tool

There we Go!

You have just seen the Fastest Way to Mock a REST API JSON Response.

Sources: Json Server Github