Linux
linuxlinux-commandsReferenceBeginner
Transfer Data from or to a Server (curl)
Make HTTP requests, test APIs, download files, and inspect response headers using curl.
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacoswindows
#linux#curl#http#api#networking
Command
curl -X POST https://api.example.com/data -H "Content-Type: application/json" -d '{"key":"val"}'
Short Description
curl is a command-line tool for transferring data to or from a server using protocols including HTTP, HTTPS, FTP, and SCP.
Examples
1. Download File and Save Output (-o or -O)
# Save to specific filename
curl -o setup.tar.gz https://example.com/downloads/setup.tar.gz
# Save using remote filename
curl -O https://example.com/file.zip2. Inspect HTTP Response Headers Only (-I)
curl -I https://docs.tashanto.com3. Send JSON POST Request
curl -X POST https://api.example.com/v1/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer my_jwt_token" \
-d '{"name": "Alice", "role": "admin"}'4. Follow Redirects (-L) and Silent Progress (-s)
curl -sL https://get.pnpm.io/install.sh | sh -