Start running Rest API on your local without writing any code

Below tutorial will show how to start a demo Rest API on a JSON Server without writing a single piece of code. It will also show how you can test the API using Rest-Assured.


1. Download Node.js on your machine. (

2. Install Node.js

3. Open Command Prompt and check that npm and node is installed

node -v
npm -v

4. Install JSON Server

npm install -g json-server

5. Create a db.json file with some data

  "posts": [
      "id": 1,
      "title": "json-server-1",
      "author": "qascript"
      "id": 2,
      "title": "json-server-2",
      "author": "qascript"
  "comments": [
      "id": 1,
      "body": "test1",
      "postId": 1
      "id": 2,
      "body": "test2",
      "postId": 2
  "profile": {
    "name": "qascript"

6. Start JSON Server

json-server --watch db.json

7. Open http://localhost:3000/posts in any browser to view JSON response

8. Write the following code to test a POST request on the demo Rest API running on the localhost.

public void PostRequestLocalJsonServer(){
       String payload = "{\n" +
               "      \"id\": 3,\n" +
               "      \"title\": \"json-server-3\",\n" +
               "      \"author\": \"qascript\"\n" +
               "    }";


9. Again open the URL(https://localhost:3000/posts) and notice that a new post is added to the api.




Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

1 Response

  1. RAMAGANO712 says:

    Thank you!!1

Leave a Reply

Your email address will not be published.