How to test APIs with curl — Basic
Quick command-line checks without a GUI—useful in terminals, CI, and remote servers.
Learn: curl is ideal for scripts, documentation, and quick smoke tests. Pair with jq or a JSON formatter when responses are large.
Supplementary examples
PUT with JSON body
curl -s -X PUT http://localhost:5001/users/1 \
-H "Content-Type: application/json" \
-d '{"username":"updated"}'Course example
curl -s http://localhost:5001/health
curl -s -X POST http://localhost:5001/users \
-H "Content-Type: application/json" \
-d '{"username":"demo"}'
Additional references & examples
- curl manual
Command-line HTTP client for quick API checks.
- HTTP status codes (MDN)
When to use 200, 201, 204, 400, 404, 500, and related codes.