dhairyashah
Portfolio

Sep 18th, 2022

Introduction to cURL

Author Picture

Dhairya Shah

Software Engineer

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:

Thanks for reading

Follow me on Twitter

Thanks for reading!

Banner image: Unsplash