Before jumping into tools like cURL, we need to understand something more important:
Who are we even talking to?
That “someone” is called a server.
What Is a Server? (In Very Simple Words)
A server is just a computer that gives something when you ask for it.
It can:
- send you a website
- give you data
- store your files
- save your login info
When you open Instagram, submit a form, or fetch API data you are talking to a server.
You (your browser, your app, your terminal) are called the client.
So the basic idea is:
Client → Server → Response
You ask.
Server processes.
Server replies.
That’s it.
Does a Server Look Special?
Not really.
A server is also a computer, just like yours.
It has:
- CPU
- Memory
- Storage
- Operating System (Ubuntu, Windows Server, etc.)
The only difference?
It is always running and always ready to respond to requests.
Types of Servers
There are different kinds of servers depending on what they provide.
1. Web Server
Delivers websites (HTML, CSS, JavaScript, images).
Example flow:
Browser → Web Server → HTML page
2. File Server
Stores and manages files.
Client → File Server → File Download
3. Mail Server
Handles sending and receiving emails.
Email App → Mail Server → Inbox
4. Database Server
Stores structured data (like users, products, orders).
Backend App → Database Server → Data
Now that we understand servers…
Let’s talk about how we can speak to them without a browser.
What is cURL? (Very Simple Explanation)
cURL is a command-line tool that lets you send requests to a server directly from your terminal.
Instead of clicking buttons in a browser,
you type a command.
That’s it.
cURL stands for Client URL.
Meaning:
- You are the client
- You send something to a URL
- You get a response back
How cURL Communicates
Here’s what happens when you use cURL:
Terminal (You)
↓
cURL builds HTTP request
↓
Server receives request
↓
Server sends response
↓
cURL prints response in terminal
No UI.
No fancy design.
Just raw communication.
Your First cURL Command
The simplest possible example:
curl https://example.com
What just happened?
- cURL sent a GET request to the server.
- The server processed it.
- The server sent back a response.
- cURL printed the response (HTML) in your terminal.
You just fetched a webpage without opening a browser.
Feels small… but it’s powerful.
What Exactly Is a Request and Response?
Every HTTP communication has two parts:
Request → Response
The Request (What You Send)
A request usually contains:
- URL (where you’re sending it)
- Method (GET or POST)
- Headers (extra info)
- Body (data, sometimes)
The Response (What Server Sends Back)
A response has three main parts:
1. Status Code
Tells you what happened.
- 200 → Success
- 404 → Not Found
- 500 → Server Error
2. Headers
Extra information like content type, date, etc.
3. Body
The actual data (HTML, JSON, text, etc.)
If you want to see everything (status + headers + body), use:
curl -i https://example.com
You’ll see something like:
HTTP/2 200
content-type: text/html
Then the HTML.
200 means it worked.
GET vs POST (Only These Two for Now)
Don’t overload yourself with too many methods.
Just understand these two.
GET → “Give me data.”
Used to fetch or read something.
Default in cURL.
Example:
curl https://api.example.com/users
This means:
“Hey server, send me users.”
POST → “Here is data. Do something with it.”
Used when sending data to the server.
Example:
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Alice"}'
What this does:
-
-X POST→ use POST method -
-H→ sending extra information -
-d→ sending actual data
Don’t worry about remembering everything now. Just understand the idea.
Using cURL to Talk to APIs
APIs are just URLs that send back data (usually JSON).
Example:
curl https://jsonplaceholder.typicode.com/posts/1
You’ll get something like:
{
"userId": 1,
"id": 1,
"title": "...",
"body": "..."
}
That’s an API response.
You just interacted with a backend system directly.
Browser vs cURL (Conceptual Difference)
Both send HTTP requests.
But:
Browser:
Request → Server → Response → Render UI
cURL:
Request → Server → Raw Response in Terminal
Browser shows design.
cURL shows truth.
That’s why backend developers love it.
Common Mistakes Beginners Make
Let me save you some frustration 😅
1. Forgetting quotes
If URL has spaces or special characters:
curl "https://example.com?name=John Doe"
2. Wrong Content-Type
If sending JSON, always add:
-H "Content-Type: application/json"
3. Typos in URL
http vs https
Missing slash
Wrong domain
Happens more than you think.
4. Ignoring Status Code
Always check:
HTTP/2 200
Use -i if needed.
Where cURL Fits in Backend Development
If you’re building backend APIs:
You build endpoint
↓
You test with cURL
↓
You verify response
↓
Frontend connects later
It’s fast.
No need for frontend.
No need for Postman (at least initially).
Also used in:
- Automation scripts
- Cron jobs
- Health checks
- Debugging production issues
Final Thought
cURL is not complicated.
It just looks scary because it’s raw.
But once you understand this flow:
Client → Request → Server → Response
Everything becomes logical.
Start small.
Use simple GET requests.
Slowly add headers and POST.
Confidence first. Depth later.
Top comments (0)