Node.js remains one of the most practical skills a developer can pick up in 2026 — it's what powers a huge share of the backend web, and unlike some frameworks, you can go from zero to a working API in under half an hour. This tutorial walks through building a simple, real API from scratch, no prior backend experience required.
What You'll Need
- Node.js installed on your computer (download from nodejs.org)
- A code editor (VS Code is the standard choice)
- Basic comfort with JavaScript syntax
A quick version note: Node.js currently has two relevant release lines. Node 24 is the Active LTS release and the right choice for new projects. Node 26 is the newer "Current" release but won't become LTS until October 2026, so stick with Node 24 if you want stability.
Step 1: Set Up Your Project
Create a new folder for your project, then open a terminal inside it and run:
mkdir my-first-api
cd my-first-api
npm init -yThis creates a package.json file, which tracks your project's dependencies and settings.
Step 2: Install Express
Express is the most widely used framework for building APIs in Node.js. It handles the repetitive plumbing (routing, requests, responses) so you can focus on your actual logic.
npm install expressStep 3: Write Your First Server
Create a file called server.js in your project folder and add the following:
const express = require('express');
const app = express();
const PORT = 3000;
app.use(express.json());
app.get('/', (req, res) => {
res.send('Hello, your API is running!');
});
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});Run it with:
node server.jsVisit http://localhost:3000 in your browser and you should see your message. That's a working server.
Step 4: Add a Real Endpoint
A single "hello world" route isn't very useful. Let's add an endpoint that returns actual data — the kind of thing a real API does.
const users = [
{ id: 1, name: 'Amaka' },
{ id: 2, name: 'Tobi' },
{ id: 3, name: 'Chidi' }
];
app.get('/users', (req, res) => {
res.json(users);
});
app.get('/users/:id', (req, res) => {
const user = users.find(u => u.id === parseInt(req.params.id));
if (!user) return res.status(404).json({ error: 'User not found' });
res.json(user);
});Add this code above the app.listen() line, restart your server, and visit http://localhost:3000/users — you'll see the full list returned as JSON. Try /users/2 and you'll get just that one user.
Step 5: Accept Data with POST
Real APIs also need to receive data, not just send it. Here's how to accept a new user via a POST request:
app.post('/users', (req, res) => {
const newUser = {
id: users.length + 1,
name: req.body.name
};
users.push(newUser);
res.status(201).json(newUser);
});You can test this with a tool like Postman or Thunder Client (a free VS Code extension), sending a JSON body like {"name": "Blessing"} to http://localhost:3000/users.
What You've Actually Built
In these five steps, you've built a working REST API with routes to read all records, read a single record, and create a new one — the same core pattern that powers most real-world backends, just without a database yet (that's the natural next step once you're comfortable with this).
Where to Go From Here
- Connect this to a real database like MongoDB or PostgreSQL instead of the in-memory array
- Add PUT and DELETE routes to complete full CRUD functionality
- Deploy it somewhere free like Render or Railway so it's live on the internet, not just your machine
Frequently Asked Questions
Do I need to know JavaScript deeply before learning Node.js?
Basic JavaScript (variables, functions, arrays) is enough to start. You'll pick up the rest as you build.
Is Express still the best choice in 2026?
For beginners, yes — it remains the most widely documented and most beginner-friendly framework, with the largest ecosystem of tutorials and Stack Overflow answers if you get stuck.
Which Node.js version should I install?
Node 24, since it's the current Active LTS release and the stable choice for new projects.
