Curl

A command to send an HTTP Request to a website. You can set many different options for example if you want to add cookies or send a data in your request. The most simple way to use this command is just to specify the URL.

curl www.example.com

Curl will access the webserver and request the default webpage since you didn’t specify the path. Here are some usefull options for curl:

-o <FILE>
	save the output in <FILE>

-i
	show HTTP Response Headers

-A "STRING"
	specify the User-Agent to use

-b <COOKIE>
	specify the cookie to use

-u <USER>:<PASSWORD>
	sets the username and password for HTTP Basic Authentication
	
-H "STRING"
	allows you to set a header. Here an example on how to set an 
	Authorization header
	curl -H 'Authorization: Basic YWRtaW46YWRtaW4='

-X [POST|GET|PUT|...]
	Specift the HTTP Method/Verb you want to use.
	
-d "STRING"
	Specify the data you want to send. Curl will automatically send an HTTP POST Request. 
	No need to use -X POST

Another good thing to know is that you can copy a Curl command from the Browser DevTools. Simply open them and go to the Network Section there you can copy the HTTP Requests you browser makes as a Curl command.

Examples

Authenticate and retrieve JSON data while beautifying it with Jq

curl -u admin:admin example.com:30351/JSON_file | jq

Upload a new resource with an HTTP POST Request

curl -X POST example.com:30351/api.php/new_resource -d "something" -v

Send an HTTP DELETE Request

curl -X DELETE example.com:30351/api.php/something -v