DevTools

curl

curl commands for HTTP requests, API testing, and data transfer.

32 commands
Windows MacOS Linux
#http #networking #Popular

Basic Requests

Fetch a URL and print response body
curl https://example.com
Save output to a file
curl -o file.html https://example.com
Save with remote filename
curl -O https://example.com/file.tar.gz
Follow redirects automatically
curl -L https://example.com
Fetch only HTTP response headers
curl -I https://example.com
Silent mode, suppress progress
curl -s https://example.com

HTTP Methods

Send a GET request
curl -X GET https://api.example.com/items
Send a POST request
curl -X POST https://api.example.com/items
Send a PUT request
curl -X PUT https://api.example.com/items/1
Send a PATCH request
curl -X PATCH https://api.example.com/items/1
Send a DELETE request
curl -X DELETE https://api.example.com/items/1

Headers & Auth

Set a request header
curl -H "Content-Type: application/json" <url>
Send bearer token auth
curl -H "Authorization: Bearer <token>" <url>
Basic authentication
curl -u user:pass https://api.example.com
Request JSON response
curl -H "Accept: application/json" <url>

Data Upload

Send JSON data
curl -d '{"key":"val"}' -H "Content-Type: application/json" <url>
Send form-encoded data
curl -d "name=value&other=data" <url>
Upload a file via multipart form
curl -F "[email protected]" <url>
Send raw binary data
curl --data-binary @file.bin <url>

SSL & Certificates

Skip SSL certificate verification
curl -k https://self-signed.example.com
Use a custom CA certificate
curl --cacert ca.pem https://example.com
Use a client certificate
curl --cert client.pem https://example.com
Client cert with private key
curl --cert client.pem --key key.pem <url>

Advanced Options

Print only the HTTP status code
curl -w "%{http_code}" -o /dev/null -s <url>
Set connection timeout in seconds
curl --connect-timeout 5 <url>
Set maximum total time for request
curl --max-time 30 <url>
Verbose output for debugging
curl -v https://example.com
Retry the request up to 3 times
curl --retry 3 <url>
Use an HTTP proxy
curl -x http://proxy:8080 <url>

Quick Commands

Fetch a URL and follow redirects
curl -L https://example.com
Send a POST request with JSON data
curl -X POST -d '{"key":"val"}' <url>
Fetch only the HTTP response headers
curl -I https://example.com