CLI UtilitiesDocumentedScanned

curl-http

Essential curl commands for HTTP requests, API testing.

Share:

Installation

npx clawhub@latest install curl-http

View the full skill documentation and source below.

Documentation

curl - HTTP Client

Command-line tool for making HTTP requests and transferring data.

Basic Requests

GET requests

# Simple GET request
curl 

# Save output to file
curl  -o output.html
curl  -O  # Use remote filename

# Follow redirects
curl -L 

# Show response headers
curl -i 

# Show only headers
curl -I 

# Verbose output (debugging)
curl -v

POST requests

# POST with data
curl -X POST  \
  -d "name=John&email=john@example.com"

# POST JSON data
curl -X POST  \
  -H "Content-Type: application/json" \
  -d '{"name":"John","email":"john@example.com"}'

# POST from file
curl -X POST  \
  -H "Content-Type: application/json" \
  -d @data.json

# Form upload
curl -X POST  \
  -F "file=@document.pdf" \
  -F "description=My document"

Other HTTP methods

# PUT request
curl -X PUT  \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane"}'

# DELETE request
curl -X DELETE 

# PATCH request
curl -X PATCH  \
  -H "Content-Type: application/json" \
  -d '{"email":"newemail@example.com"}'

Headers & Authentication

Custom headers

# Add custom header
curl -H "User-Agent: MyApp/1.0" 

# Multiple headers
curl -H "Accept: application/json" \
     -H "Authorization: Bearer token123" \

Authentication

# Basic auth
curl -u username:password 

# Bearer token
curl -H "Authorization: Bearer YOUR_TOKEN" \
  

# API key in header
curl -H "X-API-Key: your_api_key" \
  

# API key in URL
curl ""

Advanced Features

Timeouts & retries

# Connection timeout (seconds)
curl --connect-timeout 10 

# Max time for entire operation
curl --max-time 30 

# Retry on failure
curl --retry 3 

# Retry delay
curl --retry 3 --retry-delay 5

Cookies

# Send cookies
curl -b "session=abc123" 

# Save cookies to file
curl -c cookies.txt 

# Load cookies from file
curl -b cookies.txt 

# Both save and load
curl -b cookies.txt -c cookies.txt

Proxy

# Use HTTP proxy
curl -x  

# With proxy authentication
curl -x  -U user:pass 

# SOCKS proxy
curl --socks5 127.0.0.1:1080

SSL/TLS

# Ignore SSL certificate errors (not recommended for production)
curl -k 

# Use specific SSL version
curl --tlsv1.2 

# Use client certificate
curl --cert client.crt --key client.key 

# Show SSL handshake details
curl -v  2>&1 | grep -i ssl

Response Handling

Output formatting

# Silent mode (no progress bar)
curl -s 

# Show only HTTP status code
curl -s -o /dev/null -w "%{http_code}" 

# Custom output format
curl -w "\nTime: %{time_total}s\nStatus: %{http_code}\n" \
  

# Pretty print JSON (with jq)
curl -s  | jq '.'

Range requests

# Download specific byte range
curl -r 0-1000 

# Resume download
curl -C - -O

File Operations

Downloading files

# Download file
curl -O 

# Download with custom name
curl -o myfile.zip 

# Download multiple files
curl -O  \
     -O 

# Resume interrupted download
curl -C - -O

Uploading files

# FTP upload
curl -T file.txt ftp://ftp.example.com/upload/

# HTTP PUT upload
curl -T file.txt 

# Form file upload
curl -F "file=@document.pdf"

Testing & Debugging

API testing

# Test REST API
curl -X GET 
curl -X GET 
curl -X POST  -d @user.json
curl -X PUT  -d @updated.json
curl -X DELETE 

# Test with verbose output
curl -v -X POST  \
  -H "Content-Type: application/json" \
  -d '{"username":"test","password":"pass"}'

Performance testing

# Measure request time
curl -w "Total time: %{time_total}s\n" 

# Detailed timing
curl -w "\nDNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTransfer: %{time_starttransfer}s\nTotal: %{time_total}s\n" \
  -o /dev/null -s

Common debugging

# Show request and response headers
curl -v 

# Trace request
curl --trace-ascii trace.txt 

# Include response headers in output
curl -i

Common Patterns

Quick JSON API test:

curl -s  | jq '{name, bio, followers}'

Download with progress bar:

curl -# -O

POST JSON and extract field:

curl -s -X POST  \
  -H "Content-Type: application/json" \
  -d '{"user":"test","pass":"secret"}' | jq -r '.token'

Check if URL is accessible:

if curl -s --head --fail  > /dev/null; then
  echo "Site is up"
else
  echo "Site is down"
fi

Parallel downloads:

for i in {1..10}; do
  curl -O  &
done
wait

Useful Flags

  • -X: HTTP method (GET, POST, PUT, DELETE, etc.)
  • -d: Data to send (POST/PUT)
  • -H: Custom header
  • -o: Output file
  • -O: Save with remote filename
  • -L: Follow redirects
  • -i: Include headers in output
  • -I: Headers only
  • -v: Verbose output
  • -s: Silent mode
  • -S: Show errors even in silent mode
  • -f: Fail silently on HTTP errors
  • -k: Insecure (ignore SSL)
  • -u: Basic authentication
  • -F: Multipart form data
  • -b: Send cookies
  • -c: Save cookies
  • -w: Custom output format

Tips

  • Use -s in scripts to suppress progress bar
  • Combine -sS for silent but show errors
  • Use -L for redirects (e.g., shortened URLs)
  • Add -v for debugging
  • Use jq to process JSON responses
  • Save common requests as shell aliases or scripts
  • Use --config for complex reusable requests

Documentation

Official docs:
Manual: man curl
HTTP methods: