How to Use cURL: A Simple Starter Guide
Beginner's Tutorial on Making HTTP Requests with cURL

WHAT IS A SERVER AND WHY WE NEED TO TALK TO IT?
When you begin your software development or computer science journey, you hear the word "SERVER" a lot. Let's demystify this server!
At its core, a server is a powerful computer that.
Stores data
Accepts and responds to requests made by another program, known as a client.
Manages resources
Server is always on (similar to the refrigerator), connected to the internet, and designed to respond when other computers ask it for something.

INTERESTING ANALOGY
Imagine you are hungry in the middle of the night ,you need some food to eat. So you go in the kitchen ,open the fridge and grab a snickers bar. In this case the fridge will be your server to store all the food (like webpages, files, or emails) inside, while you are the client that wants to get food (information) to consume.
Your browser, mobile app, or command-line tool is the client.
The server listens for requests and sends back responses.
For example:
REQUESTS LIKE
Opening a webpage
Submitting a form
An app wants to display your profile
Browser approaches the server, and
SERVER RESPONDS BY
Providing HTML, images, and scripts.
Storing and Processing the data sent
Retrieving your data from a server.
This back-and-forth communication is usually done using HTTP (or HTTPS).
The key idea is this:
As its name , server exists to serve the requests
Features of the server are :
Hardware or Software: It can be a physical, high-powered machine in a data center (often rack-mounted) or specialized software (like Apache or Nginx) running on a computer.
Always On: Servers are designed to run 24/7 to ensure services are available whenever needed.
Key Components: They typically feature powerful CPUs, large amounts of RAM, and fast, reliable storage.
We can say that a server is a single source of truth for the computers connected to its network.
But is there a way to communicate with the server at the most basic level? Can we use the terminal for that? Indeed.
WHAT IS cURL AND WHY PROGRAMMERS NEED IT?
cURL stands for client URL. It is one of the most popular commands among computer science nerds!
It is a command line tool that developers use to transfer data to and from a server.
At the most fundamental, cURL lets you talk to a server from the terminal without using any high tech and fancy interfaces like browsers.
If we see step by step
cURL sends requests to a server
The server sends back a response
cURL shows that response directly in your terminal
Some of the features of cURL are
Supports multiple protocols such as HTTP, HTTPS, FTP, and SCP
Used to download, upload, and send data from the terminal
Helpful for testing REST APIs and web services
Works with headers, authentication, and data formats like JSON
curl https://example.com
Why Do Programmers Need cURL?
Imagine cURL as the cameraman whose job is to shoot BTS of a commercial shoot.
When we use browsers for rendering our websites , browsers does all the computations behind the scenes and directly displays a fancy website on our device.
This process is not an issue for the muggles living beyond the fire-wall of the computer world .
But the developers can’t afford to guess what’s happening behind the scenes.
Most of the time, browsers and apps hide server communication from us.
That’s where cURL becomes essential.

Behind every website and app:
Requests are sent
Responses are received
Data flows back and forth
cURL strips everything down and shows you:
The raw request
The raw response
It helps you understand HTTP, APIs, headers, and data at a fundamental level.
MAKING OUR FIRST CURL COMMAND
Making our first command with curl is easy.
Step 1: Open Your Terminal
Command Prompt or PowerShell (Windows)
Terminal (macOS or Linux)
Once the terminal is open, you’re ready to talk to a server.
Step 2: Your First cURL Command
Type the following and press Enter:
curl https://example.com
What Just Happened? Let us conceptualize!
Breaking it down
curl→ the tool you are runninghttps://example.com→ the server you are talking to

When you run this command:
cURL sends an HTTP GET request to the server
The server processes the request
The server sends back a response
cURL prints the response in your terminal
As it is a webpage, the response is HTML content. If it were an API, the response would be JSON content.
The big difference between what you see in a browser and what you get with cURL is that cURL doesn't do any HTML parsing or styling.
It simply shows you the raw response the server sends back.
UNDERSTANDING REQUEST AND RESPONSE

