Getting Started with cURL: Talking to Servers From Your Terminal

Why we need to talk to a server at all
Every time you visit a website, your browser is having a conversation with a server — a computer somewhere else, waiting to respond to requests. You ask, “give me this webpage,” and it answers, “here it is.” Browsers handle that entire conversation invisibly, behind a polished interface — but sometimes, especially as a developer, you want to have that exact same conversation directly, without a browser in the way.
That’s exactly what cURL lets you do.
What is cURL (In Very Simple Terms)
cURL is a command-line tool that lets you send a request to a server directly from your terminal, and see exactly what it sends back — no browser, no interface, just the raw conversation itself.
Think of it like sending a letter and getting a reply, except the letter is a request (“give me this data”) and the reply is whatever the server sends back — a webpage, some data, a confirmation, or an error.

Why Programmers Need cURL
Testing without building a UI first
Before writing any frontend code, developers often want to check: does this API actually work? What does it return? cURL answers that in seconds, directly from the terminal, without needing a button or a page to click.
Debugging exactly what’s being sent and received
When something’s not working, cURL lets you see the exact request going out and the exact response coming back — no browser layer potentially hiding or reformatting anything in between.
Working on servers without a browser
Many servers (especially in cloud and DevOps environments) are managed entirely through the terminal, with no graphical browser available at all. cURL is often the only practical way to check whether something is actually responding correctly.
It’s universal
cURL is available on nearly every operating system and is one of the most common tools referenced in API documentation — learning it means being able to follow along with almost any technical documentation you’ll encounter.
Making Your First Request Using cURL
The simplest possible cURL command just fetches a webpage:
curl https://example.comRun this, and your terminal fills with the raw HTML of that page — the exact same content your browser would receive, just displayed as plain text instead of a rendered page.

This is the entire foundation of cURL: point it at an address, and it shows you exactly what came back.
Understanding Request and Response
Every cURL command involves two halves: the request you send, and the response you get back.
The request
A request typically includes:
- A method — what kind of action you’re asking for (most commonly
GET, to retrieve something, orPOST, to send something) - A URL — where the request is going
- Sometimes, additional data — information you’re sending along with the request
The response
A response typically includes:
- A status code — a short number summarizing what happened (
200means success;404means "not found";500means the server had an error) - A body — the actual content returned, often a webpage’s HTML or, for APIs, structured data like JSON

Seeing the status code directly
curl -i https://example.comAdding -i includes the response's headers (including its status code) above the body, so you can see both at once — a small, genuinely useful addition once the basic command feels comfortable.
Using cURL to Talk to APIs
APIs are servers built specifically to exchange structured data (usually JSON) rather than webpages — and cURL works with them exactly the same way.
A basic GET request to an API
curl https://api.example.com/users/1This asks the API for information about user 1, and the response typically comes back as JSON:
{
"id": 1,
"name": "Aarav",
"email": "aarav@example.com"
}A basic POST request to an API
POST requests are used to send data to a server, rather than just asking for something back — commonly used to create something new:
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name": "Priya", "email": "priya@example.com"}'Breaking this down:
-X POST— tells cURL to send aPOSTrequest instead of the defaultGET-H "Content-Type: application/json"— tells the server the data being sent is JSON-d '{...}'— the actual data being sent along with the request

For now, GET (asking for data) and POST (sending data) cover the overwhelming majority of what you'll need as a beginner — there are other methods (PUT, DELETE, and others), but they're worth learning once these two feel comfortable.
Common Mistakes Beginners Make With cURL
Forgetting quotes around data
# Problem: unquoted JSON often breaks due to how the terminal interprets special characters
curl -X POST https://api.example.com/users -d {"name": "Priya"}
# Fix: wrap the data in quotes
curl -X POST https://api.example.com/users -d '{"name": "Priya"}'Forgetting the Content-Type header on POST requestsWithout telling the server the data is JSON, some APIs won’t parse it correctly, even if the data itself looks correct:
curl -X POST https://api.example.com/users -d '{"name": "Priya"}'
# May fail or misinterpret the data without this header:
curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"name": "Priya"}'Assuming no visible output means success
A cURL command that returns nothing isn’t necessarily broken — some successful responses are genuinely empty. Checking the actual status code (using -i, as shown earlier) is a more reliable way to confirm success than just looking at whether text appeared.
Mixing up GET and POST
Trying to send data with a plain GET request (which isn't designed to carry a request body the way POST is) is a common early confusion — remember, GET is for asking for something; POST is for sending something.
Not reading the status code at all
Beginners often focus only on the response body and skip the status code entirely — but the status code is often the fastest way to tell whether something actually succeeded, without needing to parse the full response first.

Final Takeaway
cURL strips away everything a browser normally handles for you invisibly, and lets you see — and control — the conversation with a server directly. A request goes out with a method and a URL; a response comes back with a status code and a body. GET asks for something; POST sends something. Once that basic shape feels natural, cURL becomes one of the fastest, most reliable ways to check whether an API is actually behaving the way you expect — no browser, no UI, just the request and the response, exactly as they really are.
Frequently Asked Questions
Is cURL the same as a browser?
> No — a browser sends requests too, but it also renders HTML, runs JavaScript, and manages a lot of complexity behind a visual interface. cURL sends the exact same kind of request, but shows you the raw response directly, without any of that rendering layer in between.
Do I need to memorize lots of cURL flags to get started?
> No — a plain curl <url> for GET requests, and curl -X POST -H ... -d ... for POST requests, cover the vast majority of beginner needs. Additional flags are worth learning gradually, as specific situations actually call for them.
What does it mean if my cURL command returns nothing?
> It doesn’t necessarily mean failure — some successful responses are genuinely empty. Adding -i to see the status code is a more reliable way to confirm whether the request actually succeeded.
Is cURL only used for testing APIs?
> No — it’s also commonly used for downloading files, checking whether a server is responding at all, and scripting automated requests as part of larger tools or deployment processes, beyond just manual API testing.
Originally published by Mr Madhukar
Read the complete article on Medium with full formatting & reader responses.