curl fetches a URL from the terminal. Learn how `-I` shows just the headers, how `-o` and `-O` save to a file, and how `-X`, `-d` and `-H` call an API, by running the commands in a real terminal in your browser.
Updated: 2026-09-11
curl [options] URL
It requests the URL and prints what comes back.
$ curl https://example.com
<!DOCTYPE html>
<html>
<head>
<title>Example Domain</title>
</head>
<body>
<h1>Example Domain</h1>
<p>This domain is for use in illustrative examples in documents.</p>
<!-- This is a simulated response from WebTerm -->
</body>
</html>
The HTML comes back as it is. The terminal on this page never leaves the browser; it composes the response itself, which the last comment line marks. The commands and the way you read the results are the same as on a real machine.
When the body is not the point, use -I.
$ curl -I https://example.com
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date: Mon, 07 Sep 2026 08:38:21 GMT
Server: WebTerm/1.0 (Simulated)
Content-Length: 250
The first line is the answer. For "is the site up" and "is it redirecting", this is the fastest question you can ask.
-o saves under a name you pick.
$ curl -o page.html https://example.com
$ ls
page.html README.md
$ head -3 page.html
<!DOCTYPE html>
<html>
<head>
Nothing is printed while it saves.
-O (capital) keeps the name from the URL.
$ curl -O https://example.com/app.tar.gz
$ ls
app.tar.gz page.html README.md
-s drops the progress output, which leaves clean JSON.
$ curl -s https://api.example.com/users
[
{
"id": 1,
"name": "alice",
"email": "alice@example.com"
},
{
"id": 2,
"name": "bob",
"email": "bob@example.com"
}
]
To send something, -X sets the method and -d carries the body.
Send JSON with only those two, though, and many APIs turn it away.
$ curl -X POST -d '{"name":"ada"}' https://api.example.com/users
{
"error": "Content-Type must be application/json"
}
Without a header, curl labels the body as form data.
Declare that it is JSON with -H 'Content-Type: application/json'.
$ curl -X POST -H 'Content-Type: application/json' -d '{"name":"ada"}' https://api.example.com/users
{
"id": 3,
"name": "ada"
}
Other headers, such as authentication, go in -H too.
$ curl -H 'Authorization: Bearer TOKEN' https://api.example.com/me
{
"id": 1,
"name": "alice",
"email": "alice@example.com"
}
Repeat -H as many times as you need.
curl is what you type to find out whether the application answers.
| Situation | What to type |
|---|---|
| Check a site is up | curl -I https://example.com |
| Read an API response | curl -s https://api.example.com/users |
| Send data | curl -X POST -d '...' -H 'Content-Type: application/json' URL |
| Call an authenticated endpoint | curl -H 'Authorization: Bearer TOKEN' URL |
| Download a file | curl -O https://example.com/app.tar.gz |
Prove the path with ping, prove the application with curl.
Those two steps separate a network problem from an application problem.
Quote the URL.
A URL containing ? or & is read by the shell first.
Write curl 'https://api.example.com/users?page=2&limit=10'.
-o means no output on screen.
If it looks like nothing happened, check ls for the file.
-X POST alone does not make it JSON.
The format is declared in a header.
Without -H 'Content-Type: application/json', the other side may not parse the body.
Do not type secrets directly.
They stay in your shell history.
Keep the token in an environment variable and pass -H "Authorization: Bearer $TOKEN".
webterm.appthis site
Advanced Terminal Commands
Learn commands for specific situations
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course