Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL

Updated
4 min readView as Markdown
Getting Started with cURL

Hey everyone! I’m just starting my journey as a technical writer, and today I want to talk about a tool that used to intimidate me: cURL.

When I first saw people typing cryptic commands into their terminal and getting walls of text back, I thought, "Why not just use a browser?" But after digging in, I realized it’s basically a superpower for talking to the internet. Let's break it down together!


What is a Server, anyway?

Before we talk about cURL, we need to understand who we’re talking to. Imagine you’re at a restaurant. You are the Client, and the kitchen is the Server.

  • The Server is just a computer somewhere else that holds information (like a website's code or a database).

  • To get that information, you have to "order" it.

Usually, our web browser (Chrome or Safari) does the ordering for us. But as programmers, we often need to talk to the server directly, without the "pretty" interface of a browser.


What is cURL?

cURL stands for "Client URL." Think of it as a way to send messages to a server directly from your terminal.

If a browser is like a high-end delivery app with photos and buttons, cURL is like sending a text message directly to the chef. It’s fast, lightweight, and works on almost every computer.


Why do Programmers even need it?

You might wonder, "Why not just use the browser?" Here is why cURL is a must-have in your toolkit:

  • Speed: It’s way faster to type a command than to wait for a heavy website to load.

  • Automation: You can write scripts that use cURL to check if a website is down or to download files automatically.

  • Testing: If you’re building an app, you need to check if your server is sending back the right data. cURL is the cleanest way to do that.

XP0nJmCn38Nt-nLlpjATMofOG2eBHyM064nYbQX9BjWkLVyzAQ6LRkgMF7-sFhsr6eaTSXgqfcW3WBjtvzxu4_So7vN5kO_nBzws3toAVgyWf5ZsFV_de5o2GlZxm6fzDB7yN2UFhy-RrSCqhPuoxLYNoyv9WrZKETWNepO4LTZiD7Orq8vYkGZwxSjcQMQdoWe_vqmbzFmCtTGIEYAGqVLKbw5mKJa3VWwCM60iEHPAuz1sqIjRjsShy1S0 (493×312)


Making Your First Request

Let’s stop talking and start doing! Open your terminal (Command Prompt on Windows or Terminal on Mac) and type this:

Bash curl https://www.google.com

What happened? You just sent a "GET" request to Google’s server. You’ll probably see a giant wall of HTML code fly past. That is exactly what your browser sees before it turns it into the Google homepage we all know.

NP51Jy9048Nl-oiczG0SR8b73WQ3CHp045eE7eVjM3QqitLcgl7VsnOZn3tjxdllUvdCKWt5kgPsUWxSec039-JoIu8PCPXqT2CTqPyhYHsNgrX7WRkNyTmub3uwOazRKiMAdkfGCNXY8t4ElVMXv2rsC2r8ci1Opn90XOFsUa-mu4EBR93umtupIgjEQbUYuH6L8DbJ4uqW9_aa6GsNgtC30-uVnm0ieFXkIM7YXzV9hDL5bc4RKX-RRC1Dt6Zi0nT07yc9IuLrKUnWFyoXvbw7CWdLoI2-NvqxYPvK0rTfchhn-zhz3wHjP2MOveRMAJpCvxE_weF-uWARmZCQPkjYkm6Ba7iXOhViKVr-VW00 (675×369)


Understanding the Conversation

When you send a request, the server sends back a Response. This usually consists of two parts:

  1. The Status Code: A 3-digit number telling you how it went.

    • 200 means "OK!"

    • 404 means "Not Found" (we’ve all seen that one).

  2. The Body: This is the actual data (HTML, text, or JSON).


Talking to APIs (The Fun Part)

APIs are how different apps talk to each other. Instead of sending back a whole webpage, an API usually sends back simple data (JSON).

Let's try a "GET" request to a real (and fun) API that gives us random facts about cats:

Bash curl https://catfact.ninja/fact

You’ll get back a neat little piece of data like: {"fact":"Cats have 32 muscles in each ear.","length":33}.

Sending Data (POST)

Sometimes you don't just want to get data; you want to send it (like submitting a form). We use POST for that.

  • GET: "Hey server, give me that file."

  • POST: "Hey server, here is some info I want you to save."

ROxDIiKm48NtUOhXkhakx0E8I2t-KEX2fLsu79EX1YSJI2PAtzu6gs9rDt2-S-PhisBI4jX8T0I7snH5IHmSf_xq02U3dr_qBk6ovNPw7E0uKbOlCumnyZVLSQ6Dwj2-rf6h-_vdWqYCGyLdp2jolLrh_aJCyTsO_VEckTnDdSFD6uaMP5x0HX6ocit_KcT_otq8v3mgWNwovZTnKJjVOhNmK2Xvob2rJRjo9V07 (696×191)


Common Mistakes Beginners (Like Me) Make

  1. Forgetting the Protocol: Always include https://. If you just type curl google.com, it might not work the way you expect.

  2. Getting Overwhelmed by Flags: You might see commands like curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}'. Don't panic! Start with simple GET requests until you feel comfortable.

  3. Typing Errors: One missing slash or a misspelled word will cause an error. Copy-paste is your friend!


Final Thoughts

cURL isn't just a "hacker tool"—it's a fundamental way to understand how the internet works. Start by just "cURLing" your favorite websites and seeing what they send back. Once you stop being afraid of the terminal, the whole web opens up to you!

Happy Learning!