Live data from Hacker News

HTTPie: A cURL-like tool for humans

github.com

71–80 of 88 posts

Re: HTTPie: A cURL-like tool for humans

#71

Earlier quoted context omitted.

Gosh, what a horrible comment! The simple fact is that curl and wget's interfaces are bad, and everyone who learns to use them spends that 10 minutes. And then, if you're like me, respends that 10 minutes when I need to do something fancy again. If a new tool were to save 5 minutes (which this one does), that's 5 minutes saved on every use, which is probably a total of a few hours for me personally, and spread over t…

All the competing tools are not "for humans." Who are they for, then? If you don't see the negativity in that sales pitch (and your own complaining about other people's creations, which were also the products of hard work) then I don't think you are being honest with yourself. If this tool actually didn't require me to go to a man page and read lots of flags (.... exactly like every other tool) then I might be more e…

curl's interface is a PITA for testing JSON APIs. HTTPie's isn't:

  http POST http://localhost:3000/person/create name="James"
The "for humans" bit signifies the author has taken care to simplify the interface for practical use, rather than for shell scripting.

Re: HTTPie: A cURL-like tool for humans

#72
post #56

Everything on HN is just "hey, learn to use this complicated complex thing - in just 30 minutes! You'll be so productive with all your creative startups!" "Learn VIM essentials in this blog post!" "Never bother reading 'man curl'!" "Learn the basics of C in three easy steps!" Sometimes HN feels like a lifestyle magazine for people who dream of being PG. EDIT: Don't get me wrong, I too dream of having the same succes…

Also not sure what your complaint is. Working at the right level of abstraction is fundamental to being a good engineer.

Re: HTTPie: A cURL-like tool for humans

#73
post #10

I was looking for something like this a while back and found a useful firefox plugin called Poster ( https://addons.mozilla.org/en-us/firefox/addon/poster/ ). It's useful for testing a RESTful api without creating any front-end code to handle the requests. Or anything you can do with cURL just simpler.

Hope a little bit of self-promotion isn't frowned upon - I have a similar app [1] on the Mac App Store. One nice thing it does is allow you to save a request in a a file, to be re-used later. A lot of folks I've talked to have used this to share test cases in a QA organization, and I think it can be kind of handy (although, the free browser-based ones are quite good, too).

I'm working on adding conversion to/from cURL and wget commands, which could be helpful when working with APIs that are documented with cURL examples.

It costs $2, but I'll give anyone who asks (well, up to 50 people at least) a free copy - my contact info is in my profile.

1. http://itunes.apple.com/us/app/graphicalhttpclient/id4330958...

Re: HTTPie: A cURL-like tool for humans

#74
post #51

Earlier quoted context omitted.

I don't really think curl is much harder, e.g. curl -X PUT -d @data/test.json httpbin.org/put It also has the advantage that it supports all the options you might ever need, for example http authentication and proxies are often useful.

HTTPie also supports proxies and HTTP auth (see --proxy and -a/--auth).

Doesn't support socks 4/5 proxies. :)

Requests and urllib3 have a long way to go to be complete competitors with cURL.

P.S. Good job nonetheless. Seems like a good idea to make a specialized HTTP CLI client for JSON/RESTful services.

Re: HTTPie: A cURL-like tool for humans

#75
post #45

Earlier quoted context omitted.

That's true, but it's no better there, either. Here's some sample curl client code in PHP. $c = curl_init("https://someurl/some/api"); $msg = /* some data here */ $opts = array( CURLOPT_POST=>TRUE, CURLOPT_USERPWD=>" ", CURLOPT_HTTPHEADER=>array("Content-type: application/json"), CURLOPT_POSTFIELDS=>$msg, CURLOPT_SSL_VERIFYPEER=>FALSE, CURLOPT_RETURNTRANSFER=>TRUE ); curl_setopt_array($c, $opts); $d = curl_exec($c);…

On the other hand I guess you could probably write a nice library that uses curl under the hood, here it's just a case of ugly design.

Indeed, I do exactly that: http://requests.ryanmccue.info/

I completely agree on cURL's design though. It's painfully obvious when working with the cURL bindings in PHP that it didn't have much thought put in to adapting it to PHP's constraints and is essentially just the command line client in a "nice" wrapper. It ends up being a huge pain to work with.

Re: HTTPie: A cURL-like tool for humans

#76
This is a good tool. I wish there's an editor-integrated interactive http tool.

OT: Is there an Emacs package that can do interactive invocation of http? Like having a text buffer to hold all the urls. Hitting Ctrl-E on a url to invoke it, and display the http response headers and result on separate buffers.

Re: HTTPie: A cURL-like tool for humans

#77
post #76

This is a good tool. I wish there's an editor-integrated interactive http tool. OT: Is there an Emacs package that can do interactive invocation of http? Like having a text buffer to hold all the urls. Hitting Ctrl-E on a url to invoke it, and display the http response headers and result on separate buffers.

OT: You just pretty much summed up restclient.el - https://github.com/pashky/restclient.el

Re: HTTPie: A cURL-like tool for humans

#78
post #71

Earlier quoted context omitted.

All the competing tools are not "for humans." Who are they for, then? If you don't see the negativity in that sales pitch (and your own complaining about other people's creations, which were also the products of hard work) then I don't think you are being honest with yourself. If this tool actually didn't require me to go to a man page and read lots of flags (.... exactly like every other tool) then I might be more e…

curl's interface is a PITA for testing JSON APIs. HTTPie's isn't: http POST http://localhost:3000/person/create name="James" The "for humans" bit signifies the author has taken care to simplify the interface for practical use, rather than for shell scripting.

Yup, I was excited to see that.

I have a text file with examples of testing different kinds of API calls w/ curl, and I have to refer to it all the time because the syntax is so easy to get wrong if I just type it out. I've also had to waste lots of time supporting other developers using our API, who got tangled up in the curl syntax in the examples I provide them.

Re: HTTPie: A cURL-like tool for humans

#79
I like it, though I got around curl's painful syntax by wrapping it in a few shell script. For example, here's my api_post script (meant to be used like "api_post users/123 first_name=Foo last_name=Bar") (pardon my incompetent shell scripting and redaction of company internals):

  #!/bin/sh
  
  resource="$1"
  shift
  
  declare -a post
  while [ "$1" ]; do
      post=("${post[@]}" "-F" "$1")
      shift
  done
  
  if [ -z "${API_BASE:=}" ]; then
      API_BASE=http://localhost:3000/api/v1/
      echo "No API_BASE set.  Using $API_BASE."
  fi
  
  verbose=""
  [ -n "$API_VERBOSE" ] && verbose="-v"
  
  if [ -z "${API_COOKIES:=}" ]; then
      cookies=~/.api.cookies
  else
      cookies="$API_COOKIES"
  fi
  
  curl -0 -k -s -S $verbose -b "$cookies" -c "$cookies" -X POST "${post[@]}" "${API_BASE}${resource}"

Re: HTTPie: A cURL-like tool for humans

#80
post #62

Earlier quoted context omitted.

No offense taken. I did report this to the API maintainers, who couldn't make heads or tails of it. I didn't file a Python bug because I honestly don't think Python is the problem. But you are right, it is more responsible to pursue this until fixed rather than raise warnings.

Do you have a link to the report? I'd be interested to read the discussion.

No. I will be following up on this, if you send me an email (in my profile) I'll try to let you know when an analysis is available.
Post reply on HN