Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL

Stop Using Your Browser: A Beginner’s Guide to cURL

Published
4 min read

Introduction: Talking to the Machine

Before we type a single command, let us talk about Servers.
A server is just a computer that lives somewhere else (in the cloud, a data center, or a basement). Its job is to hold information—like web pages, user data, or images—and wait for someone to ask for it.
Usually, you talk to a server using a Web Browser (like Chrome or Firefox).

  1. You type a URL.

  2. The browser sends a request.

  3. The server sends back code (HTML).

  4. The browser turns that code into a beautiful, clickable page.

But what if you do not want the beautiful page? What if you are a developer who just wants the raw data, or you want to automate checking if a server is alive without opening a heavy browser window?
That is where cURL comes in.

What is cURL (in very simple terms)

cURL (Client URL) is a command-line tool that lets you talk to a server directly from your terminal. Think of it as a text message for computers.

  • Browser: Calls the server, has a video chat, and puts makeup on the response.

  • cURL: Sends a concise text message (Hey, give me that file) and gets a text reply (Here it is).

It does not deal with fonts, colors, or buttons. It deals with raw data.

Why programmers need cURL

Programmers use cURL because it helps with tasks that normally require a browser or an app:

  • Testing a website response quickly (without opening Chrome)

  • Checking if a server is working (especially during backend development)

  • Talking to APIs to send/receive data

  • Debugging when something fails (wrong URL, auth issue, server error)

Making your first request using cURL

Let us try the simplest possible example. We are going to fetch a webpage. Open your terminal (on Linux, Mac, or Windows PowerShell) and type this:
Bash
curl https://example.com

What just happened?
You will see a chunk of code appear on your screen that looks like this:

HTML
<!doctype html>
<html>
<head>
<title>Example Domain</title>
...
</html>

This is the HTML. This is exactly what your browser sees before it draws the webpage. You just talked to the server manually. This works because cURL sends a GET request by default in a normal fetch scenario.

Understanding request and response

When you use cURL, you are doing a basic HTTP conversation:

  • Request: what you ask the server for

  • Response: what the server sends back

A response usually includes:

  • a status code (like 200, 404, 500)

  • headers (extra info about the response)

  • and sometimes a body (the actual data, like HTML or JSON)

If you want to see the status and headers (keeping it beginner-friendly), you can do:

curl -i https://example.com

  • 200 means success

  • 404 means not found

  • 500 means server error

To see the "conversation" details (headers), add the -v (verbose) flag:
curl -v https://example.com

Using cURL to talk to APIs

APIs are basically endpoints on a server that return data (often JSON) instead of a full webpage.
A) GET request (read data)
curl https://api.example.com/users
GET is used to retrieve data.

B) POST request (send data): POST is used to submit data to the server (often creating or updating something).A beginner-friendly POST example:

curl -X POST -H "Content-Type: application/json" -d '{"name":"Rajesh"}' http://api/example.com/users

  • -X POST tells cURL you’re sending a POST request

  • -H sets a header (here, telling the server you’re sending JSON)

  • -d sends the data (body)

Common mistakes beginners make with cURL

These are mistakes I found easy to make early on:

  1. Forgetting quotes in JSON

    • If your JSON has spaces or special characters, missing quotes can break the command.
  2. Using the wrong URL (http vs https, wrong path)

    • A small typo can lead to 404 or connection errors.
  3. Mixing GET and POST confusion

    • GET is for reading; POST is for sending.
  4. Not understanding what the response means

    • If you see a 4xx/5xx status, it’s not “cURL failed”, it often means the server responded with an error.
  5. Jumping into too many flags too soon

    • It is better to master: curl URL —> understand response —> then learn small additions like -i, -H, and -d.

Conclusion

cURL is basically a confidence tool for beginners, it lets you talk to a server directly and understand what is happening behind the scenes. Once I understood request -> response, cURL stopped feeling like a terminal trick and started feeling like a real developer skill.
cURL is the Swiss Army Knife of the web. Whether you are testing a connection, debugging an API, or downloading a file, it is the most reliable tool in your belt.
Start by fetching example.com. Once you are comfortable seeing that raw HTML flow onto your screen, you have taken your first step into the backend world.