What is cURL and How to Use It Effectively
Using cURL: A Step-by-Step Instruction

Frontend Developer 💻 | Fueled by curiosity and Tea ☕ | Always learning and exploring new technologies.
Search for a command to run...
Using cURL: A Step-by-Step Instruction

Frontend Developer 💻 | Fueled by curiosity and Tea ☕ | Always learning and exploring new technologies.
No comments yet. Be the first to comment.
From typing a URL to a fully loaded webpage, data travels through a global network of fiber cables, routers, and servers. This series covers core concepts every CS engineer should know to understand how the modern web works.
Understanding TCP and UDP Protocols
The Hidden Pipeline Behind Every AI Response

Lets understand Linux what I understand

Let's understand JSON Web token authentication in Node.js

Understand serving of files using express

We will understand how to upload files using Express and Multer

On this page
Before diving into cURL, let’s first understand the basics.
When you open a website or use an app, your device is not doing all the work.
It asks another computer on the internet to send data. That computer is called a server.
Examples:
When you open Google → your browser talks to Google’s server
When your app shows products → it talks to an API server
When you submit a form → data is sent to a server
So every time something loads from the internet, this is happening:
Client → sends request → Server → sends response
Usually, the client is:
A browser (Chrome, Firefox)
A mobile app
Postman
But sometimes developers want to talk to the server directly, without any UI.
That is where cURL comes in.
cURL is a tool that lets you send requests to a server from the terminal and see the raw response.
Think of it as:
A browser for developers, inside the terminal.
You type a command, the request is sent, and the server sends back data.
cURL is a command-line tool used to send and receive data using URLs.
It can:
Request web pages
Talk to APIs
Send data to servers
Download files
But instead of clicking buttons, you type commands.
Developers use cURL because:
You can test if a server is working
You can test APIs without writing frontend code
You can debug request and response behavior
It works almost everywhere (Linux, macOS, Windows)
It is often the first tool used to check backend systems.
Let’s start with the simplest possible example.
curl https://jsonplaceholder.typicode.com/todos/1
This command:
Sends a request to the server
The server sends back data
cURL prints that data in the terminal
You will see something like:

This is exactly what a browser would receive, but now you are seeing it directly.
Every network call has two parts:
It contains:
The URL
The request method (GET, POST, etc.)
Optional data and headers
Example: “Give me todo item number 1.”
It contains:
Status code (success or error)
Data returned by the server
Example:
200 OK → success
404 Not Found → resource does not exist
And then the actual data (HTML, JSON, file, etc.).
cURL shows you the response body by default, which is usually what you care about first.
Most APIs work using HTTP requests.
GET is used when you want to fetch something.
curl https://jsonplaceholder.typicode.com/posts/1
Meaning: “Give me the post with ID 1.”

POST is used when you want to send new data to the server.
curl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{
"title": "Hello",
"body": "Learning cURL",
"userId": 1
}'
Here:
-X POST tells cURL to use POST
-H sends a header
-d sends the data
Meaning: “Create a new post using this data.”

The server may responds with the created object.
Sometimes you want to see what is happening behind the scenes.
Use:
curl -v https://api.github.com/search/users?q=satpalsinhrana
Verbose mode shows:
Request headers sent
Status code returned
Response headers
It will look something like:

This helps when:
Requests fail
APIs return unexpected errors
But for normal usage, you usually do not need -v.
By default, cURL prints everything in the terminal.
To save the response into a file:
curl -o google.html https://www.google.com
Now the data is written into google.html instead of the screen.
Sometimes you type google.com but the server moves you to www.google.com. By default, cURL stops at the redirect. Use -L (Location) to tell cURL to follow the trail to the final destination.
Example of Normal Request
curl google.com

Example of Following Redirecting Request
curl -L google.com

cURL supports many options, but you do not need most of them at the start.
For beginners, these are enough:
| Flag | Meaning | Simple Terms |
-v | Verbose | Show me Very much detail |
-o | Output | Write Output to a file |
-L | Location | Follow the new Location (Redirects) |
-X | Request Method | execute this method (GET/POST) |
-d | Data | Send this Data |
-H | Header | Add this Header |
Try this in your terminal:
curl wttr.in

Or, for a custom ASCII-style response, check out my server:
curl https://ascii.satpal.cloud/

If you can use cURL comfortably, you already understand how the web really works behind the UI.
“Understanding client and server is the first step to mastering the web.”
— Unknown
To uncover more secrets about the invisible infrastructure powering your daily life, be sure to read my full series on The Internet.
Check out the full series: The Internet by Satpalsinh Rana