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'
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Origin: *
Connection: keep- alive
Content-Length: 476
Content-Type: application/json; charset=utf-8
Date: Tue, 12 May 2020 22:26:42 GMT
Server: openresty
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
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 488
Content-Type: application/json
Date: Tue, 12 May 2020 22:32:16 GMT
Server: gunicorn/19.9.0
{
“args”: {},
“data”: “”,
“files”: {},
“form”: {
“hello”: “World”
},
“headers”: {
“Accept”: “*/*”,
“Accept-Encoding”: “gzip , deflate”,
“Content-Length”: “11",
“Content-Type”: “application/x-www-form-urlencoded; charset=utf-8",
“Host”: “httpbin.org”,
“User-Agent”: “HTTPIE/2.1.0",
“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.
Share
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.