⚡ 100% In-Browser & Private: Your data never leaves your computer. Powered by Cloudflare Edge CDN.
ProWebTools PRO
Developer & SEO Utilities
35+ Recipes

cURL Command Line Recipes & API Cheat Sheet

Production cURL command recipes: sending JSON payloads, custom headers, bearer tokens, file uploads, following redirects, SSL flags, and curl timing variables with 1-click copy.

Basic Requests & Output (4 commands)

Basic Requests & Output
curl https://api.example.com/data

Performs simple HTTP GET request and streams response body to stdout.

PRO TIP Add -s (silent) to suppress the progress meter and error messages.
Basic Requests & Output
curl -i https://example.com

Includes HTTP response status line and headers alongside the response body.

PRO TIP Use -I (head request) if you only want to inspect headers without downloading body.
Basic Requests & Output
curl -L https://short.url/link

Follows HTTP redirects (301 Moved Permanently, 302 Found) automatically.

PRO TIP Essential when testing vanity domains or URL shorteners.
Basic Requests & Output
curl -v https://api.example.com

Verbose mode: outputs full TLS handshake, request headers (>), and response headers (<).

PRO TIP The #1 diagnostic command for troubleshooting API connection issues.

Headers, Auth & Cookies (4 commands)

Headers, Auth & Cookies
curl -H "Authorization: Bearer <token>" -H "Accept: application/json" https://api.example.com

Sends custom HTTP headers with request.

PRO TIP Multiple -H flags can be passed to attach diverse headers.
Headers, Auth & Cookies
curl -u "username:password" https://api.example.com/admin

Sends Basic HTTP Authentication header (base64 encoded automatically).

PRO TIP Can omit password (curl -u username) to be securely prompted without terminal history logging.
Headers, Auth & Cookies
curl -b "session_id=xyz123" https://example.com/profile

Sends cookies with request.

PRO TIP Use -c cookies.txt to save response cookies, and -b cookies.txt to reuse them.
Headers, Auth & Cookies
curl -A "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)" https://example.com

Sets custom User-Agent header (emulates mobile safari, chrome, or bot).

PRO TIP Useful for testing mobile viewport redirects and bot protection rules.

POST Requests & Payloads (4 commands)

POST Requests & Payloads
curl -X POST https://api.example.com/users \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "role": "admin"}'

Submits JSON payload via HTTP POST method.

PRO TIP Using -d automatically switches the HTTP request method to POST.
POST Requests & Payloads
curl -X POST https://api.example.com/upload \ -H "Content-Type: application/json" \ -d @payload.json

Reads JSON request payload directly from a local disk file using @filename.

PRO TIP Prevents shell escaping headaches with large or nested JSON bodies.
POST Requests & Payloads
curl -F "avatar=@/path/photo.png" -F "user_id=42" https://api.example.com/profile

Sends multipart/form-data upload including binary file and form fields.

PRO TIP Standard pattern for file and image uploads in web APIs.
POST Requests & Payloads
curl --data-urlencode "query=search term with spaces" https://example.com/search

URL-encodes form data parameters automatically before transmission.

PRO TIP Saves having to manually %20 encode special characters.

File Downloads & Resumes (3 commands)

File Downloads & Resumes
curl -O https://example.com/releases/v1.0.tar.gz

Downloads remote resource and saves locally using the remote filename.

PRO TIP Use lowercase -o custom_name.tar.gz to specify a custom local filename.
File Downloads & Resumes
curl -C - -O https://example.com/large_dataset.iso

Resumes an interrupted file download where it left off using byte ranges.

PRO TIP Saves bandwidth and hours of time when downloading multi-gigabyte ISOs.
File Downloads & Resumes
curl --limit-rate 500k -O https://example.com/big_file.zip

Throttles download bandwidth speed to maximum 500 KB/s.

PRO TIP Prevents saturation of production network bandwidth during large backups.

Diagnostics & Latency Timing (2 commands)

Diagnostics & Latency Timing
curl -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" -o /dev/null -s https://example.com

Detailed HTTP timing breakdown: measures DNS resolution, TCP handshake, TLS, and TTFB.

PRO TIP The definitive command for diagnosing slow API response times.
Diagnostics & Latency Timing
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/health

Extracts and outputs only the numeric HTTP response status code (e.g. 200, 404, 502).

PRO TIP The standard idiom for bash health-check scripts and CI/CD pipelines.

SSL & Security Options (3 commands)

SSL & Security Options
curl -k https://self-signed.local

Insecure mode: ignores invalid, expired, or self-signed SSL/TLS certificates.

PRO TIP Safe for local dev testing; never use in automated production scripts.
SSL & Security Options
curl --resolve example.com:443:198.51.100.15 https://example.com

Forces curl to connect to an explicit IP address, bypassing public DNS lookup.

PRO TIP Ideal for testing staging servers before updating public DNS A records.
SSL & Security Options
curl -x socks5://127.0.0.1:1080 https://api.example.com

Routes all curl traffic through an HTTP or SOCKS5 proxy server.

PRO TIP Pair with ssh -D 1080 to route curl requests through remote cloud instances.