DevOps

Curl Command Cheatsheet

Comprehensive guide to curl commands covering basic operations, data transfer (POST/JSON), authentication, SSL, file uploads, debugging options, and common flags. Perfect for testing APIs, downloading files, and debugging network issues on your VPS server or local development environment.

#curl #http #api #cli #web-scraping #debugging
Sign In to Download

Free account required

i

Syntax

$ curl [parameters] [URL]

Display the command usage and lists most common options

$ curl -help

Display the command usage and list all available options

$ curl -help all

Basic Operations

Fetch a URL

$ curl http://example.com

Download a file

$ curl -O http://example.com/file.zip

Follow redirections

$ curl -L http://example.com

Data Transfer

Post Data

$ curl -d "key1=value1&key2=value2" http://example.com/post_action

POST JSON Data

$ curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" http://example.com/api

Upload a file

$ curl -F "file=@path_to_file" http://example.com/upload

Authentication & Headers

HTTP Basic Authentication

$ curl -u username:password http://example.com

Add Headers

$ curl -H "Authorization: Bearer YOUR_TOKEN" http://example.com

Other Useful Options

Limit Rate (e.g., 1MB/s)

$ curl --limit-rate 1M -O http://example.com/file.zip

Resume Broken Download

$ curl -C - -O http://example.com/file.zip

Use a Proxy

$ curl -x http://proxyserver:port http://example.com

Debugging & Info

Verbose Mode

$ curl -v http://example.com

Essential for debugging API endpoints when testing your applications on a VPS provider.

Retrieve Only Headers

$ curl -I http://example.com

Curl Version & Protocols

$ curl --version

SSL (Secure Socket Layer)

Skip SSL Certificate Verification

$ curl -k https://example.com

Use SSL Certificate

$ curl --cert mycert.pem https://example.com

Common Options

Option Description
-d, --data <data> HTTP POST data
-f, --fail Fail fast with no output on HTTP errors
-h, --help <category> Get help for commands
-I, --include Include protocol response headers in the output
--output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
--silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
<user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server

Master API Testing & HTTP Requests

Need powerful servers for API development and testing? Check our VPS benchmarks to find hosting providers with optimal network performance, or use our comparison tool to evaluate different options side-by-side.

VPSMetrics - Your trusted source for VPS performance benchmarks and developer tools