About the curl cheat sheet
curl's defaults are quiet in ways that hide exactly what you are usually trying to diagnose. It prints the body and nothing else, so a redirect, a TLS negotiation or an unexpected status code passes without comment. The flags that show headers, follow redirects and report timing are what make it a debugging tool rather than a downloader.
For API work, three things matter most: setting the method and body correctly, sending the right content type, and seeing the response status. A surprising share of API problems are a missing content-type header, where the server rejects a perfectly valid body because it was not told what it was.
The timing breakdown is the underused feature. curl can report how long DNS resolution, connection, TLS handshake and first byte each took, which turns "the API is slow" into a specific answer. That distinction — slow DNS versus slow TLS versus a slow server — points at completely different fixes.
Frequently asked questions
How do I see the response headers and status code?
Include the flag that shows response headers along with the body, or request headers only when the body is irrelevant. For scripting, the write-out option can print just the status code, which is the cleanest way to assert on a response in a shell script or health check.
Why does my request fail with a TLS error?
Usually an untrusted certificate chain, a hostname mismatch, or a missing intermediate certificate that browsers paper over and curl does not. Use verbose mode to see the certificate presented and the negotiated protocol. Disabling verification proves the diagnosis but must never be left in a script — you have removed the guarantee, not fixed the problem.
How do I find out where the time is going?
Use the write-out option with the timing variables, which report DNS lookup, connect, TLS handshake, first byte and total. This separates a slow network path from a slow application, which the total alone cannot. It is the fastest way to disprove "the API is slow" when the real cost is DNS.
How do I send JSON correctly?
Set the content-type header explicitly and pass the body with the data option. Omitting the header sends a form content type, which many APIs reject with a confusing error that does not mention the header. For large or awkwardly quoted payloads, read the body from a file rather than fighting shell escaping.
Does curl follow redirects by default?
No, and that surprises people who expect browser behaviour. Without the follow flag you get the redirect response itself, which is sometimes exactly what you want to see. When following, be careful with credentials — headers are not sent to a different host on redirect unless you explicitly allow it, which is a safety feature rather than a bug.