Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL

Updated
2 min read

What is cURL? (Explained Simply)

Before understanding cURL, let’s understand what a server is.


What is a server and why do we talk to it?

A server is just another computer on the internet that:

  • stores data

  • runs applications

  • sends responses when asked

Whenever you:

  • open a website

  • log in to an app

  • fetch data from an API

Usually, the browser does this talking for you.
But programmers often need to talk to servers directly.

That’s where cURL comes in.


What is cURL (very simple)?

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

Think of cURL as:

“A browser without buttons or visuals”

Instead of clicking links, you type commands.

https://media2.dev.to/dynamic/image/width%3D800%2Cheight%3D%2Cfit%3Dscale-down%2Cgravity%3Dauto%2Cformat%3Dauto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4061u6jlu03xspsnnmh.png

https://www.twilio.com/content/dam/twilio-com/global/en/blog/legacy/2022/http-methods-requests-curl/HTTP_Request_Flow_1.png


Why do programmers need cURL?

Programmers use cURL to:

  • Test APIs

  • Check if a server is working

  • See raw responses from servers

  • Debug backend issues

cURL is useful because:

  • It’s fast

  • It works everywhere

  • It shows exactly what the server sends back


Your first cURL command (simplest possible)

curl https://example.com

What this does:

  • Sends a request to the server

  • Fetches the webpage content

  • Prints the response in the terminal

This is similar to opening a website — just without the browser UI.


Understanding request and response

Every server communication has two parts:

Request (what you ask)

  • “Give me this page”

  • “Send me this data”

Response (what server replies)

  • Status (success or error)

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

https://mdn.github.io/shared-assets/images/diagrams/http/messages/http-2-connection.png


GET and POST (only the basics)

GET – asking for data

Used when you want to read something.

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

Meaning:

“Server, give me the users”


POST – sending data

Used when you want to send something.

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

Meaning:

“Server, I want to send data to you”

(Details can come later — this is enough for now.)


Using cURL to talk to APIs

APIs are servers that expect requests and return data, usually in JSON.

With cURL, you can:

  • Call APIs

  • See exact responses

  • Test endpoints without writing code

This makes cURL a backend developer’s best friend.