10 Useful CURL commands
| 1 minute read | Using 167 words
Useful CURL commands
Simple GET request:
curl https://example.com
Fetches the content of a webpage or an API endpoint.
Downloading a File:
curl -O http://example.com/file.zip
Downloads a file from a given URL and saves it with the same filename.
Sending a POST Request:
curl -X POST -d "param1=value1¶m2=value2" https://example.com/resource
Sends a POST request with data to a specified resource.
Using Headers in a Request:
curl -H "Content-Type: application/json" -H "Authorization: Bearer TOKEN" https://example.com/api
Sends a request with additional header information.
Saving Output to a File:
curl https://example.com > output.html
Directs the output of the request to a file.
Resuming a Download:
curl -C - -O http://example.com/largefile.zip
Resumes a previously interrupted download.
Sending JSON Data:
curl -H "Content-Type: application/json" -d '{"key1":"value1", "key2":"value2"}' https://example.com/api
Sends a request with JSON data.
Using Cookies:
curl -b cookies.txt -c newcookies.txt https://example.com
Sends a request with cookies from a file and saves received cookies.
FTP Upload:
curl -u username:password -T file.txt ftp://ftp.example.com/directory/
Uploads a file to an FTP server.
Verbose Mode:
curl -v https://example.com
Page link: /posts/useful-curl-commands/