cURL Commands Reference Guide
Essential cURL commands for API testing — GET, POST, PUT, DELETE with headers, auth, and cookies.
Published:
Tags: cURL commands reference, curl API testing, curl examples
cURL Commands Reference Guide cURL is the universal HTTP client for the command line. Every developer who tests APIs, debugs webhooks, or reads API documentation uses it. This reference covers the most important cURL options with real examples — from basic GET requests to OAuth authentication, file uploads, and verbose debugging. --- All the tools discussed here are available for free at theproductguy.in — client-side, no sign-up required. Part of the HTTP Debugging Tools Guide — a complete toolkit for diagnosing web requests. --- What is Basic HTTP Methods? GET Request POST Request PUT and PATCH DELETE --- Headers --- Authentication Bearer Token (OAuth 2.0 / JWT) Basic Authentication API Key in Header For a complete authentication guide, see cURL for API Authentication. --- What is File…
Frequently Asked Questions
What are the most useful cURL options?
The most used cURL options are -X (method), -H (header), -d (data/body), -u (basic auth), -b (cookies), -L (follow redirects), -I (headers only), -v (verbose), -o (output file), -s (silent), -w (write-out format), and --compressed (accept gzip). Combining -v with -s gives verbose headers without progress meters.
How do I send a JSON POST with cURL?
Use curl -X POST -H 'Content-Type: application/json' -d '{"key": "value"}' URL. The -H flag sets the Content-Type header and -d provides the body. Use single quotes on the outside to avoid shell escaping issues with double quotes inside the JSON. On Windows, reverse the quote nesting or use a --data-binary @file.json approach.
How do I add headers to a cURL request?
Use the -H flag once per header: curl -H 'Authorization: Bearer token' -H 'Accept: application/json' URL. Header names are case-insensitive. You can also use --header as the long form. To remove a header that cURL sends by default, use -H 'Header-Name:' with an empty value.
How do I use cURL with OAuth?
For OAuth 2.0 bearer tokens, use curl -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' URL. To obtain a token via client credentials flow, use curl -X POST -d 'grant_type=client_credentials&client_id=ID&client_secret=SECRET' https://auth.server/token. Store the returned token and use it in subsequent requests.
How do I follow redirects with cURL?
Use the -L flag: curl -L URL. By default, cURL does not follow redirects and returns the 3xx response directly. With -L, it follows up to 30 redirects. Use --max-redirs N to set a different limit. Use -v to see each redirect step. cURL preserves the HTTP method for 301/302 redirects by default (unlike browsers, which change POST to GET).
All articles · theproductguy.in