curl
Quick Reference
Command Name:
curl
Category:
networking
Platform:
Linux/Unix/Windows
Basic Usage:
Common Use Cases
- 1
API testing
Test RESTful APIs with different HTTP methods and data formats
- 2
File downloads
Download files from various sources including HTTP, FTP, and more
- 3
Web scraping
Extract data from websites in scriptable, non-interactive manner
- 4
Server testing
Verify server configurations, TLS/SSL settings, and response headers
Syntax
curl [options] [URL...]
Options
Option | Description |
---|---|
-A, --user-agent | Specify the User-Agent string to send to the server |
-b, --cookie | Send cookies from a string or file |
-c, --cookie-jar | Write cookies to a file after operation |
-C, --continue-at | Resume a download from a specific position |
-d, --data | Send data in a POST request |
-F, --form | Send a multipart/form-data request |
-H, --header | Add custom headers to the request |
-I, --head | Fetch headers only (HTTP HEAD request) |
-k, --insecure | Allow insecure connections (skip SSL certificate verification) |
-L, --location | Follow redirects |
-m, --max-time | Set a maximum time for the transfer |
-o, --output | Write output to a file instead of stdout |
-O, --remote-name | Save output to a file using the remote filename |
-s, --silent | Silent mode (don't show progress or errors) |
-S, --show-error | Show errors even in silent mode |
-u, --user | Specify username and password for authentication |
-v, --verbose | Make the operation more verbose (show detailed information) |
-X, --request | Specify the request method (GET, POST, PUT, DELETE, etc.) |
--limit-rate | Limit the transfer speed |
--proxy | Use the specified proxy |
--ssl-reqd | Require SSL/TLS for the connection |
Examples
How to Use These Examples
The examples below show common ways to use the curl
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
curl https://example.com
Fetch and display the contents of a website.
curl -o output.html https://example.com
Download the contents of a website and save it to a file.
curl -O https://example.com/file.zip
Download a file and save it with the same name as on the remote server.
Advanced Examples:
curl -X POST -d "name=John&age=25" https://example.com/api
Send a POST request with form data to an API endpoint.
curl -X POST -H "Content-Type: application/json" -d '{"name":"John","age":25}' https://example.com/api
Send a POST request with JSON data and a custom header.
curl -u username:password https://example.com/protected
Access a protected resource using basic authentication.