Httpie: A CLI http client
radek.io
radek.io
As others noted, I'd revert to curl commands for sharing with others (or for performance-sensitive tasks like downloads or quick-and-dirty load generation) but this may become my go-to HTTP CLI for personal use -- if only because it looks like won't need to look at the man page every time I want to do much more than a basic curl -X <METHOD> <URL>. (But maybe that says more about me than curl/httpie.)
One neat feature to add would be a mode that accepts the curl syntax (or at least the common parts of it), that way all the curl examples and "Copy as curl" tools work with httpie as well.
Conversely, an option that accepts httpie syntax and outputs the corresponding curl command might be convenient as well. (But I guess at that point maybe httpie devolves into a command-line parser + pretty-printer that wraps around curl, but that may not be all bad either.)
Agreed that curl is good for things that should be copied and pasted directly or for matters of distribution because it is guaranteed to be installed everywhere.
Would also love a httpie2curl converter for those times when testing in httpie and needing to distribute the requests to places without it.
But I fully agree, it's a complement.
It also follows unix conventions in option placement and syntax, so there's never any cognitive hurdle to cross when the question arises where to put headers, where to put form data, where to put query string data, how to handle the case of query string data being supplied using overlapping methods and what the form data is encoded in.
It also doesn't force me to write json in yet another syntax that's command-line friendly. Instead I can just write json.
Yes. HTTPie looks nicer, but the wide availability of curl and the much more predictable syntax make it a better tool for my taste.
If I need formatted JSON output, I can always pipe the result in to jq.
Without jq, you can still pipe to python json.tool module:
$ curl http://domain.com | python -m json.tool
One liner-wise, you could create an alias
echo '{"foo":12, "bar": 11}' | python -c 'import json as j, collections as c, sys as s; j.dump(j.load(s.stdin, object_pairs_hook=c.OrderedDict), s.stdout, indent=4)'
[0] https://github.com/python/cpython/blob/3.5/Lib/json/tool.py#...1. jq project page: https://stedolan.github.io/jq/
2. jq HN Discussion: https://news.ycombinator.com/item?id=9446980
This comment from the jq HN submission discusses httpie, jq, and httpie vs. curl: https://news.ycombinator.com/item?id=9447175
Using only tools based on ubiquity is rather short sighted.
That said, I use curl and httpie. I am a casual user of both and love them both. I first heard about httpie on HN.
One thing has always bugged me, maybe someone knows how to fix it.
This command works fine:
$ http example.com
And http symlinks to the right binary: $ which http
/usr/local/bin/http
$ ls -l /usr/local/bin/
...
lrwxr-xr-x 1 taylor admin 31 Jun 25 2014 http -> ../Cellar/httpie/0.8.0/bin/http
...
But man shows a different executable: $ man http
...
NAME
http - Client-side implementation of the HTTP/1.1 protocol
...If there is a manpage, it's possible that another manpage exists with the same name, but in a different category (such as a system call). In that case, running "man 1 http" will restrict man to only look for a user command manpage.
The article says pip, I used apt-get which is probably somewhat behind. Either way.
EDIT: yep, the version in my repo was 0.8.0. I uninstalled and used pip, it's now 0.9.2.
AGENT/##.## (url)
where `AGENT` is the identifier for the user agent, ##.## is the major/minor version, and url is the url for the tool/project/bot.In this case, one minor tweak might be...
HTTPie/%s (https://github.com/jkbrzt/httpie)
It's a minor nit, but trying to find something based on "foo/version" alone isn't always easy enough when looking at your logs.[0] https://chrome.google.com/webstore/detail/postman/fhbjgbifli...
To be honest, I am a little surprised to see it here because I thought everyone already knows about it.
HTTPie (pronounced aych-tee-tee-pie) is a command line HTTP client.
The name, as written on the repository, is "HTTPie", and not "Httpie" like in the title of this post.H-T-T-Pie, which I'd relate to it being written in Python, where the file extension and several other names have "py" (pronounced as "pie") in some form.