Quick Tips
2 min
Quick API Testing with cURL
Master essential cURL commands for rapid API testing
...
apicurltestingcli
Essential cURL Commands for API Testing
Basic GET Request
curl https://api.example.com/usersPOST with JSON Data
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"John","email":"john@example.com"}'With Authentication
# Bearer token
curl https://api.example.com/profile \
-H "Authorization: Bearer your-token-here"
# Basic auth
curl -u username:password https://api.example.com/securePretty Print Response
curl https://api.example.com/users | jq '.'Show Headers
curl -i https://api.example.com/usersFollow Redirects
curl -L https://api.example.com/redirectSave Response to File
curl https://api.example.com/data -o response.jsonTest Response Time
curl -w "Time: %{time_total}s\n" -o /dev/null -s https://api.example.com/endpointTest Multiple Endpoints
#!/bin/bash
endpoints=(
"/users"
"/products"
"/orders"
)
for endpoint in "${endpoints[@]}"; do
echo "Testing $endpoint"
curl -s -o /dev/null -w "%{http_code}\n" "https://api.example.com$endpoint"
donePro Tips
- Use
-vfor verbose output (debugging) - Use
-sfor silent mode (scripts) - Save common requests as shell aliases
- Combine with
jqfor JSON parsing - Use environment variables for tokens
# ~/.bashrc
export API_TOKEN="your-token"
alias api-test='curl -H "Authorization: Bearer $API_TOKEN"'Comments (0)
Loading comments...