Tools

curl

HTTP requests from the command line — options, headers, and SSL.

Options

-o <file>Write output to file
-u user:passHTTP authentication
-vVerbose output
-sSilent mode
-iInclude response headers
-IHeaders only (HEAD request)
-LFollow redirects

Request & data

-X POSTSet HTTP method
-d 'body'POST body (URL-encoded)
-d @filePOST body from file
-F key=valMultipart form upload
-GAppend -d data as GET params

Headers

-H "Key: val"Add request header
-H "Content-Type: application/json"JSON content type
-A "agent"Set user agent
-b name=valSend cookie
--compressedRequest gzip compression

SSL

-k, --insecureSkip certificate verification
--cacert <file>CA certificate file
-E <cert>Client certificate

Examples

# GET with JSON header
curl -H "Accept: application/json" https://api.example.com/users

# POST JSON body
curl -X POST -H "Content-Type: application/json" \
  -d '{"name":"Ada"}' https://api.example.com/users

# Download file
curl -o output.zip https://example.com/file.zip

# Bearer token auth
curl -H "Authorization: Bearer $TOKEN" https://api.example.com