The transfer of data between the client and server mainly consists of 2 types of messages sent from either side. .
Request message
- Client (terminal) —> Source , - - - - - - - > Server—> Destination
Response message
- Client (terminal) —>Destination , <- - - - - - - Server—> Source
You REQUEST the server to fetch the data. As soon as the server receives the request, it sends an appropriate RESPONSE to the REQUEST.
What Is a Request?
A request is a message sent from cURL to a server.
For example, when you run:
curl https://example.com
cURL sends a request to the server which includes:
Where to go (the URL)
What to do (by default, GET)
All these processes which cURL let’s you visualize , generally happen behind the scenes which browser doesn’t show you . It serves you the webpage on a fancy platter.
What Is a Response?
A response is the message the server sends back to cURL.
<!doctype html><html lang="en"><head><title>Example Domain</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.<p><a href="https://iana.org/domains/example">Learn more</a></div></body></html>
Every response usually contains two important things:
Status – did the request succeed or fail?
Data – the actual content returned by the server
Let us see them in detail
Status
It is a HTTP status code returned by a web server in response to a cURL request .
This three-digit number indicates whether the request was successfully completed, and if not, the reason for the failure.
The status code is a standard part of the HTTP protocol and is a crucial indicator of the outcome of a server request.
Some common examples:
200 OK – Success
404 Not Found – The resource doesn’t exist on the server
401 Unauthorized – You’re not allowed to access this
500 Server Error – The server failed
It’s the server’s quick way of saying “this worked” or “something went wrong.”
- Data
The data is what you actually asked for in the request message.
| TYPE OF URL IN THE REQUEST COMMAND | TYPE OF DATA RETURNED |
| WEBPAGE | HTML |
| API | JSON |
For example:
curl https://api.github.com
The response data is JSON, as an api is being tested.
Data in the form of TEXT AND FILES can also be requested and retrieved using these request response commands.
cURL simply prints whatever data the server sends back.
INTRODUCTION TO THE GET AND POST
Now let’s look at the two most common request types you’ll use:
GET – to fetch data
POST – to send data
1.GET Request Structure
As the name suggest a GET request is used to retrieve data from a server.
GET Request is used to:
Read data
Fetch a webpage
Get API responses
Basic Structure
curl <URL>
Example:
curl https://api.example.com/users
That’s a complete GET request.
What a GET Request Contains?
A GET request includes:
URL – where the request is sent (destination)
Method – GET (default in cURL)
Headers (optional) – extra information like content type or authentication
GET requests do not send a request body as the data is to be fetched not uploaded . This is one main difference between GET and POST Request.
2.POST Request
A POST request is used to send data to a server.
POST is used to:
Submit forms
Create new data
Send login or registration details
Basic Structure
curl -X POST <URL> -d "<data>"
Example:
curl -X POST https://api.example.com/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"secret"}'
A POST request usually includes:
URL – where the data is sent (destination/location)
Method – POST
Data (body) – the information being sent (only sent in POST )
Headers – to describe the data format (content type or authentication)
GET vs POST
GET → Ask for data
POST → Send data
Both follow the same flow:
cURL → Server → Response
Only the structure of the request changes.
| Feature | GET | POST |
| Purpose | Retrieve data | Send data |
| Data sent | None | In request body |
| Default in cURL | Yes | No |
| Common use | Reading data | Creating or submitting data |

cURL REQUEST RESPONSE STRUCTURE
1.HTTP REQUEST STRUCTURE

2.HTTP RESPONSE STRUCTURE

USING cURL TO TALK TO APIs
cURL is most used by developers for API testing before building a frontend.
When you communicate with an API it sends back data in JSON format.
Before writing code, many developers test APIs with cURL first.
USING cURL TO TALK TO APIs lets you to
Send requests manually
See raw responses
Test APIs without building an app
Debug problems quickly
Learn how APIs actually work
Making your first API request (GET):
curl -H "Accept: application/json" https://api.github.com
//Most of the APIs are very particular about mentioning headers in cURL commands .
- Understanding the flow, behind the scenes :
cURL sends a GET request
GitHub’s API processes it
The API sends back JSON data
cURL prints that JSON in your terminal
The response for an API command is well structured and consist of
Key-value pairs
Nested objects
Arrays of data

Sending Data to an API (POST)
Many times you will require to send data to API via a POST request.
//Request
curl -X POST https://api.example.com/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"secret"}'
//Response
{
"status": "success",
"message": "Login successful",
"user": {
"id": 123,
"username": "admin"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
What’s happening here:
-X POST→ defining the type of method-H→ setting the header-d→ sending data in the request body
This is how applications send information to APIs.
Common mistakes beginners make with cURL
Making mistakes is not the problem . But not analysing and correcting them is a problem .
For a beginner cURL feels confusing at first which is completely normal
Some common mistakes at beginner level that tend to take place are
Excluding HTTPS on the URL
Without http:// or https://, cURL doesn’t know how to connect.
Interchanging GET and POST
Using GET when you actually need to send data.
curl https://api.example.com/login ❌❌❌❌❌
Here the server expects a POST request, but you sent a GET request.
The fix :- If you’re sending data, you usually need POST.
Not including the headers
The mistake :- Sending JSON without telling the server it’s JSON.
The server doesn’t know how to read the data.
The fix : - Headers matter more than beginners expect.
Incorrect Quoting (Very Common on Windows)
The mistake :- Using quotes incorrectly, especially in PowerShell.
-d '{"username":"admin"}' ❌❌❌❌❌
PowerShell may interpret quotes differently.
The fix :-
1. Use double quotes and escape inner quotes:
-d "{`"username`":`"admin`"}"
2. Or use curl.exe explicitly:
curl.exe -X POST ...
5. Copy-Pasting Commands Without Understanding Them
The mistake : - Running cURL commands blindly without knowing what they are doing .
When something breaks, it’s hard to debug.
The fix:-
Always interpret the command yourself first before hitting enter:
What URL am I calling?
What method am I using?
Am I sending data?
What response did I get?
Even a basic understanding makes a huge difference.
Concluding our journey ….
Hitting the climax now , do you the importance of cURL in backend development? .
Without cURL developing applications would be a long tiresome process .Every time you need to test an API, you have to build the whole system (frontend, backend, other services).
Backend development is all about servers, APIs, and data exchange.

cURL sits at the heart of backend development because it lets you communicate with servers and APIs in the most direct and transparent way possible. By learning cURL, you’re not just memorizing commands—you’re understanding how requests are made, how servers respond, and how data flows behind every application. Whether you’re testing APIs, debugging backend issues, or automating workflows, cURL helps you see past frameworks and tools to the fundamentals that power modern systems. Mastering cURL early builds a strong foundation that makes every backend technology you learn afterward easier and more intuitive.




