cURL Commands
Essential cURL commands for HTTP requests and API testing.
cURL Commands
Essential cURL commands for HTTP requests and API testing
Basic Requests
curl <url>Simple GET request
curl https://api.example.com/userscurl -X POST <url>POST request
curl -X POST https://api.example.com/userscurl -X PUT <url>PUT request
curl -X PUT https://api.example.com/users/1curl -X DELETE <url>DELETE request
curl -X DELETE https://api.example.com/users/1curl -I <url>Fetch headers only
curl -I https://example.comHeaders & Authentication
curl -H "Header: Value" <url>Add custom header
curl -H "Content-Type: application/json" https://api.example.comcurl -H "Authorization: Bearer <token>" <url>Bearer token authentication
curl -H "Authorization: Bearer abc123" https://api.example.com/protectedcurl -u user:password <url>Basic authentication
curl -u admin:secret123 https://api.example.com/admincurl -A "User-Agent" <url>Set custom user agent
curl -A "Mozilla/5.0" https://example.comRequest Body
curl -d "data" <url>Send form data
curl -d "name=John&email=john@example.com" https://api.example.com/userscurl -d @file.json <url>Send data from file
curl -d @user.json https://api.example.com/userscurl --data-raw '{"key":"value"}' <url>Send raw JSON data
curl --data-raw '{"name":"John"}' -H "Content-Type: application/json" https://api.example.com/userscurl -F "file=@path" <url>Upload file (multipart)
curl -F "file=@photo.jpg" https://api.example.com/uploadOutput & Response
curl -o file <url>Save response to file
curl -o response.json https://api.example.com/datacurl -O <url>Save with remote filename
curl -O https://example.com/file.zipcurl -i <url>Include response headers
curl -i https://api.example.com/statuscurl -v <url>Verbose mode (debug)
curl -v https://api.example.comcurl -s <url>Silent mode (no progress)
curl -s https://api.example.com/datacurl -w "%{http_code}" <url>Print HTTP status code
curl -w "%{http_code}" https://api.example.comAdvanced Options
curl -L <url>Follow redirects
curl -L https://short.url/abc123curl -k <url>Ignore SSL certificate errors
curl -k https://self-signed.example.comcurl --max-time <seconds> <url>Set timeout
curl --max-time 30 https://slow-api.example.comcurl -x proxy:port <url>Use proxy
curl -x http://proxy.example.com:8080 https://api.example.comcurl -b cookies.txt <url>Send cookies from file
curl -b cookies.txt https://example.comcurl -c cookies.txt <url>Save cookies to file
curl -c cookies.txt https://example.com/login