TOOL » LINUX » PACKAGE

Curl

Usage

shell
curl OPTIONS URL
OptionDescription
-v --verboseMakes curl verbose during the operation.
-X --requestSpecifies a custom request method (GET, HEAD, POST, PUT).
-H --headerExtra header to include in the request when sending HTTP to a server.
-d --dataSends the specified data to the HTTP server.
-s --silentSilent (Does not show progress bar).
-o --outputWrite response into file.
-L --locationFollow redirect.
-k --insecureSkip SSL certificate check.
--noproxyComma-separated list of hosts which do not use a proxy, if one is specified.

Examples

Download file from remote:

shell
curl -o pylint.svg "https://img.shields.io/badge/pylint-10-green.svg"
curl -o nvim.appimage -L https://github.com/neovim/neovim/releases/download/v0.10.2/nvim.appimage

PUT application/json request:

shell
curl -X PUT \
  -H 'Content-Type:application/json' \
  -d '{"json":1,"encoded":{"key":"value"}}' \
  http://mysite.com/api/user/1

POST application/x-www-form-urlencoded request with array:

shell
curl -X POST \
  -d 'username=admin' \
  -d 'groups[]=user' \
  -d 'groups[]=admin' \
  http://mysite.com/api/user

Useful services

CommandService
curl ifconfig.mePublic IP address
curl ja.wttr.inWeather forecast (in japanese)