/curl-cheat-sheet

Common curl commands with examples

curl Cheat Sheet

Official man page
Official FAQ


Jump to: GET | POST | PUT | DELETE | PATCH | Verbose Output | Basic Auth | Ignore Insecure SSL Connections | Headers | Output to File


GET

Example: curl http://www.example.com/resource/123


POST

-X POST -d "bodyContents"
-X POST -d @fileWithBodyContents
Example: curl -X POST -d "my contents to post" http://www.example.com/doit


PUT

-X PUT -d "bodyContents"
-X PUT -d @fileWithBodyContents
Example: curl -X PUT -d "my contents to put" http://www.example.com/doit


DELETE

-X DELETE
Example: curl -X DELETE http://www.example.com/resource/123


PATCH

--request PATCH -d "patchContents"
--request PATCH -d @fileWithPatchContents
Example: curl --request PATCH -d "foo=bar" http://www.example.com/resource/123


Verbose Output

-v, --verbose
Example: curl -v https://www.google.com


Basic Auth

-u username:password
Example: curl -u claptrap:Password1 http://www.example.com


Ignore Insecure SSL Connections

-k, --insecure
Example: curl -k https://www.badcert.com


Specify Headers

-H "headerName: headerValue"
Example: curl -H "Content-Type: application/json" http://www.example.com


Write Output to File

-o, --output <filename>
Example: curl -o capture.txt http://www.example.com