Building a REST API is one of the most important backend skills for developers. It helps you understand how servers, routes, and data communication work in real applications.
In this guide, you will learn how to build a simple REST API using Node.js and Express step-by-step.
1. Project Overview
This REST API will allow you to:
- Create data
- Read data
- Update data
- Delete data (CRUD operations)
👉 This is the foundation of backend development
2. Express Setup (Server Setup)
Express is a popular Node.js framework used to build APIs.
Steps:
- Install Node.js
- Initialize project
npm init -y
- Install Express
npm install express
Basic Server Code:
const express = require('express');
const app = express();
app.listen(3000, () => {
console.log('Server running on port 3000');
});
👉 This creates your backend server
3. Creating Routes
Routes define API endpoints.
Example Routes:
app.get('/', (req, res) => {
res.send('Welcome to API');
});
app.get('/users', (req, res) => {
res.json([{ name: 'John' }, { name: 'Sara' }]);
});
👉 Each route handles a specific request
4. JSON Response
APIs send data in JSON format.
Example:
app.get('/data', (req, res) => {
res.json({ message: 'Hello World' });
});
👉 JSON is standard for API communication
5. Handling Requests (CRUD)
Create Data (POST):
app.post('/users', (req, res) => {
res.send('User created');
});
Update Data (PUT):
app.put('/users/:id', (req, res) => {
res.send('User updated');
});
Delete Data (DELETE):
app.delete('/users/:id', (req, res) => {
res.send('User deleted');
});
6. Real-World Flow
- Client sends request (GET/POST)
- Server receives request
- Route handles logic
- Response sent in JSON
Why Build This Project?
- Learn backend fundamentals
- Understand API development
- Build real-world applications
Beginner Recommendation
- Start with simple routes
- Practice CRUD operations
- Connect database later
Final Thoughts
Building a REST API is the first step toward backend development. It helps you understand how applications communicate and process data.
At Mango Engineers, we focus on practical backend training and real-world projects to make students industry-ready.
Call to Action
Start building your REST API with Mango Engineers and become a backend developer!





