# Getting Started with cURL

# 1\. What is a Server

* A **server** is a computer on the internet that stores data or performs work for us
    
* Websites, APIs, and apps all live on servers
    
* Whenever you:
    
    * Open a website
        
    * Submit a form
        
    * Fetch data from an API  
        you are **talking to a server**
        
* To build backend systems, programmers must **send requests to servers and understand responses**
    

---

## 2\. What is cURL

* **cURL** is a command-line tool used to **send messages to a server**
    
* It works from the **terminal**, not a browser
    
* cURL can:
    
    * Ask a server for data
        
    * Send data to a server
        
    * Show the server’s response clearly
        
* Think of cURL as:
    
    * *“A browser without buttons, images, or UI”*
        

---

## 3\. Why programmers need cURL

* Browsers **hide technical details**
    
* Programmers need to see:
    
    * What request is actually sent
        
    * What response comes back
        
* cURL helps in:
    
    * Testing APIs
        
    * Debugging backend services
        
    * Verifying server responses
        
    * Learning how HTTP really works
        
* cURL is:
    
    * Lightweight
        
    * Available on almost all systems
        
    * Used in real backend workflows
        

---

## 4\. Making your first request using cURL

### The simplest possible command

* This command:
    
    * Sends a request to the server at [`example.com`](http://example.com)
        
    * Asks for the webpage
        
* The server sends back:
    
    * HTML content of the page
        
* cURL prints the response **directly in the terminal**
    

→ No flags, no complexity just **request → response**

---

## 5\. Understanding request and response

### What cURL sends

* Method: `GET`
    
* URL: where the server lives
    
* Headers: It handle basic information automatically
    

### What cURL receives

* **Status code**
    
    * `200` → Success
        
    * `404` → Not Found
        
    * `500` → Server Error
        
* **Data**
    
    * HTML, JSON, or plain text
        
* **Headers**
    
    * Metadata about the response
        

![https://www.opencsf.org/Books/csf/html/_images/CSF-Images.4.7.png](https://tse2.mm.bing.net/th/id/OIP.aaOR4B-LkzAqWLLbIf4QQwHaEy?w=474&h=379&c=7&p=0 align="center")

![https://media.geeksforgeeks.org/wp-content/uploads/20210905091508/ImageOfHTTPRequestResponse-660x374.png](https://media.geeksforgeeks.org/wp-content/uploads/20210905091508/ImageOfHTTPRequestResponse-660x374.png align="center")

![https://www.researchgate.net/publication/356862193/figure/fig1/AS%3A1098796406714417%401638984886808/Gambar-4-Traditional-Client-Server-Request-Response-Cycle-Figure-4-Shows-the.png](https://tse4.mm.bing.net/th/id/OIP.wN31UgfKFwOV5V8ONGfeuwHaDR?w=474&h=379&c=7&p=0 align="center")

---

## 6\. Using cURL to talk to APIs

### What is an API in simple terms

* An API is a server endpoint that returns **data**, not webpages
    
* APIs usually return **JSON**
    

### Example: GET request to an API

* Server responds with structured data
    
* No UI, only raw information
    
* This is exactly how backend services communicate
    

---

## 7\. Introducing POST

### When GET is not enough

* GET → ask for data
    
* POST → send data to the server
    

### Simple POST idea

* You are:
    
    * Sending data
        
    * Expecting a response (success or failure)
        
* POST is used for:
    
    * Login
        
    * Form submission
        
    * Creating records
        

→ Details come later — focus on **purpose**, not syntax

---

## 8\. Browser request vs cURL request

* Browser:
    
    * Automatically sends requests
        
    * Renders HTML
        
    * Hides request details
        
* cURL:
    
    * You send requests manually
        
    * No rendering
        
    * Full visibility of server response
        

![https://miro.medium.com/v2/resize%3Afit%3A1400/1%2ASgkHt0DBnVFkazz3_eLRDw.png](https://miro.medium.com/v2/resize%3Afit%3A1400/1%2ASgkHt0DBnVFkazz3_eLRDw.png align="center")

![https://capsquery.com/wp-content/uploads/2025/01/REST-vs-Web-API-3.png](https://capsquery.com/wp-content/uploads/2025/01/REST-vs-Web-API-3.png align="left")

![https://crawlbase.com/blog/how-to-send-get-requests-with-curl/curl-get-request-options.jpg](https://crawlbase.com/blog/how-to-send-get-requests-with-curl/curl-get-request-options.jpg align="left")

---

## 9\. Common mistakes beginners make with cURL

* Expecting formatted output like a browser
    
* Forgetting that cURL shows **raw data**
    
* Mixing GET and POST concepts
    
* Using too many flags too early
    
* Assuming errors mean cURL is broken (often the server isn’t responding as expected)
    

→ Errors are learning signals, not failures

---

## 10\. Where cURL fits in backend development

* Used to:
    
    * Test APIs before frontend exists
        
    * Debug production issues
        
    * Verify authentication and data flow
        
* Backend engineers use cURL to:
    
    * Reproduce bugs
        
    * Inspect server behavior
        
    * Validate endpoints
        
* Learning cURL builds:
    
    * Strong HTTP fundamentals
        
    * Confidence in backend communication
        

---

## 11\. Core idea to remember

* Backend development is **server communication**
    
* cURL is the **simplest, clearest way** to learn that communication
    
* Mastering cURL means:
    
    * You understand how the web really works
        
    * You are no longer dependent on tools hiding details
