# Getting Started with cURL

### **cURL** stands for "**Client for URLs**" , **a command-line tool used to transfer data to or from a server.**

---

## First, what is a server?

A **server** is just a computer(a machine which is 24×7 available) on the internet that:

* waits for requests
    
* sends back responses
    

When you open a website, **your browser talks to a server**.

You don’t see the conversation.  
But it’s happening every time

### **Servers:**

* store websites
    
* provide data (APIs)
    
* accept form submissions
    
* handle logins, payments, uploads
    

If you are a programmer, you must be able to **talk to servers directly**, not only through a browser.

That’s where **cURL** comes in.

![What is the cURL Command?](https://53.fs1.hubspotusercontent-na1.net/hubfs/53/curl-command-1-20240924-8716216.webp align="left")

### **What is cURL?**

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

That’s it.

No UI.

No browser.

Just you → terminal → server.

Think of cURL as: “A browser controlled by commands nothing else”.

## Why programmers need cURL ?

**Because browsers:**

* hide details
    
* auto-handle things
    
* don’t show raw responses clearly
    

**cURL lets you:**

* Test servers quickly
    
* Talk to APIs
    
* Debug backend issues
    
* Understand what’s really happening
    
* **Direct Protocol Interaction**
    

If you work with backend, APIs, or DevOps — **cURL is must.**

---

## **Making your first request using cURL**

1. **cURL usually comes pre-installed on macOS, Linux, and Windows 10/11.**
    

Open your Terminal (Mac/Linux) or Command Prompt (Windows) and type:

**bash**

```plaintext
curl --version
```

2. **The simplest way to use cURL is to fetch a website's content. Type this and hit Enter:**
    
    ```plaintext
    curl https://www.google.com
    ```
    
    **What happened?** You just received a giant wall of text. That is the **HTML code** that makes up Google's homepage. Your browser usually turns this code into a pretty page, but cURL shows you the raw data.
    
3. By running this command, we confirm three things:
    
    * our computer can reach the server
        
    * The server responded successfully
        
    * We received real data from the internet  
        
4. > cURL does **not**:
    > 
    > * Open a webpage visually
    >     
    > * Run JavaScript
    >     
    > * Load images or styles
    >     
    
    It only **fetches and displays the response**.
    

---

## **How Does a Request/Response model works?**

![](https://miro.medium.com/v2/resize:fit:870/1*wzzLb_xz5Mlykcd1bBqDig.png align="left")

## **How Request–Response works (simple view)**

1. Client sends a request to the server
    
2. Server understands what is being asked
    
3. Server performs the action
    
4. Server sends a response back
    
5. Client uses the responseHTTP Methods (What kind of action you are asking for————————————————————————————————————-
    

When you use cURL or a browser, you are not just contacting a server —  
you are also telling it **what you want to do**.

That instruction is called an **HTTP method**.

### Common HTTP methods (only the important ones)

* **GET**  
    Used to **request data**  
    Example: loading a webpage or fetching API data
    
* **POST**  
    Used to **send data** to the server  
    Example: submitting a form, creating a new user
    
* **PUT**  
    Used to **update existing data**  
    Example: updating a user profile
    
* **DELETE**  
    Used to **remove data**  
    Example: deleting a record
    

For beginners, remember this:

> **GET = ask**  
> **POST = send**  
> **PUT = update**  
> **DELETE = remove**

![HTTP Response Message](https://home.ubalt.edu/abento/650/modelandapplication/img037.gif align="left")

* **Status Codes:** Indicate the outcome of the request (e.g., 200 OK, 404 Not Found). Status codes are short numbers that explain the result.
    
* **Response Headers:** Additional information that accompanies the response.
    
* **Response Body:** Data returned by the server (e.g., HTML, JSON).
