curl

CLI

Transfer data from or to a server using various protocols.

Universal URL transfer tool supporting HTTP, FTP, SMTP and more

8 of 10 recipes verified by execution · 2026-10-03#http#download#upload#transfer

Verified commands

Executed by our harness on the platforms shown; the assertion checked the actual result, not just the exit code.

Get only the HTTP status code

Verified macOS · Linux · 2026-09-17
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/

Get the body and the status code together

Verified macOS · Linux · 2026-09-17
curl -s -w '\n%{http_code}\n' https://example.com/

POST JSON from a file

Verified macOS · Linux · 2026-09-17
curl -sS -X POST -H 'Content-Type: application/json' -d @body.json https://api.example.com/items
Common failures (1)
  • server reports invalid JSONinline -d '{...}' quoting broke; put the payload in a file and use -d @body.json

Fail the command on HTTP 4xx/5xx (for scripts)

Verified macOS · Linux · 2026-09-17
curl -sSf https://api.example.com/health
Common failures (1)
  • exit code 22the server returned an HTTP error; drop -f to see the body

Follow redirects

Verified macOS · Linux · 2026-09-17
curl -sL -o /dev/null -w '%{http_code}\n' https://example.com/redirect

Send a bearer token

Verified macOS · Linux · 2026-09-17
curl -s -H 'Authorization: Bearer TOKEN' https://api.example.com/me

Call an API and pick a value with jq

Verified macOS · Linux · 2026-09-17
curl -s https://api.example.com/data | jq '.items | length'

Retry a flaky request instead of failing once

Verified macOS · Linux · 2026-10-03
curl -fsS --retry 3 --retry-delay 2 --retry-all-errors https://api.example.com/health
Common failures (1)
  • curl: option --retry-all-errors: is unknownneeds curl 7.71+; drop that flag and keep --retry 3, which already retries transient failures and 5xx

More recipes

Curated from documentation and usage. Percentages are estimates, not measurements.

Download a file

~98% est.
curl -L -o output.zip https://example.com/file.zip

Get this machine's public IP address

~97% est.
curl -s https://api.ipify.org
Common failures (1)
  • empty output behind a proxy or offlineadd -f to make the failure visible, or try https://ifconfig.me as a second source

Install

aptsudo apt install curl
Homebrewbrew install curl

Agent notes

When to use
Downloading files, calling APIs, scripting HTTP requests
Quick examples
  • curl -s https://api.example.com/data
  • curl -X POST -d '{"key":"val"}' -H 'Content-Type: application/json' URL

Use from an agent

curl -s https://clihub.com/api/tools/curl | jq '.agentHints.provenRecipes[] | {task, command, verified}'

Or call get_tool with slug curl on the MCP server at https://clihub.com/mcp.

Homepage ↗curl (MIT-like)0 views