Imagine you're sending a quick message to a friend over the internet. Your browser (like Chrome or Firefox) does this automatically when you visit a website it asks the website for the page, and the website sends it back.
cURL is like a tiny messenger you control from your computer's terminal or command prompt. It stands for client URL basically a command-line tool that lets you send requests to servers and get replies, without needing a browser.
It's free, works on Windows, Mac, Linux and is already installed on most computers.
Think of it as your personal way to chat with web servers directly from the command line.
Here's a simple visual of how cURL talks to a server:
Why Do Programmers Need cURL?
As a beginner in web dev, you'll build or use APIs (Application Programming Interfaces) these are like doors that let your code talk to other services (like fetching weather data, user info or posting a tweet).
cURL is perfect because:
- It's fast for testing: You can quickly check if an API works without writing full code.
- It helps debug: See exactly what the server sends back.
- No browser needed: Great for servers, scripts, or when you're learning backend stuff.
- Builds confidence: Start simple in the terminal before using it in code (like JavaScript's fetch or Python's requests).
Making Your First Request Using cURL
Open your terminal (on Mac/Linux: Terminal app and on Windows: Command Prompt or PowerShell).
Type this super simple command and press Enter:
curl https://chaicode.com
What happens? cURL sends a message to chaicode.com asking for its homepage, and the server sends back the HTML code of the page you'll see a bunch of text in your terminal (that's the webpage's code!).
StatusCode : 200
StatusDescription : OK
Content : <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link
rel="icon"
type="image/svg+xml"
href="/assets/favicon-light-B_XE0b_A.svg"
media="(prefers-color...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
Age: 4316
cache-status: "Netlify Edge"; hit
Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.clou...
Forms : {}
Headers : {[Transfer-Encoding, chunked], [Connection, keep-alive], [Age, 4316], [cache-status, "Netlify
Edge"; hit]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 2143
That's it your first reques.
To make it cleaner, try this public test API:
text
curl https://jsonplaceholder.typicode.com/todos/1
You'll get back some JSON data like:
StatusCode : 200
StatusDescription : OK
Content : {
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
access-control-allow-credentials: true
nel: {"report_to":"heroku-nel","response_headers":["Via"],"max_age":3600,"success_fraction":0.01,"f
ailure_fraction":0.1...
Forms : {}
Headers : {[Connection, keep-alive], [access-control-allow-credentials, true], [nel, {"report_to":"heroku-nel
","response_headers":["Via"],"max_age":3600,"success_fraction":0.01,"failure_fraction":0.1}],
[pragma, no-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 83
Understanding Request and Response
Every time you talk to a server (with browser or cURL), it's a request to response conversation.
- Request: What you send (like "Hey server, give me this page!").
- Response: What comes back (the page content & some info).
A basic response has:
- Status code like 200 OK (good!), 404 Not Found (oops, page missing), 500 (server error).
- Headers give extra info (like content type: "this is JSON").
- Body is the actual data (HTML, JSON, etc.).
Try this to see headers too:
curl -i https://chaicode.com
Here's a simple diagram of a basic HTTP request and response:

Browser or cURL sends request with method, headers, etc and Server replies with status, headers & content.
Browser does the same thing behind the scenes, but cURL lets you see it directly.
Using cURL to Talk to APIs (Just GET and POST)
Most beginner APIs use two main methods:
- GET: Ask for data (like reading a list of posts). Default in cURL.
- POST: Send data (like creating a new user or submitting a form).
GET example (fetch a post):
curl https://jsonplaceholder.typicode.com/posts/1
POST example (send fake data to create a post):
curl -X POST \
-H "Content-Type: application/json" \
-d '{"title": "My First Post", "body": "Hello world!", "userId": 1}' \
https://jsonplaceholder.typicode.com/posts
- -X POST: Tells cURL to use POST method.
- -H: Add a header (here, saying data is JSON).
- -d: The data you're sending (in quotes).
The server replies with your new post (fake API echoes it back). Try it!
This is how you test APIs before coding them in your app.
Common Mistakes Beginners Make with cURL
- Forgetting quotes around URLs with ? or & (special characters break things). Fix: Use "quotes" like "https://api.com?key=value".
- Ignoring status codes — if you get error data but don't notice 404 or 401, it confuses you. Always use -i to see status.
- Overloading with too many flags too soon — start simple! Add one option at a time.
- Not using verbose mode for debugging: Add -v (or -vv for more) to see full details when something fails.
- Forgetting the method: For POST/PUT, you need -X POST or it defaults to GET.
- Sending wrong data format: Always match -H "Content-Type: application/json" if sending JSON.
Pro tip: When stuck add -v and read what cURL prints as it tells you a lot.
Connect with Me
Follow me on LinkedIn: https://www.linkedin.com/in/himazing

Top comments (0)