Fake Rest API in 30 sec

Eswar Abisheak
2 min readJul 1, 2021

You read it right!

Can you set up a fake rest API in seconds without code?

If your answer is no then this would come in handy.

You just need to have NodeJS and a JSON structure to set up
the fake rest API.

  1. Open your terminal / CMD / Powershell then enter
    npm install -g json-server then press enter.
  2. Now open a new folder somewhere then open the folder in
    your code editor.
  3. Create a file called db.json .
  4. Open that file and make your JSON structure.
  5. open terminal / CMD / PowerShell in that folder and type
    json-server — watch db.json and hit enter.

Your fake rest API is ready.

Note: If you want to have the fake rest API to be accessible by all the
devices in your wifi network.

Open your terminal / CMD type ipconfig for windows and ifconfig for Linux. find out your IPV4 address assigned to your device by your router.
then run the command
json-server — watch db.json --host <IPV4> --port 5000

There is more for you to explore over here.

Hope you liked it, feel free to ask your queries I am happy to answer them.

Github if you want to follow.

--

--