From XennisWiki
Jump to: navigation, search

cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. The cURL project produces two products, libcurl and cURL. It was first released in 1997. The name stands for "Client URL". (Wikipedia)



apt-get install -y curl


Parameter Description
--connect-timeout <seconds> Timeout in seconds
--location Follow redirect
--include [-i] Output HTTP header
--insecure Allow insecure certificates
--silent Quit outout
--user <user>:<pass> Basic auth
--header '<key>: <value>' Header

Download a file

Further information: wget vs curl: How to Download Files Using wget and curl

curl -O

(With wget it is wget

Download a file silently with a output name

curl --output local-name.txt --silent

POST request

HTTP POST sending JSON with authorization header

data='{"count": 10, "name": "text"}'
curl \
    --request POST \
    --header 'Content-Type: application/json' \
    --header "Authorization: Bearer ${JWT}" \
    --data $data


Parsing JSON with jq

Further information: jq Turotial

On Arch Linux install the jq. Just pipe the output of cURL into jq

curl '' | jq '.'

Query the result like

curl '' | jq '.cars[0].color'

Get the same result without the quotes

curl '' | jq --raw-output '.cars[0].color'

See also

External links