Skip to main content

Command Palette

Search for a command to run...

Understanding CURL: Talking to Servers from the Terminal

cURL: The digital postman - Deliver Request & Responses between Client & Server

Updated
5 min read
Understanding CURL: Talking to Servers from the Terminal
M
Backend-focused developer learning. I write about internal workings, fundamentals, and real project learnings. Sharing my journey, insights, and mistakes while building in public.

This article will walk you through the concept of cURL, after this article you will understand what is cURL, how to interact with servers and handle API.

Let's go steps wise steps...


First Thing -- What is Server?

A server is simple a computer which is never shut down. A server:

  • Receive Request

  • Runs applications

  • Store data

  • Send Response

When ever you open browser and search anything:

  • Your browser send a request to the server.

  • The server send back the response (in HTML, JSON, image, CSV, other format).

So internet is collection of computer work on request --> response model.


What is cURL?

cURL means Client-URL (i.e., Client Uniform Resource Locator).

It is a tool that let you sent request to a server from the terminal and receive the reposes in the terminal. In simple word it means, you will send a request from the terminal --> to server, server --> send response --> response is printed in the terminal.

Think of cURL as a WhatsApp for servers, you send a text-request (command) and receive a text (response).


Why do Programmers need cURL?

Programmer work with data, they creates interfaces to interact data to get some result. So programmers uses cURL because:

  • Browser hide a lot of inter-details

  • API don't have proper interface

  • Backend developer interacts with data

  • cURL is simple -- easy to use -- no step required

with cURL, you get:

  • see API responses

  • interact with servers


cURL setup

1. Check if cURL is installed

Some system have pre-install cURL in it. To check where cURL is present in the system or not.

Run this command:

On Windows
Open Command Prompt or PowerShell and run:

curl --version

if cURL is installed, it will display version information.
if not installed, it will print and error: 'curl' is not recognized as an internal or external command

On Linux/ macOS
Open Terminal and run:

curl --version

If installed, it shows version details.
If not installed, the output will be: command not found

2. Basic Syntax of cURL

curl [options] [URL]

Make your First Request using cURL:

Run the Command [Request]:

curl https://www.google.com

Output [Response]:

<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-IN"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="Kte3U_JUNEMObrAkjzR0gA">(function(){var _g={kEI:'mOalafOhGdaTseMPvPzR0Ac',kEXPI:'0,203063,2,1101138,2935842,48791,46127,344796,270476,30674,5231880,36811338,25381059,8944,56232,39766,74608,710,23254,37805,28334,48279,17344,13691,7714,33385,3050,2,26042,2884,19843,46337,9923,10758,10122,1760,6437,9742,2646,2251,21995,14505,1383,2,1,1515,3355,2,195,5813,2,4205,3,3213,12885,2,874,2231,5089,19,3008,26,769,4081,4,5386,25902,1250,5337,311,534,846,1200,2,12,16,1545,3,5941,1010,1747,4,12116,3077,4,2243,537,5,1113,389,4,2647,5,5568,298,3414,2842,2997,1275,7,1784,7,1049,2,1912,1947,8510,2,3006,2718,9,602,59,37,1553,4,5522,389,933,3664,1,2,803,3,1359,2,4932,60,10,204,441,158,2,1645,191,4,1928,4,1634,544,4,1568,1033,1399,187,259,1846,5,259,5,197,1921,209,236,19,1332,89,119,4,385,1247,732,356,3,2004,5,40,2569,4,3845,4,354,1696,264,107,5,4,970,4,64,902,5,1125,3,2,815,2935,4,32,4,844,1859,4,40,4,1428,426,256,4,438,323,1,575,1777,1865,41,5,1,1184,4,14,3,2,1,447,4,730,5,75,4,1940,4,1432,990,572,1,1091,1,265,702,4905,1788,14,178,329,823,953,500,1017,8,5,14,57,258,695,8,2244,4,281,264,563,2916,18,4,2,36,847,3294,639,4,1411,1212,4,138,4,2138,4,939,22,4,463,152,1,21007878,5,2253,739,4,2960,3,3237,4647,607,2,706,852,3,11875,536,2,3655,3,746,6,1149,3,5578,2,1971,2,642,48,2,6491963,7858,2490,108497,1890112,14330060,4360024,1082,83,507,5,732,506,3,1452,881,113,3,12,1,600,4,65,388,2,972,195,4,550,219,3,2,2,2,550,4,1055,5,883,2,683,5,3371,1,875,118,1,2,5,44,2,12,16,362,682,684,1,2,642,207,7,1485,417,139,4592,5,433,774,784,207,5,163,129,5,142,4,228,359,309,2,338,971,718,348,471,165,8,240,999,582,4,73,1038,331,600,477,665,100,1160,5,2,8,24,388,301,4,190,8,14,30,652,1,1,1314,4,300,304,70,212,125,4,4,2,2,3,1,2,3,2,2,1,2,3,2,2,1,3,2,2,1,3,1,2,2,2,3,2,2,2,1,3,2,2,2,2,1,3,2,2,1,3,2,1,3,2,1,2,11,2,2,1,3,1,10,2,2,2,2,3,10,2,1,3,1,3,9,2,3,1,2,2,2,3,1,3,1,3,1,2,2,3,1,2,3,2,1,2,2,2,3,2,2,2,2,2,2,1,2,2,2,2,3,2,2,1,3,2,1,2,3,2,9,3,2,2,2,2,9,3,1,2,2,3,10,2,1,3,1,2,277,60,265,43,151,5,1362,4,49,67,346,242,1,2,132,686,395,121,617,8,85,1,337,348,452,4,112,10,887,416,3,2,2,2,355,288,4,131,204,364,2717,640,1703,9,666,125,293,3,605,3,2,2,2,721,520,434,636,834,175,23,2760,333,4,778,117,449,424,743,27,449,20,3,2,2,2,563,897,28,128,325,302,261,168,557,856,778,304,12,2386',kBL:'PWFU',kOPI:89978449};(function(){var a;((a=window.google)==null?0:a.stvsc)?google.kEI=_g.kEI:window.google=_g;}).call(this);})();(function(){google.s ... [more...]

