Rapid prototyping a REST API with json-server

written by Guido Percú on May 24, 2020

Sometimes we need a full fake REST API to prototype new products and mock new functionalities. The json-server package provides a quick and easy way to do that.

npm init -y
npm i json-server

Then we create a db.json file with a JSON object representing the resources we want to provide CRUD API access.

 "podcasts": [
      "id": 1,
      "name": "Podcast 1",
      "url": "https://testurl.com/api/v3/profile/aaaa"
      "id": 2,
      "name": "Podcast 2",
      "url": "https://testurl.com/api/v3/profile/bbbb"

Change your package.json scripts property:

"scripts": {
    "start": "json-server --watch db.json"

And then you're ready to run your REST API

npm start