TOOL » LINUX » PACKAGE

Curl

Usage

shell
curl OPTIONS URL
OptionDescription
-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.
-F --formEmulate a filled-in form in which a user has pressed the submit button.
-o --outputWrite response into file.
-L --locationFollow redirect.
-k --insecureSkip SSL certificate check.
-s --silentSilent (Does not show progress bar).
-v --verboseMakes curl verbose during the operation.
--noproxyComma-separated list of hosts which do not use a proxy, if one is specified.

Examples

Download file from remote:

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

PUT application/json request:

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

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

shell
curl --request POST \
  --data 'username=admin' \
  --data 'groups[]=user' \
  --data 'groups[]=admin' \
  'https://example.com/api/user'

POST multipart/form-data with a file and a string:

shell
curl --request POST \
  --header "Authorization: $TOKEN" \
  --form 'file=@path/to/file.txt' \
  --form 'name=filename.txt' \
  'https://example.com/storage'

Useful services

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