Bash Transfer URL
curl is the command-line tool for transferring data to and from servers using URLs, making it the go-to way to test APIs and debug web requests.
What Is curl?
curl (Client URL) transfers data to or from a server using a URL. It supports HTTP, HTTPS, FTP, and many other protocols, and is the standard way to test REST APIs, download resources, and inspect exactly what a server sends back, all without leaving the terminal.
Making a GET Request
By default curl performs an HTTP GET request and prints the response body straight to standard output, which makes it easy to pipe into other commands like grep or a JSON formatter.
Fetching a URL
$ curl https://api.github.com/zen
Keep it logically awesome.Sending Data and Custom Headers
Use -X to set the HTTP method, -d to attach a request body, and -H to add a header. curl switches to POST automatically once you pass -d, so -X POST is often optional but still good for clarity.
Posting JSON Data
$ curl -X POST https://httpbin.org/post -H "Content-Type: application/json" -d '{"name":"maria","role":"admin"}'
{
"json": {
"name": "maria",
"role": "admin"
},
"url": "https://httpbin.org/post"
}Inspecting Response Headers and Status
Add -i to include response headers above the body, or -I to fetch only the headers using a HEAD request. Combine with -s to silence the progress meter and -o to save the body to a file instead of printing it.
Checking Just the Headers
$ curl -I https://example.com
HTTP/2 200
content-type: text/html; charset=UTF-8
content-length: 1256
date: Thu, 16 Jul 2026 09:12:03 GMT
cache-control: max-age=3600- -X <method> - set the HTTP method, such as POST, PUT, or DELETE
- -H "Header: value" - add a custom request header
- -d '<data>' - send a request body (implies POST)
- -o file - write the response body to a file instead of the terminal
- -i - include response headers in the output
- -L - follow redirects automatically
- -s - silent mode, hides the progress bar
- -v - verbose mode, shows the full request and response for debugging