Skip to content
>_devvkit
$devvkit learn --librarie curl-guide

cURL Guide

[http][api][cli][networking]
Universal
Install
# macOS (pre-installed) / Linux
sudo apt install curl

# Windows
winget install curl.curl

cURL is the Swiss Army knife of HTTP clients. Every developer reaches for curl at some point.

What makes curl indispensable is its predictability. Once you learn the flag-based syntax, it works the same on your laptop, a CI runner, a Docker container, or a production server.

Basic Requests

GET requestFetch a URL and print the response body.
curl https://api.example.com/users
GET with verboseSee request/response headers and timing.
curl -v https://api.example.com/users
Follow redirectsAutomatically follow Location headers.
curl -L https://example.com
Custom HTTP methodUse -X to specify method.
curl -X POST https://api.example.com/users

Headers & Auth

Set request headerAdd a custom HTTP header.
curl -H "Authorization: Bearer token123" https://api.example.com/users
Basic authSend HTTP Basic Authentication.
curl -u username:password https://api.example.com/login

Data Transfer

POST JSON bodySend a JSON payload.
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alice"}' https://api.example.com/users
Upload fileUpload a file as multipart/form-data.
curl -F "file=@photo.jpg" https://api.example.com/upload
Download fileSave response body to a file.
curl -o output.json https://api.example.com/users

Debugging

Show headers onlyFetch only the HTTP headers.
curl -I https://example.com

Scripting

Silent modeSuppress progress output.
curl -s https://api.example.com/users
Retry on failureAutomatically retry on errors.
curl --retry 3 --retry-delay 5 https://api.example.com/users