Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL

Published
•4 min read•View as Markdown

How your terminal talks to Server

Have you every wondered how websites, apps and APIs talk to each other? Have you ever thought how will behind the scene will look in this scenario? If yes, then this blog is for YOU!

To introduce you with cURL, we’ll start slowly from zero and built a mental model. cURL is a small yet powerful tool every programmer should know.

Believe me in this blog you won’t get bombarded with jargons, no overwhelming feeling will be there. Let’s go.


Firstly: What is a server?

To understand cURL, we first need understand what a server is? Cause server is the one we’ll be talking to.

A sever is just a computer connected to the internet who job is to:

  • Store data

  • Run applications

  • Respond when someone asks for something

When you open a website like www.google.com, your browser is basically saying:
“Hey server, can you send me the Google homepage?”

And the server replies with the data needed to show that page.

This asking and replying is the foundation of the web.


Why Do We Need to Talk to Server

Pretty question no? So basically as programmers, we constantly need to:

  • Fetch Data (users, posts)

  • Send Data (login info, forms, payments)

  • Test APIs

Usually, the browser does this talking for us.

But we programmers as very curious, so sometimes we directly want to talk to the server.

Thats where cURL comes in.


What is cURL?

cURL is a tool that lets you send messages to a server from the terminal.

Think of it like this:

  • Browser → talks to server using buttons and clicks

  • cURL → talks to server using commands

You type a command → server replies → you see the response

That’s it.


Browser vs cURL

Browser

  • Shows buttons, images, UI

  • Hides technical details

  • Made for users

cURL

  • Runs in the terminal

  • Shows raw responses

  • Made for developers

cURL only care about data


What Should be Your First cURL Request

Open your terminal and type the simplest command:

curl https://google.com

What just happened?

  • You sent a request to a server

  • The server sent back a response

  • cURL printed that response in the terminal

You just talked to a server without a browser.


Request and Response

Every conversation with a server has two parts:

1. The Request (What You Ask)

Includes:

  • Where you’re sending the request (URL)

  • What you want to do (GET, POST, etc.)

2. The Response (What you get back)

Includes:

  • Status → Did it work?

  • Data → HTML, JSON, text etc.

Example:

  • Status: 200 OK → Success

  • Data: The content you asked for

If something goes wrong, you might see:

  • 404 → Not found

  • 500 → Server error

These numbers are how servers talk back.


Introducing HTTP Methods

To keep things simple, we’ll only talk about GET and POST.

GET — Asking for Data

Its used when you want to fetch something.

curl https://jsonplaceholder.typicode.com/users

Meaning:
“Hey server, send me the users.”

POST — Sending Data

Used when you want to send something.

Conceptually:
“Hey server, here is some data. Do something with it.”


Using cURL to Talk to APIs

An API is just a server that speaks in data which is usually JSON.

When you use cURL with an API, you’re doing things like:

  • Getting user data

  • Sending form data

  • Checking if your backend works

For example:

curl https://jsonplaceholder.typicode.com/users

This response won’t be a webpage, it’ll be a raw data.

And that’s exactly what developers want.


Where cURL Fits in Backend Development

cURL is commonly used to:

  • Test API without writing code

  • Debug server responses

  • Check authentication issues

  • Understand request/response behaviour


Common Mistakes Beginners Make with cURL

Let’s save you some frustration.

1. Trying to learn all flags at once

You don’t need them yet. Start small.

2. Expecting a webpage UI

cURL shows data, not design.

3. Panicking over error codes

Errors are normal. They’re feedback.

4. Copy-pasting complex commands blindly

Understand the basics first, confidence beats complexity.


A Simple Mental Diagram (Visualize This)

You (Terminal)
     |
     |  cURL request
     v
  Server
     |
     |  Response (status + data)
     v
You (Terminal)

That’s the whole loop.


Final Thoughts

cURL isn’t scary. It’s not advanced magic.
It’s just a direct way to talk to servers.

Once this clicks, APIs stop feeling mysterious, and backend development starts making sense.