Skip to main content

Command Palette

Search for a command to run...

Mastering cURL – A Developer's Best Friend for Testing APIs

Updated
3 min readView as Markdown

Over the past few days, I've been exploring how the Internet works—from computer networks to DNS and DNS records.

Today, I learned about one of the most useful tools every developer should know: cURL.

At first, I thought cURL was just a command for opening websites from the terminal. But after learning more, I realized it's much more powerful than that.

Developers use cURL every day to test APIs, debug servers, send requests, download files, upload data, and much more.

Let's explore the basics.


What is cURL?

cURL (Client URL) is a command-line tool used to transfer data between a client and a server using different network protocols.

It supports protocols like:

  • HTTP

  • HTTPS

  • FTP

  • SMTP

  • IMAP

  • LDAP

  • And many more.

In simple words:

cURL lets you communicate with servers directly from your terminal.


Your First cURL Command

Open your terminal and type:

curl https://example.com

The server responds with the HTML of the webpage.

No browser required.


Fetch HTTP Headers

Sometimes we only want the response headers.

curl -I https://google.com

This returns information such as:

  • HTTP Status Code

  • Content-Type

  • Server

  • Date

  • Cache-Control

Very useful while debugging websites.


Send a GET Request

Most APIs use GET requests to retrieve data.

Example:

curl https://jsonplaceholder.typicode.com/posts/1

The server responds with JSON data.


Send a POST Request

To send data to a server:

curl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{"title":"Hello","body":"Learning cURL","userId":1}'

This sends JSON data to the API.


Add Custom Headers

Many APIs require authentication.

Headers can be added using:

curl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com

This is commonly used with REST APIs.


Download a File

cURL can download files directly.

curl -O https://example.com/image.jpg

The file is saved in your current directory.


Follow Redirects

Some websites redirect requests.

Use:

curl -L https://google.com

The -L flag tells cURL to automatically follow redirects.


Verbose Mode

Want to see everything happening behind the scenes?

curl -v https://google.com

This displays:

  • DNS Lookup

  • TCP Connection

  • SSL Handshake

  • HTTP Request

  • HTTP Response

It's a great way to understand how clients communicate with servers.


Why Every Developer Should Learn cURL

Whether you're a frontend developer, backend developer, or DevOps engineer, cURL is incredibly useful.

You can use it to:

  • Test REST APIs

  • Debug backend services

  • Verify server responses

  • Check HTTP headers

  • Download files

  • Authenticate API requests

  • Learn how HTTP works

It's one of those tools that seems simple but becomes invaluable in real-world development.


My Biggest Takeaway

Before today, I thought browsers were the only way to interact with websites.

Now I understand that browsers are just one type of client.

Using cURL, I can communicate directly with servers, inspect responses, and test APIs without writing any code.

Learning cURL has also helped me understand HTTP requests more clearly, and I can already see how useful it will be when I start building REST APIs with Node.js.

Every day, another piece of the web development puzzle falls into place.

1 views

100 Days of Code: My Journey to Becoming a Full Stack Developer

Part 6 of 50

Welcome to my 100 Days of Code journey! In this series, I'll document my daily progress as I learn Full Stack Web Development from the ground up. Every post will cover what I learned, challenges I faced, mistakes I made, and the projects I built. My goal is not just to complete 100 days but to become a better developer through consistency, discipline, and learning in public. Topics I'll cover include: • Git & GitHub • HTML, CSS & JavaScript • React.js • Node.js & Express • MongoDB • APIs • Real-world Projects • AI tools for Developers Whether you're just starting out or revising your fundamentals, I hope this journey helps you learn alongside me. Let's build, learn, and grow together! 🚀

Up next

Understanding HTTP vs HTTPS – How the Web Communicates Securely

Over the past few days, I've learned how computers communicate through networks, how DNS helps locate websites, and how tools like cURL send requests to servers. That naturally led me to another impor

More from this blog

T

TheSaurceCode

73 posts

Documenting my journey to becoming a Full Stack Developer through daily blogs, coding challenges, projects, tutorials, and lessons learned. Learn, build, and grow with me