Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faraday vs HTTParty [closed]

Tags:

Faraday is the ruby HTTP client library of choice. Why is it preferable to use it over HTTParty?

Some things that I would like compared are:

  • Performance
  • Architecture
  • Ease of use
  • Features existing in Faraday that isn't in HTTParty (or vice versa)
  • Anything else that makes Faraday the library of choice.
like image 240
austen Avatar asked Oct 11 '12 14:10

austen


2 Answers

They differ in many aspects, but here's the essence IMHO:

HTTParty: - Uses net/http - Some magic (e.g. parse JSON responses)

Faraday: - A wrapper around most of the http libraries out there (excon, typhoeus, net-http-persistent, etc.) - Allows to craft the request and response middleware that suits your specific needs.

I personally prefer Faraday, as it allows me to switch to any http library, and because it allows very fine-grain control over the request and response.

like image 136
Roman Avatar answered Nov 13 '22 09:11

Roman


I was at the point of having to make the same decision yesterday. However, I just need a library that can do simple http requests, nothing fancy... I was however looking for something that is easier to use than Net::HTTP.

For my purposes, both libraries seemed equally well suited, so I decided to go with the one introducing less overhead. Since I also use the twitter gem in this project, I went with faraday since the twitter gem already depends on it and I get it included in my project for "free"...

like image 35
severin Avatar answered Nov 13 '22 09:11

severin