Last updated: May 2025 | Perfect for quick reference, API testing, and proxy validation.

1. Basics

# Simple GET
curl https://example.com

# Follow redirects
curl -L https://example.com

# Save output to file
curl -o output.html https://example.com
curl -O https://example.com/file.tar.gz   # keep original filename

2. HTTP Methods

# GET with query params
curl "https://httpbin.org/get?key=value&foo=bar"

# POST JSON
curl -X POST -H "Content-Type: application/json" \
     -d '{"name":"test","value":123}' https://httpbin.org/post

# POST form data
curl -X POST -d "name=test&value=123" https://httpbin.org/post

# PUT
curl -X PUT -H "Content-Type: application/json" \
     -d '{"updated":"data"}' https://httpbin.org/put

# DELETE
curl -X DELETE https://httpbin.org/delete

3. Headers & Metadata

# Custom headers
curl -H "Authorization: Bearer token123" https://api.example.com
curl -H "X-Custom-Header: value" https://httpbin.org/headers

# View only headers (HEAD request)
curl -I https://example.com

# Verbose output (great for debugging)
curl -v https://httpbin.org/headers
curl -vvv https://httpbin.org/headers   # extra verbose

4. Authentication

# Basic Auth
curl -u username:password https://httpbin.org/basic-auth/username/password

# Bearer Token
curl -H "Authorization: Bearer YOUR_TOKEN" https://api.github.com/user

# OAuth / API Key (common pattern)
curl -H "X-API-Key: your_key_here" https://api.example.com

5. Cookies & Sessions

# Send cookies
curl -b "session=abc123; user=guest" https://httpbin.org/cookies

# Store & reuse cookies (session simulation)
curl -c cookies.txt -b cookies.txt https://httpbin.org/cookies/set?foo=bar

6. Downloads & Uploads

# Download with progress bar
curl -# -O https://speed.cloudflare.com/__down?bytes=100000000

# Resume interrupted download
curl -C - -O https://example.com/largefile.zip

# Upload file
curl -F "file=@localfile.txt" https://httpbin.org/post
curl --upload-file largefile.zip https://transfer.sh/

7. Performance & Limits

# Set timeout (seconds)
curl --max-time 10 https://example.com

# Connect timeout
curl --connect-timeout 5 https://example.com

# Limit download speed (e.g., 1MB/s)
curl --limit-rate 1M https://example.com/largefile

# Number of redirects to follow
curl -L --max-redirs 5 https://example.com

8. Proxy & Network Options

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

# SOCKS5 Proxy
curl -x socks5://proxy:1080 https://example.com

# Proxy with auth
curl -x http://user:pass@proxy:8080 https://example.com

# Ignore SSL errors (useful for testing)
curl -k https://self-signed.example.com

9. Advanced / Useful Flags

# Silent (no progress) but show errors
curl -s -S https://example.com

# Raw output (no decoding)
curl --raw https://...

# Trace to file (detailed timing)
curl --trace trace.log https://httpbin.org/get

# Parallel requests (curl >= 7.66)
curl --parallel --parallel-immediate \
     -o file1 https://... \
     -o file2 https://...

10. Informative & Testing Endpoints

Great for testing proxies, headers, latency, and API behavior:

httpbin.org (Most Useful)

Other Excellent Test Endpoints

One-Liners You'll Love

# Quick proxy + IP check
curl -x http://yourproxy:port https://httpbin.org/ip

# Test API with pretty JSON
curl -s https://httpbin.org/get | jq .

# Check website headers quickly
curl -I -L https://example.com

# Download all images from a page (advanced)
curl -s https://example.com | grep -o 'https://[^"]*\.jpg' | xargs -n1 curl -O

Pro Tips:

alias myapi='curl -H "Authorization: Bearer $TOKEN" https://api.example.com'