Skip to content

httpie command on Linux (download files)

The httpie command on Linux is similar to CURL, but its use is simpler. It allows you to download files and also connect to web APIs to test REST or Backend Javascript web applications.

It allows you to interact with HTTP servers, RESTful APIs, and web services.

To install on Ubuntu or Debian:

$ apt-get install httpie

To install on Red Hat/CentOS/Fedora:

$ yum install httpie

Once installed, its use is simple, simply enter the URL:

$ http 'https://api.openweathermap.org/data/2.5/weather?q=Belo%20Horizonte,PT&appid=9908ae7bbb3c530f54efdec77ac3ccde' <br></br>HTTP/1.1 200 OK <br></br>Access-Control-Allow-Credentials: true <br></br>Access-Control-Allow-Methods: GET, POST <br></br>Access-Control-Allow-Origin: * <br></br>Connection: keep- alive <br></br>Content-Length: 476 <br></br>Content-Type: application/json; charset=utf-8 <br></br>Date: Tue, 12 May 2020 22:26:42 GMT <br></br>Server: openresty <br></br>X-Cache-Key: /data/2.5/weather? q=belo%20Horizonte, pt

{
“base”: “stations”,
“clouds”: {
“all”: 81
}, The http command already does the job of entering the header and formatting the JSON, without the need to enter additional parameters and commands.

It allows you to pass POST parameters:

$ http -f POST httpbin.org/post hello=World <br></br>HTTP/1.1 200 OK <br></br>Access-Control-Allow-Credentials: true <br></br>Access-Control-Allow-Origin: * <br></br>Connection: keep-alive <br></br>Content-Length: 488 <br></br>Content-Type: application/json <br></br>Date: Tue, 12 May 2020 22:32:16 GMT <br></br>Server: gunicorn/19.9.0 <br></br>{<br></br>“args”: {}, <br></br>“data”: “”, <br></br>“files”: {}, <br></br>“form”: {<br></br>“hello”: “World”<br></br>}, <br></br>“headers”: {<br></br>“Accept”: “*/*”, <br></br>“Accept-Encoding”: “gzip , deflate”, <br></br>“Content-Length”: “11", <br></br>“Content-Type”: “application/x-www-form-urlencoded; charset=utf-8", <br></br>“Host”: “httpbin.org”, <br></br>“User-Agent”: “HTTPIE/2.1.0", <br></br>“X-Amzn- Trace-Id”: “root=1-5ebb23f0-c052d8b2169a5304df2fee88"

},
“json”: null,
“origin”: “192.241.133.165”,
“url”: “http://httpbin.org/post
} A file can also be sent in a simple way, using redirection

: ``` $ http httpbin.org/post < file.json

Likewise, a file can be downloaded and saved using output redirection:

$ http http://bin.org/image/png > image.png

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.
Did you like it?
-----------------
Share