If you’re just starting with backend development, building your own API is one of the best ways to learn how the web actually works.
What is an API?
API stands for Application Programming Interface — it allows two systems to communicate with each other.
For example:
Your frontend asks the server: “Give me the t-shirt info”
The server replies:
{ "tshirt": "T-shirt with your dragon and ID of 23" }
Why use APIs?
We use APIs to make communication between clients and servers smooth and structured.
They allow your app to request and receive data in a standard format like JSON.
Step-by-Step: Build an API from Scratch
1️⃣ Create a new folder
Open your terminal and create an empty folder for your project.
mkdir api
cd api
2️⃣ Initialize npm
This creates a package.json file.
npm init -y
3️⃣ Install Express
npm install express
4️⃣ Create index.js
This is where we’ll build our server.
Check my GitHub repo for full code: https://github.com/EsraaNasr92/api
Test your API
You can test your API in several ways:
- curl — directly from your terminal
- VS Code REST Client Extension
- REST Client
- Postman
- Insomnia (the one I used to learn something new
Example Results
GET /tshirt
POST /tshirt/23
with no logo
POST /tshirt/23
with logo
What I Learned
- How to initialize a Node.js project
- How to use Express to build an API
- How to use middleware to parse JSON (express.json())
- How to test endpoints with Insomnia
Let’s Connect!
If you enjoyed this tutorial and want to follow my learning journey, connect with me here:
Please don't hesitate to ask me any questions.
GitHub: github.com/EsraaNasr92
LinkedIn: linkedin.com/in/esraa-nasr92
Instgrame: esraa_dev_
I regularly post about frontend & backend development, APIs, and tech learning journeys.
If you’re also learning Node.js or Express, follow me — let’s grow together!
Top comments (0)