curl Commands Cheatsheet — HTTP Requests from Terminal

curl command examples: GET, POST, headers, authentication, file upload, JSON, cookies, debugging.

Basic Requests

# GET request
curl https://api.example.com/users

# POST with JSON body
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

Common Options

FlagDescription
-sSilent (no progress bar)
-vVerbose (show headers)
-o fileSave output to file
-OSave with remote filename
-LFollow redirects
-iInclude response headers
-w "%{http_code}"Print status code
--max-time 10Timeout in seconds

Authentication

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

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

# API key in header
curl -H "X-API-Key: your-key" https://api.example.com

File Upload

# Upload file
curl -F "file=@photo.jpg" https://api.example.com/upload

# Multiple files
curl -F "file1=@a.jpg" -F "file2=@b.jpg" https://api.example.com/upload

Useful Patterns

# Pretty-print JSON response
curl -s https://api.example.com/data | jq .

# Save response and check status
STATUS=$(curl -s -o response.json -w "%{http_code}" https://api.example.com)
echo "Status: $STATUS"

# POST form data
curl -X POST -d "user=alice&pass=secret" https://example.com/login

Need These Tools as an API?

TextForge API offers 20+ developer toolkit endpoints. Free tier: 50 requests/day.

Try TextForge API Free →

Related Tools