DEV Community

Cover image for A Beginner's Guide to Curl: Part 1 - Your First Curl
Jesse vB
Jesse vB

Posted on

A Beginner's Guide to Curl: Part 1 - Your First Curl

Curl (client-URL) is a command line utility app. In the same way your web browser accesses online resources via the address bar, so curl does the same via the a command line interface.

For example, open a new tab and go to this website, www.example.com. You probably saw a very boring looking example webpage. If you inspect the HTML in your browser, you'll see it's the standard <head> and <body> with some <div>, <h1>, and <p> tags. That's because the remote server behind this domain name serves HTML back when any client makes a GET request to that specific url. Your browser is able present the HTML visually to you.

Now, do the same thing in your terminal or command prompt. Type the following command and hit return.

Don't worry about typing the "$". That just shows this is a shell command we're typing.

$ curl http://www.example.com
Enter fullscreen mode Exit fullscreen mode

You should have received several lines of text as a response. In the exact same way that example.com returned HTML to your web browser, it returned the same response to your command line client. You successfully just consumed a server response by using a terminal client instead of a browser.

Curl is very powerful, because you can work with server requests and responses directly without a browser getting in your way.

If you've ever used a tool like Postman for working with APIs, you'll find that curl can do almost all the same things if you know how to use it.

Curl is very simple. You type the word curl followed by an address (URL). Hit return and you get a response!

That's not all! You can customize your command with many different options and flags. Each one accomplishes a specific purpose. You could spend months or years trying to master all the different functionalities of curl.

Are you ready? Let's get started in my next article, A Beginner's Guide to Curl: Part 2

Top comments (0)