Install and use HTTP client tool HTTPie

HTTPie is a command line tool that uses as an HTTP client, enabling us to consume Web Services with a simple, friendly syntax. In this tutorial, I will show you how to install and use it!

First, to install HTTPie, depending on the operating system you are using, you can run 1 of following statements:

– macOS:

or:

– Linux:

or:

or:

– On Window environment, you can use pip tool to install HTTPie.

See more about installing HTTPie here!

I’m using macOS so I will use HomeBrew tool to install it.

Install and use HTTP client tool HTTPie

To check the results, run the command:

Myself is as follows:

Install and use HTTP client tool HTTPie

At this point, you can start using HTTPie.

The syntax of the http command is as follows:

Where:

  • flags defines the options that HTTP will use to process for the request or display response.
  • HTTP_method is the HTTP Method that we will use to request the Web Service. By default, if you do not pass this value, HTTPie will understand GET method if we do not transmit the request data, POST method if there is a request data.
  • URL is the URL of the Web Service. For Web Services deployed in local machine, you don’t need to pass the localhost value. For example, if you have a Web Service at http://localhost:8080/hello, just only need to run “http: 8080/hello”.
  • request_data is data we will send to Web Service.

I will use the example in the tutorial Hello World with Spark framework to consume by HTTPie! I will run the http command as follows:

Result:

Install and use HTTP client tool HTTPie

Find out more about how to use HTTPie here!

Add Comment