Hacky & Tipy
API debugging: kompletní toolkit
API nefunguje? Tady je kompletní sada nástrojů pro debugging REST API.
1. curl
curl -v https://api.example.com/users
curl -X POST -H "Content-Type: application/json" -d '{"name":"John"}' api.example.com/users
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" URL
curl -X POST -H "Content-Type: application/json" -d '{"name":"John"}' api.example.com/users
curl -o /dev/null -s -w "TTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" URL
2. HTTPie
http GET api.example.com/users
http POST api.example.com/users name=John
http POST api.example.com/users name=John
3. Postman / Insomnia
GUI pro komplexní testování. Collections, environments, pre-request scripts.
4. mitmproxy
mitmproxy # interaktivní proxy na :8080
5. ngrok
ngrok http 3000
6. jq pro responses
curl -s api.example.com/users | jq '.[] | {id, name}'
7. Watch
watch -n 5 "curl -s api.example.com/health | jq ."
8. Load testing
hey -n 1000 -c 50 https://api.example.com/users
HTTP status codes
- 200 OK
- 201 Created
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 429 Rate Limit
- 500 Server Error
- 502 Bad Gateway
- 503 Unavailable
Workflow
curl -v → zkontrolujte status code → jq pro response → mitmproxy pro hlubší analýzu.