Skip to main content

Command Palette

Search for a command to run...

Getting Started with cURL: Talking to Servers from Your Terminal

Published
3 min read

When you open a website in your browser, your browser sends a request to a server. The server responds with data. But what if you want to talk to a server without a browser?

What if you want to:

  • Test an API

  • Debug a backend

  • Check a server response

  • Send data manually

That’s where cURL comes in.

In this article, you’ll learn:

  • What cURL is (in very simple terms)

  • Why programmers need it

  • How to make your first request

  • What request and response mean

  • How to talk to APIs using cURL

  • Common beginner mistakes

Let’s start from the basics.

What Is a Server?

A server is a computer that:

  • Stores data

  • Runs applications

  • Responds to requests from clients

When you visit:https://example.com

Your browser sends a request to a server.

The server replies with:

  • HTML

  • JSON data

  • Images

  • Files

This is called client–server communication.

What Is cURL?

cURL stands for: Client URL

In simple terms: cURL is a tool that lets you send requests to a server from your terminal. Instead of using a browser, you use a command line.

Why Programmers Need cURL

Developers use cURL to:

  • Test APIs

  • Debug backend services

  • Check HTTP responses

  • Send data to servers

  • Automate server communication

It is especially useful in:

  • Backend development

  • DevOps

  • API testing

cURL helps you see exactly what the server sends back.

Making First cURL Request

Let’s try the simplest possible command.

In your terminal, type:

curl https://example.com

Press Enter.

You will see raw HTML output printed in your terminal.

What just happened?

  1. cURL sent an HTTP request.

  2. The server responded with HTML.

  3. cURL printed that response.

That’s it. You just talked directly to a server.

Understanding Request and Response

When using cURL, two main things happen:

Request

The message sent to the server.

Example:

GET / HTTP/1.1
Host: example.com

This means: “Please give me the homepage.”

Response

The server replies with:

HTTP/1.1 200 OK
Content-Type: text/html

Followed by the actual HTML content.

What Does "200 OK" Mean?

HTTP status codes tell you what happened.

  • 200 → Success

  • 404 → Not Found

  • 500 → Server Error

When using cURL, you are seeing the raw response that browsers normally hide.

Using cURL to Talk to APIs

APIs usually return JSON instead of HTML.

Example:

curl https://jsonplaceholder.typicode.com/posts/1

You will see:

{
  "userId": 1,
  "id": 1,
  "title": "...",
  "body": "..."
}

This is API communication. Instead of rendering a webpage, the server sends structured data.

GET vs POST

Let’s keep this simple.

GET

Used to retrieve data.

Example:

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

This fetches data.

POST

Used to send data to the server.

Example:

curl -X POST https://jsonplaceholder.typicode.com/posts

This tells the server: “I want to create something.”

Browser vs cURL

Browser renders visuals. cURL shows raw data.

Basic HTTP Structure

Request:
GET /resource HTTP/1.1
Host: api.example.com

Response:
HTTP/1.1 200 OK
Content-Type: application/json

{ "data": "value" }

Where cURL Fits in Backend Development

When building APIs, you often need to:

  • Test endpoints

  • Check if server is running

  • Validate responses

  • Debug errors

Instead of opening a browser, you use: curl

It’s faster and more precise. Backend developers use it daily.

Common Mistakes Beginners Make

Forgetting https://

Wrong:

curl example.com

Better:

curl https://example.com

Confusing GET and POST

GET retrieves data.
POST sends data.

Expecting Pretty Output

cURL prints raw output. If it looks messy, that’s normal.