cURL 시작하기
Source: Dev.to
Introduction
In this article we’ll cover:
- What a server is and why we need to talk to it
- What cURL is (in very simple terms)
- Why programmers use cURL
- Making your first request using cURL
- Understanding requests and responses with cURL
- Common mistakes beginners make while using cURL
What a Server Is
Think of a server like a friend you ask for money.
- If the friend is in a good mood and has money, they say “Sure”.
- Otherwise, they say “No”.
A server works in a very similar way.
A server is a hardware or software system that receives requests over a network, processes them, and sends back a response.
Every time you open a website, upload a photo, or log in to an app you’re talking to a server. Servers are important because they allow us to:
- Get data – fetch posts, videos, products, etc.
- Send data – forms, messages, login details
- Update data – edit profile, change password
- Delete data – remove posts or accounts
For example, you cannot upload a photo to social media without communicating with a server.
What cURL Is
cURL stands for Client URL. It is a command‑line tool (like ping or ipconfig) used to send requests and transfer data between your computer and a server using a URL.
You can run cURL from any Command Line Interface (CLI), such as:
- Command Prompt (
cmd) - PowerShell
- Terminal (macOS / Linux)
- Warp
In simple words: cURL lets you talk to servers directly from the command line.
Why Programmers Use cURL
- Allows quick HTTP requests
- Supports all common methods:
GET,POST,PUT,DELETE, etc. - Lightweight and fast
- No browser or UI required – just commands
- Frequently used by backend developers to test APIs
Making Your First Request
Open a CLI on your device and run:
curl https://google.com
You’ll see the raw HTML returned by the server.
GET Request
A GET request retrieves data from a server.
curl https://dummyjson.com/products
The response is a list of products in JSON format.
POST Request
A POST request sends or updates data on a server.
curl -X POST https://httpbin.org/anything
The server responds with details about the request it received.
Understanding Requests and Responses
When you use cURL:
-
You send a request (URL + method + optional data)
-
The server processes it
-
The server sends a response, which includes:
- Status code (e.g., 200, 404, 500)
- Headers
- Response body (data or message)
This request–response cycle is the foundation of APIs.
Common Mistakes to Watch Out For
- ❌ Writing URLs incorrectly or without quotes when required
- ❌ Ignoring the HTTP status code in the response
- ❌ Sending invalid JSON data
- ❌ Forgetting flags like
-X,-H, or-d - ❌ Mixing up
GETandPOSTrequests
Conclusion
cURL might look scary at first, but once you understand it, it becomes a powerful tool for learning how servers and APIs actually work. If you’re a beginner in backend development, learning cURL is 100 % worth it.
Happy coding 🚀