Skip to main content
๐ŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy โ€” plus the companion book on Leanpub & Amazon. Start Learning
curl Cheat Sheet 2026: HTTP Requests for API Testing
DevOps

curl Cheat Sheet 2026: HTTP Requests for API Testing

curl cheat sheet for API testing and debugging in 2026. GET, POST, PUT, DELETE requests, headers, authentication, TLS certificates, and verbose output.

LB
Luca Berton
ยท 1 min read

A quick reference for curl โ€” the command-line HTTP client. Bookmark this page.

Basic Requests

# GET request
curl https://api.example.com/users
curl -s https://api.example.com/users  # Silent (no progress)
curl -sS https://api.example.com/users # Silent but show errors

# POST request
curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name": "Alice", "email": "alice@example.com"}'

# PUT request
curl -X PUT https://api.example.com/users/1 \
  -H "Content-Type: application/json" \
  -d '{"name": "Alice Updated"}'

# DELETE request
curl -X DELETE https://api.example.com/users/1

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

Headers and Authentication

# Custom headers
curl -H "Authorization: Bearer TOKEN" \
  -H "Accept: application/json" \
  https://api.example.com/data

# Basic auth
curl -u username:password https://api.example.com/secure

# Bearer token
curl -H "Authorization: Bearer eyJhbG..." https://api.example.com/data

# Show response headers
curl -i https://example.com          # Include response headers
curl -I https://example.com          # HEAD request (headers only)
curl -v https://example.com          # Verbose (request + response)

File Upload and Download

# Download file
curl -O https://example.com/file.zip          # Keep original name
curl -o custom-name.zip https://example.com/file.zip
curl -L -O https://example.com/redirect       # Follow redirects

# Upload file
curl -X POST https://api.example.com/upload \
  -F "file=@/path/to/document.pdf"

# Upload with additional fields
curl -X POST https://api.example.com/upload \
  -F "file=@photo.jpg" \
  -F "description=Profile photo"

Output and Formatting

# Pretty print JSON (pipe to jq)
curl -s https://api.example.com/users | jq .

# Write output to file
curl -s https://api.example.com/data -o output.json

# Show timing info
curl -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" \
  -o /dev/null -s https://example.com

# Show only HTTP status code
curl -s -o /dev/null -w "%{http_code}" https://example.com

# Show redirect chain
curl -sIL https://example.com

Advanced Options

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

# Set timeout
curl --connect-timeout 5 --max-time 30 https://slow-api.example.com

# Send data from file
curl -X POST https://api.example.com/data \
  -H "Content-Type: application/json" \
  -d @payload.json

# Use a proxy
curl -x http://proxy:8080 https://example.com
curl -x socks5://proxy:1080 https://example.com

# Skip SSL verification (testing only!)
curl -k https://self-signed.example.com

# Send cookies
curl -b "session=abc123" https://example.com
curl -b cookies.txt https://example.com
curl -c cookies.txt https://example.com  # Save cookies

API Testing Patterns

# Check if API is healthy
curl -sf https://api.example.com/health && echo "OK" || echo "FAIL"

# Measure response time
curl -s -o /dev/null -w "%{time_total}" https://api.example.com/users

# Loop with different payloads
for i in {1..10}; do
  curl -s -X POST https://api.example.com/items \
    -H "Content-Type: application/json" \
    -d "{"name": "item-$i"}"
done

Tips and Tricks

  • Use curl -sS in scripts (silent but shows errors)
  • Use jq for JSON processing: curl -s url | jq '.users[0].name'
  • Use --retry 3 for flaky endpoints
  • Use --compressed to accept gzip responses
  • Save common options in ~/.curlrc
#Cheat Sheet #Reference #DevOps #2026
Share:
Free Consultation

Need help implementing this?

I help enterprises design AI infrastructure, Kubernetes platforms, and automation strategies. Free 30-minute discovery call.

Want to operate this yourself, in production?

Take the free AI Platform Engineer Readiness Scorecard to see which skills transfer โ€” then build a production-shaped AI platform in the 4-week Bootcamp.

Take the Scorecard โ†’
Luca Berton โ€” The Production AI Expert, Docker Captain

Luca Berton

The Production AI Expert ยท Docker Captain ยท KubeCon Speaker

15+ years in enterprise infrastructure. Author of 8 technical books, creator of Ansible Pilot (1M+ YouTube views, 648K site users). Former Red Hat engineer. Speaker at KubeCon EU 2026 and Red Hat Summit 2026.

Free 30-min Production AI consultation

Book Now