Link Search Menu Expand Document

cURL with API

Table of contents

Basic cURl

For more cURL command, click here.

curl -I

-I for request header

curl -i

-i for header and content

Create file with cURL and open resource jsonplaceholder

  1. Change directory; cd /example-folder.
  2. Run cURL to generate text.txt file.
curl -o test.txt
  • -o stands for --output. It writes the output content from jsonplaceholder to text.txt

Download with -O

Note: -O and -o, using capitalised O for download.

curl -O

Download with limit using flag --limit-rate 1000B

curl -O --limit-rate 1000B

Post data

  • -d stands for --data
  • -X flag specifies a HTTP request method when communicates with the remote server.
curl --data "title=Hello&body=hello world"
curl -X POST --data "title=Hello&body=hello world" | jq

Put request

curl -X PUT --data "title=hello" 

Delete request

curl -X DELETE 

cURL with FTP (File Transfer Protocol)

The syntax is curl -u username:password https://xxxxx

Upload to FTP

curl -u [email protected]:123456!(password) -T hello.txt

Download from FTP

curl -u [email protected]:123456!(password) -O