cURL Commands

Essential cURL commands for HTTP requests and API testing.

Basic Requests

curl <url>

Simple GET request

curl -X POST <url>

POST request

curl -X PUT <url>

PUT request

curl -X DELETE <url>

DELETE request

curl -I <url>

Fetch headers only

Headers & Authentication

curl -H "Header: Value" <url>

Add custom header

curl -H "Authorization: Bearer <token>" <url>

Bearer token authentication

curl -u user:password <url>

Basic authentication

curl -A "User-Agent" <url>

Set custom user agent

Request Body

curl -d "data" <url>

Send form data

curl -d @file.json <url>

Send data from file

curl --data-raw '{"key":"value"}' <url>

Send raw JSON data

curl -F "file=@path" <url>

Upload file (multipart)

Output & Response

curl -o file <url>

Save response to file

curl -O <url>

Save with remote filename

curl -i <url>

Include response headers

curl -v <url>

Verbose mode (debug)

curl -s <url>

Silent mode (no progress)

curl -w "%{http_code}" <url>

Print HTTP status code

Advanced Options

curl -L <url>

Follow redirects

curl -k <url>

Ignore SSL certificate errors

curl --max-time <seconds> <url>

Set timeout

curl -x proxy:port <url>

Use proxy

curl -b cookies.txt <url>

Send cookies from file

curl -c cookies.txt <url>

Save cookies to file