curl is a popular command-line tool and software project used by developers to transfer data to and from servers.

  • It stands for Client URL.
  • It lets your computer talk to a web server using a URL.
  • It supports many network protocols like HTTP, HTTPS, and FTP.
  • You can use it to download files, test web links, and work with APIs.

curl https://example.com

Downloads and prints the contents of a URL to the terminal.


curl -o page.html https://example.com

Downloads the response and saves it as page.html.


curl -O https://example.com/file.zip

Downloads a file and saves it using the filename provided by the server.


curl -L https://example.com

Automatically follows HTTP redirects (301, 302, etc.). Useful when URLs redirect to another location.


curl -I https://example.com

Retrieves only the HTTP response headers without downloading the body.


curl -i https://example.com

Displays both the response headers and body together.


curl "https://api.example.com/users?id=123"

Sends a GET request with URL parameters. Common for REST APIs.


curl -X POST https://api.example.com/users

Explicitly sends a POST request. Often combined with request data.


curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

Sends JSON data in the request body. This is the standard format for modern REST APIs.


curl -d "username=admin&password=secret" https://example.com/login

Submits URL-encoded form data similar to an HTML form submission.


curl -F "file=@report.pdf" https://example.com/upload

Uploads a file using multipart form data. Common for file upload APIs.


curl -O https://example.com/a.zip -O https://example.com/b.zip

Downloads multiple files in a single command.


curl -u username:password https://example.com

Authenticates using HTTP Basic Authentication.


curl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com

Adds an OAuth or JWT bearer token for API authentication.


curl -H "X-API-Key: abc123" https://api.example.com

Includes custom HTTP headers in the request.


curl -b "sessionid=abc123" https://example.com

Sends cookies with the request, useful for authenticated sessions.


curl -c cookies.txt https://example.com/login

Stores cookies received from the server into a file for later use.


curl -b cookies.txt https://example.com/dashboard

Uses previously saved cookies to maintain a session.


curl -k https://self-signed.example.com

Allows connections to servers with self-signed or invalid SSL certificates. Useful for development environments.


curl -v https://example.com

Displays detailed request and response information for debugging network issues.


curl -o /dev/null -s -w "%{http_code}\n" https://example.com

Suppresses the response body and prints only the HTTP status code.


curl -X PUT https://api.example.com/users/1

Uses a different HTTP method such as PUT, PATCH, DELETE, or OPTIONS.


curl -X POST \
  -H "Content-Type: application/json" \
  -d @payload.json \
  https://api.example.com/users

Reads the request body directly from a file instead of typing it inline.


curl --max-time 10 https://example.com

Stops the request if it takes longer than the specified number of seconds.


curl -C - -O https://example.com/large.iso

Resumes an interrupted download from where it stopped.


curl -x http://proxy.example.com:8080 https://example.com

Routes the request through an HTTP proxy server.


curl -A "Mozilla/5.0" https://example.com

Changes the User-Agent header to mimic a browser or another client.


curl -X GET https://api.example.com/health

Checks whether an API endpoint is reachable and responding correctly.


curl -w "\nTotal: %{time_total}s\n" -o /dev/null -s https://example.com

Displays how long the request took to complete. Useful for performance testing and diagnostics.


curl -I --http2 https://example.com

HTTP/2 support check.


Source: Orkhan Alishov's notes