A Beginner’s Guide to cURL: Making Web Requests from the Command Line

What Exactly Is cURL?
cURL (short for Client URL) is a command-line tool used to transfer data between a client and a server using URLs. In simple terms, it lets you send and receive data over the internet from the terminal—without a browser.
Developers use cURL to test APIs, download files, send HTTP requests, debug network issues, automate workflows, and inspect server behavior. Because it is scriptable, lightweight, and extremely reliable, cURL is a foundational tool in backend development, DevOps, cloud engineering, and security testing.
cURL was created in 1997 by Daniel Stenberg, and it is still actively maintained today as open-source software. Its underlying library, libcurl, powers millions of applications, devices, servers, and embedded systems. It is estimated that billions of installations exist globally—often invisibly—inside operating systems, CI pipelines, containers, and software products.
Today, cURL supports a wide range of protocols including HTTP/HTTPS, FTP, SFTP, SCP, SMTP, POP3, IMAP, LDAP, MQTT, SMB, and more. This broad protocol support makes cURL a universal networking tool across platforms and industries.
Why Developers Use cURL (The Problems It Solves)
Browsers are built for humans. Servers are built for machines. cURL allows developers to talk directly to servers from the command line, without clicking buttons or filling forms.
curl https://example.com
This fetches exactly what the server sends—no UI, no styling, just data.
Before building a full app, developers often need to check if an API works. cURL lets you send requests instantly, without setting up a project or writing any program.
curl https://api.example.com/users
In one command, you can see if the API is reachable and returning data.
Many applications send data to servers—logins, forms, JSON, files. cURL allows developers to send data manually, which helps understand how real applications communicate.
curl -X POST https://api.example.com/message
-d "hello=world"
This mirrors what a real app does behind the scenes.
Downloading files, calling APIs, or triggering actions repeatedly can be automated using cURL. This saves time and avoids manual errors.
curl -O https://example.com/file.zip
Impact:
cURL helps beginners understand how the internet works at a practical level. It removes complexity, builds confidence, and gives developers a simple way to interact with servers using clear, repeatable commands.
Installation:
cURL comes preinstalled in most systems these days, so there's a good chance you already have it. To check, just run:
curl --version
If it's not there, no worries! Here's how to get it on your system:
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install curl
macOS:
brew install curl
Windows:
Windows 10 (version 1803 and above) already has cURL built-in. If you're on an older version, grab it from https://curl.se/windows/
Basic Commands
Alright, let's dive into the actual commands. The basic syntax is super simple:
curl [options] [URL]
Fetching Data (GET Request)
Makes a basic GET request and displays the response in your terminal.
curl https://jsonplaceholder.typicode.com/posts/1
Use -v to see detailed request/response info including headers; this is useful for debugging.
curl -v https://jsonplaceholder.typicode.com/users
Saving Files 💾
Use -O to save the file with its original name from the server.
curl -O https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
Use -o to save with a custom filename of your choice.
curl -o my-gitignore.txt https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
Chain multiple -O flags to download multiple files at once.
curl -O https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore -O https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
Viewing Headers 🔍
Use -I to fetch only the response headers (HEAD request) - great for checking status codes without downloading content.
curl -I https://api.github.com
Use -i to include headers along with the response body.
curl -i https://jsonplaceholder.typicode.com/posts/1
Following Redirects 🔄
Add -L to automatically follow HTTP redirects until reaching the final destination.
curl -L https://github.com
POST Requests 📤
Use -X POST with -d to send form data to the server.
curl -X POST https://jsonplaceholder.typicode.com/posts \
-d "title=foo&body=bar&userId=1"
Add a Content-Type: application/json header when sending JSON data.
curl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{"title":"foo","body":"bar","userId":1}'
Use @filename to send data from a file instead of typing it inline.
curl -X POST https://jsonplaceholder.typicode.com/posts \
-d @data.json
PUT Requests ✏️
Use -X PUT to update existing resources on the server.
curl -X PUT https://jsonplaceholder.typicode.com/posts/1 \
-H "Content-Type: application/json" \
-d '{"title":"updated title","body":"updated body","userId":1}'
DELETE Requests 🗑️
Use -X DELETE to remove resources from the server.
curl -X DELETE https://jsonplaceholder.typicode.com/posts/1
Custom Headers 🎯
Use -H to add custom headers like authentication tokens or content types.
curl -H "Authorization: Bearer your_token_here" \
-H "Content-Type: application/json" \
https://api.github.com/user
Stack multiple -H flags for multiple headers.
curl -H "Accept: application/json" \
-H "User-Agent: MyApp/1.0" \
https://jsonplaceholder.typicode.com/posts
Working with Cookies 🍪
Use -b to send cookies with your request.
curl -b "session=abc123; user=john" https://httpbin.org/cookies
Use -c to save cookies from the response to a file.
curl -c cookies.txt https://httpbin.org/cookies/set/session/abc123
Use -b with a file to send previously saved cookies.
curl -b cookies.txt https://httpbin.org/cookies
Combine -b and -c to both read and save cookies in one request.
curl -b cookies.txt -c cookies.txt https://httpbin.org/cookies
Using a Proxy 🌐
Use -x to route your request through a proxy server.
curl -x http://proxy.example.com:8080 https://api.github.com
Include credentials in the proxy URL if authentication is required.
curl -x http://username:password@proxy.example.com:8080 https://api.github.com
Use --socks5 for SOCKS5 proxy connections.
curl --socks5 127.0.0.1:9050 https://api.github.com
File Uploads 📁
Use -F to upload files as multipart/form-data.
curl -F "file=@/path/to/file.jpg" https://httpbin.org/post
Request Timing ⏱️
Use -w with format variables to display request timing information.
curl -w "\nTime: %{time_total}s\n" -o /dev/null -s https://jsonplaceholder.typicode.com/posts
Hands-On Experience: Cool Things You Can Do with cURL 🚀
Now that you know the basics, let's have some fun! Here are some interesting APIs you can try right now in your terminal—no API keys, no setup required.
Get a beautiful ASCII art weather forecast for any city:
curl wttr.in/London
Want just a quick one-liner?
curl "wttr.in/NewYork?format=3"
You can even customize it by your current location:
curl wttr.in
Check real-time exchange rates:
curl rate.sx/1btc
Convert between currencies:
curl rate.sx/100usd@eur
See historical rates:
curl rate.sx/btc@2020-01-01
Get a completely useless but entertaining fact (just the text, no JSON):
curl -s https://uselessfacts.jsph.pl/api/v2/facts/random?language=en | python -c "import sys, json; print(json.load(sys.stdin)['text'])"
What's happening here?
curl -sfetches the data silently (no progress bar)python -cruns a small Python script to parse the JSON and extract just the text field
- Programming Jokes 😄
Need a laugh? Get a random programming joke:
curl https://v2.jokeapi.dev/joke/Programming
Want only safe-for-work jokes?
curl "https://v2.jokeapi.dev/joke/Programming?safe-mode"
Get a specific type (single-part joke):
curl "https://v2.jokeapi.dev/joke/Programming?type=single"
Try it yourself! Run these commands in your terminal and see what you get. These APIs are perfect for understanding how real-world HTTP requests work, and they're actually fun to play with!
Your Next Steps with cURL
You've just learned one of the most powerful tools in a developer's toolkit. cURL might seem simple on the surface, but you now have the foundation to interact with virtually any web service, API, or server on the internet—all from your command line.
The beauty of cURL is that the more you use it, the more indispensable it becomes. Start small: test an API you're curious about, automate a repetitive download, or debug why a request isn't working in your application. Before long, you'll find yourself reaching for cURL instinctively whenever you need to understand what's really happening between a client and a server.
Remember, every major application you use—from mobile apps to web platforms—is making requests just like the ones you've practiced here. You now have the power to peek behind the curtain, experiment freely, and truly understand how the modern internet works at its core.
So open your terminal, pick a command from this guide, and start exploring. The internet is waiting for you to talk to it directly.
Happy curling! 🚀
Comments
Join the discussionNo comments yet. Be the first to comment.






