{"id":11844,"date":"2019-03-17T14:11:38","date_gmt":"2019-03-17T14:11:38","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11844"},"modified":"2019-03-17T14:11:38","modified_gmt":"2019-03-17T14:11:38","slug":"httpie-a-modern-http-client-similar-to-curl-and-wget-commands","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/httpie-a-modern-http-client-similar-to-curl-and-wget-commands\/","title":{"rendered":"HTTPie \u2013 A Modern HTTP Client Similar to Curl and Wget Commands"},"content":{"rendered":"<p><strong>HTTPie<\/strong>\u00a0(pronounced aitch-tee-tee-pie) is a\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-curl-command-examples\/\" target=\"_blank\" rel=\"noopener\">cURL-like<\/a>, modern, user-friendly, and cross-platform command line HTTP client written in Python. It is designed to make CLI interaction with web services easy and as user-friendly as possible.<\/p>\n<div id=\"attachment_31600\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/HTTPie-HTTP-Client.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31600\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/HTTPie-HTTP-Client.png\" alt=\"HTTPie - A Command Line HTTP Client \" width=\"500\" height=\"654\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">HTTPie \u2013 A Command Line HTTP Client<\/p>\n<\/div>\n<p>It has a simple http command that enables users to send arbitrary HTTP requests using a straightforward and natural syntax. It is used primarily for testing, trouble-free debugging, and mainly interacting with HTTP servers, web services and RESTful APIs.<\/p>\n<ul>\n<li><strong>HTTPie<\/strong>\u00a0comes with an intuitive UI and supports JSON.<\/li>\n<li>Expressive and intuitive command syntax.<\/li>\n<li>Syntax highlighting, formatted and colorized terminal output.<\/li>\n<li>HTTPS, proxies, and authentication support.<\/li>\n<li>Support for forms and file uploads.<\/li>\n<li>Support for arbitrary request data and headers.<\/li>\n<li>Wget-like downloads and extensions.<\/li>\n<li>Supports ython 2.7 and 3.x.<\/li>\n<\/ul>\n<p>In this article, we will show how to install and use httpie with some basic examples in Linux.<\/p>\n<h3>How to Install and Use HTTPie in Linux<\/h3>\n<p>Most Linux distributions provide a\u00a0<strong>HTTPie<\/strong>\u00a0package that can be easily installed using the default system package manager, for example:<\/p>\n<pre># apt-get install httpie  [On Debian\/Ubuntu]\r\n# dnf install httpie      [On Fedora]\r\n# yum install httpie      [On CentOS\/RHEL]\r\n# pacman -S httpie        [On Arch Linux]<\/pre>\n<p>Once installed, the syntax for using\u00a0<strong>httpie<\/strong>\u00a0is:<\/p>\n<pre>$ http [options] [METHOD] URL [ITEM [ITEM]]\r\n<\/pre>\n<p>The most basic usage of\u00a0<strong>httpie<\/strong>\u00a0is to provide it a URL as an argument:<\/p>\n<pre>$ http example.com\r\n<\/pre>\n<div id=\"attachment_31593\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/basic-usage-example.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31593\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/basic-usage-example.png\" alt=\"Basic HTTPie Usage\" width=\"552\" height=\"268\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Basic HTTPie Usage<\/p>\n<\/div>\n<p>Now let\u2019s see some basic usage of\u00a0<strong>httpie<\/strong>\u00a0command with examples.<\/p>\n<h4>Send a HTTP Method<\/h4>\n<p>You can send a HTTP method in the request, for example, we will send the\u00a0<strong>GET<\/strong>\u00a0method which is used to request data from a specified resource. Note that the name of the HTTP method comes right before the URL argument.<\/p>\n<pre>$ http GET tecmint.lan\r\n<\/pre>\n<div id=\"attachment_31594\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/send-get-http-method.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31594\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/send-get-http-method.png\" alt=\"Send GET HTTP Method\" width=\"552\" height=\"268\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Send GET HTTP Method<\/p>\n<\/div>\n<h4>Upload a File<\/h4>\n<p>This example shows how to upload a file to\u00a0<a href=\"https:\/\/www.tecmint.com\/file-sharing-from-linux-commandline\/\" target=\"_blank\" rel=\"noopener\">transfer.sh<\/a>\u00a0using input redirection.<\/p>\n<pre>$ http https:\/\/transfer.sh &lt; file.txt\r\n<\/pre>\n<h4>Download a File<\/h4>\n<p>You can download a file as shown.<\/p>\n<pre>$ http https:\/\/transfer.sh\/Vq3Kg\/file.txt &gt; file.txt\t\t#using output redirection\r\nOR\r\n$ http --download https:\/\/transfer.sh\/Vq3Kg\/file.txt  \t        #using wget format\r\n<\/pre>\n<h4>Submit a Form<\/h4>\n<p>You can also submit data to a form as shown.<\/p>\n<pre>$ http --form POST tecmint.lan date='Hello World'\r\n<\/pre>\n<h4>View Request Details<\/h4>\n<p>To see the request that is being sent, use\u00a0<code>-v<\/code>\u00a0option, for example.<\/p>\n<pre>$ http -v --form POST tecmint.lan date='Hello World'\r\n<\/pre>\n<div id=\"attachment_31595\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/view-request-details.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31595\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/view-request-details.png\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/view-request-details.png 792w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/view-request-details-768x463.png 768w\" alt=\"View HTTP Request Details\" width=\"792\" height=\"477\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">View HTTP Request Details<\/p>\n<\/div>\n<h4>Basic HTTP Auth<\/h4>\n<p>HTTPie also supports basic HTTP authentication from the CLI in the form:<\/p>\n<pre>$ http -a username:password http:\/\/tecmint.lan\/admin\/\r\n<\/pre>\n<h4>Custom HTTP Headers<\/h4>\n<p>You can also define custom HTTP headers in using the\u00a0<strong>Header:Value<\/strong>\u00a0notation. We can test this using the following URL, which returns headers. Here, we have defined a custom User-Agent called \u2018strong&gt;TEST 1.0\u2019:<\/p>\n<pre>$ http GET https:\/\/httpbin.org\/headers User-Agent:'TEST 1.0'\r\n<\/pre>\n<div id=\"attachment_31596\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/define-custom-http-headers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31596\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/define-custom-http-headers.png\" sizes=\"auto, (max-width: 832px) 100vw, 832px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/define-custom-http-headers.png 832w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/01\/define-custom-http-headers-768x388.png 768w\" alt=\"Custom HTTP Headers\" width=\"832\" height=\"420\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Custom HTTP Headers<\/p>\n<\/div>\n<p>See a complete list of usage options by running.<\/p>\n<pre>$ http --help\r\nOR\r\n$ man  ttp\r\n<\/pre>\n<p>You can find more usage examples from the\u00a0<strong>HTTPie Github<\/strong>\u00a0repository:\u00a0<a href=\"https:\/\/github.com\/jakubroztocil\/httpie\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/jakubroztocil\/httpie<\/a>.<\/p>\n<p><strong>HTTPie<\/strong>\u00a0is a\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-curl-command-examples\/\" target=\"_blank\" rel=\"noopener\">cURL-like<\/a>, modern, user-friendly command line HTTP client with simple and natural syntax, and displays colorized output. In this article, we have shown how to install and use httpie in Linux. If you have any questions, reach us via the comment form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/httpie-http-client-for-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTPie\u00a0(pronounced aitch-tee-tee-pie) is a\u00a0cURL-like, modern, user-friendly, and cross-platform command line HTTP client written in Python. It is designed to make CLI interaction with web services easy and as user-friendly as possible. HTTPie \u2013 A Command Line HTTP Client It has a simple http command that enables users to send arbitrary HTTP requests using a straightforward &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/httpie-a-modern-http-client-similar-to-curl-and-wget-commands\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;HTTPie \u2013 A Modern HTTP Client Similar to Curl and Wget Commands&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11844","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11844","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11844"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11844\/revisions"}],"predecessor-version":[{"id":11845,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11844\/revisions\/11845"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}