Dhairya Shah
Dhairya Shah's Blog

Dhairya Shah's Blog

Introduction to cURL

Introduction to cURL

Dhairya Shah's photo
Dhairya Shah
·Sep 18, 2022·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Introduction

cURL is practically ubiquitous, whether it's testing the output of an API before deploying it to production or simply fetching a response from a website (for example, to ensure it's not down).

As a front-end developer, I had to use it frequently. And I resolved to comprehend the cURL's capabilities fully. As a result, I will share all of my exciting cURL knowledge with you in this article.

What is cURL?

cURL first appeared in 1996. It was developed by a Swedish Developer Daniel Stenberg. It was originally called httpget, then urlget, before taking its current name, cURL.

Did you know? cURL stands for Client URL

To begin using cURL, launch your favorite terminal in Linux/macOS or any Linux-based operating system. If you haven't already, you can install cURL with 'apt-get' on Linux and 'brew' on Mac.

Calling GET Method

The HTTP GET method on the provided URL is the default behavior of cURL.

$ curl https://dhairyashah.dev

This will return the HTTP response output (in this case HTML).

Doing a POST request

$ curl -d '{name: "John", age: "16"}' -H 'Content-Type: application/json' https://example.com/login

Here, -d specifies the data to be passed to the request body. And, -H is the header passed to the request headers.

Fetching site headers

I've already written an article about it, which you can find here.

Conclusion

In this article, you have learned the following things:

  • What is cURL?
  • Calling GET Method
  • Doing POST request
  • Fetching Site Headers

Thanks for reading

Follow me on Twitter

Thanks for reading!

Banner image: Unsplash

 
Share this