What just happened 😮!!

  • cURL just send a request to www.google.com

  • The server take request and send back response, In this server sends HTML code as response

  • cURL printed the response in your terminal

You just access the webpage using terminal.


List of basic cURL options:

1. -V or --version

Shows curl version information

curl -V

2. -I

Fetches only HTTP headers (HEAD request).

curl -I https://example.com

3. -i

Includes response headers in the output.

curl -i https://example.com

4. -o <file>

Saves output to a file.

curl -o page.html https://example.com

5. -O

Saves file with original name from URL.

curl -O https://example.com/file.zip

6. -L

Follows redirects.

curl -L https://example.com

7. -X <METHOD>

Specifies request method (GET, POST, PUT, DELETE).

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

8. -d <data>

Sends data (used with POST).

curl -d "name=Minsu&age=24" https://example.com/api

9. -H <header>

Adds custom HTTP header.

curl -H "Content-Type: application/json" https://example.com

10. -u user:password

Used for basic authentication.

curl -u user:pass https://example.com

11. -k

Ignores SSL certificate verification (not recommended for production).

curl -k https://example.com

12. -v

Verbose mode (shows request and response details).

curl -v https://example.com

Understanding Request and Response

Every cURL interaction has two parts:

1. Request

This is what you send:

  • Where you want to go (URL)

  • What you want (GET, POST)

  • Optional data

2. Response

This is what the server sends back:

  • Status code (success or error)

  • Data (HTML, JSON, text)

You ask → Server answers.


Seeing the Response Status (Basic Insight)

Sometimes you want to know:

  • Did the request succeed?

  • Did something go wrong?

You can tell cURL to show basic response info:

curl -i https://example.com

You may see:

  • 200 OK → success

  • 404 Not Found → page doesn’t exist

  • 500 Internal Server Error → server problem

Don’t worry about memorizing these yet—just know they exist.

Introducing GET and POST (Only What You Need)

GET – Asking for Data

By default, cURL makes a GET request.

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

Use GET when you want to read data.


POST – Sending Data

POST is used when you want to send data to a server.

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

For now, just remember:

  • GET → fetch data

  • POST → send data

We’ll avoid heavy flags and details until you’re comfortable.


-—» THE END, see you in Next Article😁👍