API with Node.js Node.js

Video Tutorial & Live Code: Build a JSON API Node.js

Hello, world! In this interactive tutorial, I want to share my experience of building a simple JSON API with Node.js and Express.js. This tutorial is part of my video tutorial/course – Example backend API in Node.js – Video Tutorial. Check it for more contextual information.

If you need help with editing the source code and using IDE, check the video at the end of the page.

For mobile users, scroll to the middle of the page for online IDE or code editor.

Part 1: Build a JSON API in Node.js

If you want to jump directly to the coding part start at 1:25.

In this part:

  • Initialize an empty Node.js project.
  • Create a very simple web app.
  • Return a JSON response using the HTTP package.
Part 2: Introduce package.json and use nodemon

In this part:

  • Introduce package.json for project dependencies.
  • Introduce nodemon to the project for hot-reload.
  • Shortly about GitHub repo for the course.
Part 3: Convert to Express.js web framework

In this part:

  • Introduce Express.js – a popular Node-based web framework.
  • Convert pure Node HTTP app to Express.js application.
Part 4: Accept URL params and return JSON object by using Express.js features:

In this part:

  • Return a JSON response by using res.json() method. This method implicitly uses JSON.stringify() and sets the correct content-type.
  • Add one more route and accept request params by using the req.params object.

How to use an interactive code window?

Check the following video for:

  • Setup for your own use.
  • Start the project online and check the link.
  • Do very simple code modifications.
How to use interactive tutorial?

Use and Share!

Do you like this format? I want to do more tutorials like this.

You can help me by subscribing to my website – you will receive all updates in your mailbox. And, also by sharing this page with your friends.

Success! You're on the list.

By Kanan Rahimov

Sr. Software Engineer

Leave a Reply