Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL

Learn how to talk to servers using the cURL Command

Published
β€’3 min read
Getting Started with cURL
P

My name is 𝐏𝐫𝐚𝐀𝐚𝐬𝐑 and I talk about 𝗧𝗲𝗰𝗡-𝐊𝐧𝐨𝐰π₯𝐞𝐝𝐠𝐞, π—ͺπ—²π—―π——π—²π˜ƒ, π——π—²π˜ƒπ—’π—½π˜€ and π—Ÿπ—Άπ—³π—²π˜€π˜π˜†π—Ήπ—².

If you are learning backend development, APIs, or even basic web concepts, you will hear the word cURL again and again. At first it looks scary a black terminal, strange commands, and confusing responses.

This blog is written to remove that fear.

No overload. Just clear thinking.

❀ Before cURL: What is a Server?

β€· A server is simply a computer that is always connected to the internet and waits for requests.

Examples of what servers do:

  • Send a webpage (HTML, CSS, JS)

  • Return user data from a database

  • Accept form submissions

  • Provide APIs for mobile apps

Whenever you:

  • Open a website

  • Submit a login form

  • Scroll Instagram

You are talking to a server.

❀ How Do We Talk to a Server?

‑ To talk to a server, we send a request.

That request contains:

  • What we want (data, page, action)

  • Where we want it from (URL)

  • Sometimes extra data (login info, form data)

‑ The server then sends back a response.

That response contains:

  • Status (success or failure)

  • Data (HTML, JSON, text, etc.)

❀ Where Does cURL Come In?

β€· Normally, browsers send requests for us.

But programmers often want to:

  • Test APIs

  • Debug backend issues

  • Call a server without a browser

  • Automate requests

This is where cURL is used.

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

Think of it as:

Terminal β†’ Server β†’ Response

❀ What is cURL ?

‑ cURL = Command Line URL tool

‑ cURL is a way to send messages to a server using text commands.

No UI. No buttons. Just pure communication.

❀ Why Programmers Need cURL ?

β€· Programmers use cURL because:

  • It works everywhere (Linux, Mac, Windows)

  • No browser required

  • Perfect for backend and API testing

  • Helps understand how HTTP really works

❀ Understanding Request and Response

‑ Request (What You Send)

A basic HTTP request includes:

  • Method (GET / POST)

  • URL

  • Headers (optional for now)

  • Body (only for POST)

Example :

GET / HTTP/1.1

Host: prakashtsx.me

‑ Response (What You Get Back)

A response includes:

  • Status code (200, 404, 500)

  • Headers

  • Data (HTML, JSON, text)

Example :

HTTP/1.1 200 OK

Content-Type: text/html

<html>...</html>

❀ Status Codes :

  • 200 β†’ Success

  • 404 β†’ Not Found

  • 500 β†’ Server Error

❀ Using cURL to Talk to APIs

APIs usually return JSON, not HTML.

Example:

curl https://api.github.com

We will see JSON data in response.

This is how:

  • Frontend talks to backend

  • Mobile apps talk to servers

  • Services talk to other services

❀ GET vs POST (Only What We Need)

β€· GET

  • Used to fetch data

  • Default method in cURL

curl https://api.example.com/users

β€· POST

  • Used to send data

curl -X POST https://api.example.com/login

❀ Browser Request vs cURL Request (Conceptual)

Browser:

  • UI + request + rendering

cURL:

  • Only request + response

Same protocol. Same server. Different interface.

❀ Where cURL Fits in Backend Development

cURL helps you:

  • Test APIs before frontend exists

  • Debug server issues

  • Understand HTTP deeply

  • Think like a backend engineer

Networking

Part 4 of 7

In this series I have write blogs related to computer networks.

Up next

How DNS Resolution Works

Breaking Down DNS Resolution with Real dig Examples