J O S E P H J O S E P H

cURL

Basic Usage

Get only the response status code from a request

curl -s -o /dev/null -w "%{http_code}\n" http://example.com  #=> 200

# Description
-s                   # Silent mode. Don't show download progress.
-o /dev/null         # Suppress the response body
-w "%{http_code}\n"  # Write-out the numerical response code (+ newline)

Pretty-print JSON response body using jq (must have jq installed already)

curl -s https://highlights-api-production.up.railway.app/random | jq .

Download to File

Write output to a local file instead of stdout

curl http://example.com/some-file.txt -o ./myfile.txt

Write output to a local file named like the remote file

curl -O http://example.com/some-file.txt