Linux How-To

HTTPie – A Trendy HTTP Consumer Much like Curl and Wget Instructions

HTTPie (pronounced aitch-tee-tee-pie) is a cURL-like, trendy, user-friendly, and cross-platform command line HTTP consumer written in Python. It’s designed to make CLI interplay with internet providers straightforward and as user-friendly as potential.

HTTPie - A Command Line HTTP Client HTTPie - A Command Line HTTP Client

HTTPie – A Command Line HTTP Consumer

It has a easy http command that allows customers to ship arbitrary HTTP requests utilizing a simple and pure syntax. It’s used primarily for testing, trouble-free debugging, and primarily interacting with HTTP servers, internet providers and RESTful APIs.

HTTPie comes with an intuitive UI and helps JSON.
Expressive and intuitive command syntax.
Syntax highlighting, formatted and colorized terminal output.
HTTPS, proxies, and authentication assist.
Assist for types and file uploads.
Assist for arbitrary request knowledge and headers.
Wget-like downloads and extensions.
Helps ython 2.7 and three.x.

On this article, we are going to present learn how to set up and use httpie with some primary examples in Linux.

Set up and Use HTTPie in Linux

Most Linux distributions present a HTTPie bundle that may be simply put in utilizing the default system bundle supervisor, for instance:

# apt-get set up httpie [On Debian/Ubuntu]
# dnf set up httpie [On Fedora]
# yum set up httpie [On CentOS/RHEL]
# pacman -S httpie [On Arch Linux]

As soon as put in, the syntax for utilizing httpie is:

$ http [options] [METHOD] URL [ITEM [ITEM]]

Probably the most primary utilization of httpie is to offer it a URL as an argument:

$ http instance.com

Basic HTTPie UsageBasic HTTPie Usage

Fundamental HTTPie Utilization

Now let’s see some primary utilization of httpie command with examples.

Ship a HTTP Methodology

You possibly can ship a HTTP methodology within the request, for instance, we are going to ship the GET methodology which is used to request knowledge from a specified useful resource. Word that the identify of the HTTP methodology comes proper earlier than the URL argument.

$ http GET tecmint.lan

Send GET HTTP MethodSend GET HTTP Method

Ship GET HTTP Methodology

Add a File

This instance reveals learn how to add a file to switch.sh utilizing enter redirection.

$ http https://switch.sh < file.txt

Obtain a File

You possibly can obtain a file as proven.

$ http https://switch.sh/Vq3Kg/file.txt > file.txt #utilizing output redirection
OR
$ http –download https://switch.sh/Vq3Kg/file.txt #utilizing wget format

Submit a Kind

You can too submit knowledge to a kind as proven.

$ http –form POST tecmint.lan date=’Hi there World’

View Request Particulars

To see the request that’s being despatched, use -v possibility, for instance.

$ http -v –form POST tecmint.lan date=’Hi there World’

View HTTP Request DetailsView HTTP Request Details

View HTTP Request Particulars

Fundamental HTTP Auth

HTTPie additionally helps primary HTTP authentication from the CLI within the kind:

$ http -a username:password http://tecmint.lan/admin/

Customized HTTP Headers

You can too outline customized HTTP headers in utilizing the Header:Worth notation. We will take a look at this utilizing the next URL, which returns headers. Right here, we’ve outlined a customized Consumer-Agent known as ‘sturdy>TEST 1.zero’:

$ http GET https://httpbin.org/headers Consumer-Agent:’TEST 1.zero’

Custom HTTP HeadersCustom HTTP Headers

Customized HTTP Headers

See a whole checklist of utilization choices by operating.

$ http –help
OR
$ man ttp

Yow will discover extra utilization examples from the HTTPie Github repository: https://github.com/jakubroztocil/httpie.

HTTPie is a cURL-like, trendy, user-friendly command line HTTP consumer with easy and pure syntax, and shows colorized output. On this article, we’ve proven learn how to set up and use httpie in Linux. In case you have any questions, attain us by way of the remark kind under.

Source link

Related Articles

Back to top button