# Exploring cURL

Before we talk about cURL we need to understand Server.

## What is a server?

A **server** is just a computer somewhere on the internet that stores data,runs applications and responds when someone asks it for something.

![Client-Server Architecture Explained](https://substackcdn.com/image/fetch/$s_!F636!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa29b682c-cff6-4ed3-a085-4347eb020b06_1906x1150.png align="left")

## What is cURL?

cURL is a command-line tool that lets you send requests to servers from the terminal.cURL is a way to send messages to a server from your terminal and see the response.It does not require any UI or browser its just you and the server.

## Why Programmers Need cURL?

As a programmer, cURL is extremely useful because:

1. You can test APIs without building a frontend
    
2. You can debug backend endpoints quickly
    
3. You can understand how requests and responses actually work
    
4. It works everywhere: Linux, macOS, Windows
    

## Making Your First Request Using cURL

In your terminal type “curl [https://www.google.com](https://www.google.com)”

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769868548911/5a992b08-522b-47bf-adc1-16d552f9ceac.png align="center")

**what is this output??**You just sent a "GET" request to Google. You’ll see a wall of HTML code fly past. That is the server saying, "Here is the code for my homepage!"

## Understanding Request and Response

Every time you use cURL, a three-step process occurs:

1. **The Request:** You ask for something (e.g., `curl` [`google.com`](http://google.com)).A request usually contains
    
    Method (GET, POST, etc.),URL (where you are sending the request), Data or headers
    
2. **The Processing:** The server looks up your request.
    
3. **The Response:** The server sends back a status code (like **200 OK**) and the data.A response contains Status code (e.g., 200, 404, 500) and Data (HTML, JSON, text, etc.)
    

## Using cURL to Talk to APIs

An APIs usually return **JSON**, not HTML. In your terminal type “curl [https://jsonplaceholder.typicode.com/posts/1](https://jsonplaceholder.typicode.com/posts/1)”

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769869081463/8bfe7e82-e61c-4bed-aba8-8f5eaa1a2fa6.png align="center")

## Introducing GET and POST

* **GET (Fetching Data):** Asking the server to give you something.
    
    * *Example:* `curl` [`https://api.example.com/users`](https://api.example.com/users)
        
* **POST (Sending Data):** Giving the server something new to save.
    
    * *Example:* `curl -X POST -d "name=John"` [`https://api.example.com/users`](https://api.example.com/users)
        

## Common mistakes beginners make with cURL

* Sometimes cURL doesn't show an error message if a page fails. Use `-v` (verbose) to see the "behind the scenes" chatter.
    
* **Missing Quotes:** If your URL has special characters (like `&`), always wrap it in quotes: `"`[`https://api.com?id=1&type=user`](https://api.com?id=1&type=user)`"`.
    
* **Formatting:** Beginners often get overwhelmed by the wall of text. (Pro tip: Pipe your output to a tool like `jq` to make JSON look pretty!).
    

## Browser vs cURL

**Browser:** UI → Request → Server → Response → UI

**cURL:** Terminal → Request → Server → Response → Terminal
