Tips for Using Curl as a REST Client

> docker run -it --rm centos:8 curl --version

Basic Curl Downloads to File or STDOUT

curl -O
curl | grep carping
curl$SPARK_VERSION/$PACKAGE.tgz | tar -xvz -C /opt

Rest Client: Useful Command Flags

curl -X DELETE localhost:9200/myindex
-H 'Content-Type: application/json'
-d '{"type": "s3"}'
> seq 100 | curl -d @- -XPUT 'http://nsqd:4151/pub?topic=test'
-u elastic:$es_password
--connect-timeout 5 # Max time to take making a connection
--max-time 10 # Max time permitted for the whole operation
--retry 5 # Number of times to retry
--retry-delay 0 # Wait this amount of time between retries
--retry-max-time 40 # Total time making a connection before failure

Parsing JSON Outputs

$ curl -Ss -k
$ curl -Ss -k | jq .
“versions”: [

Elasticsearch Example

curl -u “elastic:$PASSWORD” -k -X PUT “$ESHOST/_snapshot/my_s3_repository?pretty” -H 'Content-Type: application/json' -d'
“type”: “s3”,
“settings”: {
“bucket”: “elastic-snapshots”,
“endpoint”: “”,
“protocol”: “http”,
“max_restore_bytes_per_sec”: “1gb”,
“max_snapshot_bytes_per_sec”: “200mb”
curl -X DELETE -u "elastic:$PASSWORD" -k "$ESHOST/oops_index?pretty"




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store