# API key in headercurl-H"X-API-Key: your-api-key"https://api.example.com
# API key in query parametercurl"https://api.example.com?api_key=your-api-key"# Multiple headerscurl-H"Authorization: Bearer token"\-H"Content-Type: application/json"\https://api.example.com
# POST JSON datacurl-XPOST\-H"Content-Type: application/json"\-d'\\\\{"name":"John","age":30\\\\}'\https://api.example.com/users
# JSON from filecurl-XPOST\-H"Content-Type: application/json"\-d@data.json\https://api.example.com/users
# URL-encoded form datacurl-d"name=John&age=30"https://api.example.com/users
# Multipart form datacurl-F"name=John"-F"age=30"https://api.example.com/users
# File upload with form datacurl-F"file=@document.pdf"\-F"description=Important document"\https://api.example.com/upload
# Test REST API endpointscurl-XGEThttps://api.example.com/users
curl-XPOST-d'\\\\{"name":"John"\\\\}'https://api.example.com/users
curl-XPUT-d'\\\\{"name":"Jane"\\\\}'https://api.example.com/users/1
curl-XDELETEhttps://api.example.com/users/1
# Test with different content typescurl-H"Accept: application/json"https://api.example.com/users
curl-H"Accept: application/xml"https://api.example.com/users
#!/bin/bash# API testing scriptBASE_URL="https://api.example.com"API_KEY="your-api-key"# Function to make authenticated requestsapi_request()\\\\{localmethod=$1localendpoint=$2localdata=$3curl-X"$method"\-H"Authorization: Bearer $API_KEY"\-H"Content-Type: application/json"\$\\\\{data:+-d"$data"\\\\}\"$BASE_URL$endpoint"\\\\}# Usage examplesapi_requestGET"/users"api_requestPOST"/users"'\\\\{"name":"John","email":"john@example.com"\\\\}'
# Always verify SSL certificates in productioncurl--cacert/path/to/ca-bundle.crthttps://api.example.com
# For development only (not recommended for production)curl-khttps://self-signed.example.com
# Download webpagecurl-Lhttps://example.com>page.html
# Follow redirects and save cookiescurl-L-ccookies.txt-bcookies.txthttps://example.com
# Set user agent to avoid blockingcurl-H"User-Agent: Mozilla/5.0 (compatible; bot)"https://example.com
# Verbose output for debuggingcurl-vhttps://example.com
# Trace all network activitycurl--tracetrace.txthttps://example.com
# Show only headerscurl-Ihttps://example.com
# Test connectivitycurl-I--connect-timeout5https://example.com