Skip to content

Instantly share code, notes, and snippets.

@raghav4
Last active September 30, 2019 03:31
Show Gist options
  • Save raghav4/793c8697b48af6e72b60ab1b1c56c736 to your computer and use it in GitHub Desktop.
Save raghav4/793c8697b48af6e72b60ab1b1c56c736 to your computer and use it in GitHub Desktop.
Getting Started with CURL

Curl & HTTP

  1. curl https://jsonplaceholder.typicode.com/posts/1/comments
  • This will fetch you the json response from the input api url.
  1. curl -i https://jsonplaceholder.typicode.com/posts/1/comments
  • This will include all the header information
  1. curl -I/--head https://jsonplaceholder.typicode.com/posts/1/comments
  • -I or --head will give us only the header.
  1. curl -o/--output filename.txt https://jsonplaceholder.typicode.com/posts
  • This will copy the respone/output in filename.txt
  1. curl -O https://jsonplaceholder.typicode.com/posts/1/comments
  • This will download the response but will not have any extension name.
  1. curl -O --limit-rate 100B https://jsonplaceholder.typicode.com/posts
  • This will limit the transfer rate of our download, to the given speed.
  1. curl --data "title=Hello&body=world" https://jsonplaceholder.typicode.com/posts
  • This will make a Post request to add data to the server using curl.
  1. curl -X PUT -d "title=Raghav" https://jsonplaceholder.typicode.com/posts/3
  • This will make a PUT request to the server.
  1. curl -X DELETE https://jsonplaceholder.typicode.com/posts/3
  • This will make a DELETE request to the server.
  1. curl -L https://google.com
  • This will give us location's response from the url.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment