Back to Blog
3 min readBy Tanish Bhandari

Getting Started with cURL


Getting Started with cURL

Back in the day, if you wanted to fetch data from a server, you'd write a script. Or open a browser. Or pray.

There was no simple way to just ask a server for something from your terminal.

Then came cURL — a command-line tool that lets you send requests to any server, instantly. It speaks HTTP, HTTPS, FTP, and about 25 other protocols. One tool. Every server.


Your First Request

Fetching a webpage is one command:

curl https://example.com

Output:

<!doctype html>
<html>
<head>
    <title>Example Domain</title>
</head>
<body>
    <h1>Example Domain</h1>
    <p>This domain is for use in examples...</p>
</body>
</html>

That's it. You just talked to a server.


Understanding the Response

Want to see what's happening under the hood? Add -i to include headers:

curl -i https://example.com

Output:

HTTP/2 200
content-type: text/html; charset=UTF-8
content-length: 1256
date: Fri, 31 Jan 2026 10:00:00 GMT

<!doctype html>...

That 200 is the status code — it means success. The headers tell you content type, size, and server info.


Talking to APIs

Most APIs return JSON. Fetch it like this:

curl https://api.github.com/users/octocat

Output:

{
  "login": "octocat",
  "id": 583231,
  "type": "User",
  "name": "The Octocat",
  "company": "@github",
  "followers": 15000
}

GET vs POST — The Two Methods You Need

GET — Fetch data (default):

curl https://api.example.com/users

POST — Send data:

curl -X POST https://httpbin.org/post -d "name=tanish&role=developer"

Output:

{
  "form": {
    "name": "tanish",
    "role": "developer"
  }
}

Sending JSON Data

Modern APIs expect JSON. Use -H to set headers:

curl -X POST https://httpbin.org/post \
  -H "Content-Type: application/json" \
  -d '{"name": "tanish", "role": "developer"}'

Useful Flags

FlagWhat It Does
-iInclude response headers
-IFetch headers only (HEAD request)
-XSpecify HTTP method (POST, PUT, DELETE)
-HAdd custom header
-dSend data in request body
-oSave output to file
-sSilent mode (no progress bar)
-LFollow redirects

Common Beginner Mistakes

  • Forgetting https:// in the URL
  • Missing -X POST when sending data
  • Not using -H "Content-Type: application/json" for JSON APIs
  • Forgetting -L when a URL redirects

Quick Note

If you're into modern shells, xonsh can replace cURL with native Python syntax. Worth exploring.


cURL turns your terminal into a conversation with any server on the internet. Master it, and you'll debug APIs faster than anyone with a GUI.



Written by Tanish Bhandari