A few weeks back I asked what ruby HTTP client library folks preferred. I’ve since collected over 700 responses, which seems like a pretty decent sample. You can check out the results for yourself, or look at the full list of responses, but here are some highlights.
And the winner is…
Actually, there are no winners or losers here. However, At 26.2% of responses, HTTParty is the most popular library, slightly edging out Faraday. Factors people cited for their preference include simplicity and ease of use, as well as familiarity.
As a personal favorite of mine, it made me happy to see Faraday at #2, with 24.4% of the vote. Commenting why they chose it, respondents not surprisingly tended to focus on its flexibility. They liked the ability to modify its behavior with middlewares, as well as the ability to swap out backend libraries.
3rd: Built-in Net::HTTP
This one got 13% of the vote, a drop-off of more than 11 points behind Faraday. I’m actually a little surprised to find that Faraday is that much more popular than using Ruby’s built-in HTTP client library.
Not surprisingly, one of the main selling points of Net::HTTP was that it’s always there, without adding a dependency. But respondents also praised its robustness and stability.
Finishing out the list:
- Rest-Client (10.7%) “Easy api, just works, can do file uploads, and have never had a problem with it.”
- Typhoeus (5.8%): “Concurrent requests and multipart posts actually work.”
- HTTPClient (4.9%): “Thread-safe, uses keepalive, fast, no C code (cross-platform; I use a lot of JRuby).” “Supports ENV[‘http_proxy’] and especially ENV[‘no_proxy’] out of the box, supports http streaming.”
- HTTP.rb (3.7%): “Thread safety (I have some Jruby projects), a sane API for SSL (e.g. mutual auth)” “Straightforward API that I don’t have to look up every time I use it.”
- Excon (3.2%) “Excon don’t have extra dependency such as curl, easy to use and customize, easy to handle errors, has feature to debug”
- Curb (3%) “Our benchmarks showed that curb is by far the fastest one.”
- Patron (1%): “Curl-based, but with a nicer API than Curb. Easy to set the timeout, which I often have to do. Easy to log and do REST actions.”
The other others
4% of the votes went to libraries that weren’t listed, including:
(I’ve omitted libs that got just a single mention.)