curl: Die wichtigsten Optionen für API-Tests
curl ist das Schweizer Taschenmesser für HTTP-Anfragen in der Kommandozeile – unverzichtbar für API-Tests und Debugging.
Grundlagen
curl https://api.example.com/items # GET
curl -X POST https://api.example.com/items # POST
curl -i https://api.example.com/ # Header anzeigen
curl -v https://api.example.com/ # verbose (TLS, Redirects)JSON senden
curl -X POST https://api.example.com/items
-H "Content-Type: application/json"
-d '{"name": "Test"}'Auth und Header
-H "Authorization: Bearer TOKEN" für JWT, -u user:pass für Basic Auth, -b cookies.txt für Cookies.
Praktische Optionen
-sstill,-o /dev/null -w "%{http_code}"nur Statuscode.-LRedirects folgen,--max-time 10Timeout.-kZertifikatsprüfung deaktivieren (nur Tests!).| jq .Antwort hübsch formatieren.
Weiterführend: Tools & Software.