The Top Ruby HTTP Clients for 2020
Tags: ruby, api, webdev, programming
Published: 2020-02-06 09:02:11

---
title: The Top Ruby HTTP Clients for 2020
published: true
description: Narrow down your choice of Ruby HTTP gems with our list of the best options worth adding to your gemfile in 2020.
tags: ruby, api, webdev, programming
canonical_url: https://www.bearer.sh/blog/top-ruby-http-client-gems
cover_image: https://www.bearer.sh/static/45544740046cdf76fa306d0e787cd28a/e4d72/ruby-gems.png
---

Trouble choosing an HTTP client for your Ruby project? We've got you covered. To help with the decision making, here is a list of the most popular and interesting libraries in the space. 

We've also included examples of making a request in each, and some reasons each library might be of interest to you and your project.

## The built-in net/http client

Before we get right into the third-party implementations, it's worth mentioning that you can make requests using Ruby's built-in `net/http` client from the standard library. Many of the libraries mentioned in this post use the standard HTTP client under the hood.

Perform a `GET` request like this:

```ruby
uri = URI('https://bearer.sh')
response = Net::HTTP.get_response(uri)

puts response.code, response.body
```

Perform a `POST` request like this:

```ruby
uri = URI('https://bearer.sh')
response = Net::HTTP.post_form(uri, 'q' => 'Bearer')

puts response.code, response.body
```

While `net/http` is built-in and convenient, it can be pretty difficult and inconsistent to work with. With many libraries acting as a more usable wrapper around `net/http`, it is hard to recommend starting here unless your team has deep experience with it.

## Faraday

> Faraday is an HTTP client library that provides a common interface over many adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.

A `GET` request looks like this:

```ruby
response = Faraday.get("https://bearer.sh")

puts response.status, response.body
```

A `POST` request looks like this:

```ruby
response = Faraday.post("https://bearer.sh", '{"title": "Bearer Rocks!"}', "Content-Type" => "application/json")

puts response.status, response.body
```

Easily the client with the nicest documentation and site design, [Faraday](https://lostisland.github.io/faraday/) aims to be a wrapper around common clients. The goal being to provide a shared interface. The default is the standard `net/http` client, but Faraday's [adapter system](https://lostisland.github.io/faraday/adapters/) allows it to use a variety of implementations (including some that are on this list). Like many modern Ruby HTTP clients, it also supports the ability to create connections with shared properties through the `Faraday::Connection` interface.

While just shy of a 1.0 release at the time of this writing, over 3600 gems depend on Faraday.

[Read the Faraday docs](https://lostisland.github.io/faraday/).

## http.rb (HTTP The Gem)

> HTTP (The Gem! a.k.a. http.rb) is an easy-to-use client library for making requests from Ruby. It uses a simple method chaining system for building requests, similar to Python's Requests.

A `GET` request looks like this:

```ruby
response = HTTP.get("https://bearer.sh")
puts response.status, response.body

```

A `POST` request looks like this:

```ruby
payload = {
  title: "Bearer Rocks"
}

response = HTTP.post("https://bearer.sh", json: payload)
puts response.status, response.body
```

While not as popular as some of the other clients on this list, one thing that sets [`http.rb`](https://github.com/httprb/http) apart is its use of Ruby FFI bindings to bring Node.js' C-based [`http-parser`](https://github.com/nodejs/http-parser) to Ruby. This allows it to claim higher performance benchmarks than other clients that simply wrap `net/http`. It also includes a predictable interface with a standard array of helper methods that you see across many other libraries.

[Read the http.rb docs](https://github.com/httprb/http).

## rest-client

> A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style of specifying actions: get, put, post, delete.

A `GET` request looks like this:

```ruby
response = RestClient.get('https://bearer.sh')
puts response.code, response.body

```

A `POST` request looks like this:

```ruby
response = RestClient.post('https://bearer.sh', { title: 'Bearer Rocks!'})
puts response.code, response.body
```

Inspired by the Sinatra framework's style, [`rest-client`](https://github.com/rest-client/rest-client) brings a very predictable interface thanks to it's `url, headers` and `(url, payload, headers)` syntax that is shared across all the high-level helper methods (get, post, put, patch, delete). Like other clients, it too offers the ability to create named clients through it's `RestClient::Resource.new` interface. `rest-client` is one of the oldest gem on our list, dating back to 2008, but it still receives updates and is used by over 3500 other gems.

[Read the rest-client docs](https://github.com/rest-client/rest-client).

## httparty

> Makes http fun again! Ain't no party like a httparty, because a httparty don't stop.

A `GET` request looks like this:

```ruby
response = HTTParty.get('https://bearer.sh')
puts response.code, response.body

```

A `POST` request looks like this:

```ruby
options = {
  body: {
    title: "Bearer Rocks!"
  }
}
response = HTTPary.post('https://bearer.sh', options)
puts response.code, response.body

```

[httparty](https://github.com/jnunemaker/httparty), fun name aside, is one of the more popular libraries on our list. It also happens to have the most gems depending on it from our list, at just shy of _4000_. It includes a CLI interface, to make experimenting with endpoints and configurations easy. The documentation can be difficult to navigate for less experienced developers, but the [provided examples](https://github.com/jnunemaker/httparty/tree/master/examples) cover most use cases.

[Read the httparty docs](<(https://github.com/jnunemaker/httparty)>).

## excon

> Excon was designed to be simple, fast and performant. It works great as a general HTTP(s) client and is particularly well suited to usage in API clients.

A `GET` request looks like this:

```ruby
response = Excon.get('https://bearer.sh')
puts response.status, response.body
```

A `POST` request looks like this:

```ruby

response = Excon.post('https://bearer.sh', :body => '{ "title": "Bearer rocks"} ', :headers => { "Content-Type" => "application/json"})
puts response.status, response.body

```

[excon](https://github.com/excon/excon) is another very popular HTTP client, however it isn't depended on by other gems as often as some of the other libraries we've mentioned. It includes the standard list of helper methods and the ability to create named connections through `Excon.new`.

[Read the excon docs](https://github.com/excon/excon).

## Typhoeus

> Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.

A `GET` request looks like this:

```ruby
response = Typhoeus.get("https://bearer.sh")
puts response.code, response.body
```

A `POST` request looks like this:

```ruby
options = {
  body: {
    title: "Bearer Rocks!"
  }
}
response = Typhoeus.post("https://bearer.sh", options)
puts response.code, response.body
```

[Typhoeus](https://github.com/typhoeus/typhoeus) is interesting in that it is built on top of [libcurl](https://curl.haxx.se/libcurl/), and also offers the ability to make parallel requests through it's `Typhoeus::Hydra` interface. In includes the features you've come to expect, like helpers for commonly used actions and some additional niceties like caching and memoization. Another nice option is their custom adapter for Faraday, to mix the best of both. While somewhat popular, Typhoeus hasn't seen an update in over a year.

[Read the Typhoeus docs](https://github.com/typhoeus/typhoeus).

## Curb

> Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the libcurl(3), a fully-featured client-side URL transfer library. cURL and libcurl live at http://curl.haxx.se/ .

A `GET` request looks like this:

```ruby
response = Curl.get("https://bearer.sh")
puts response.status, response.body_str
```

A `POST` request looks like this:

```ruby
payload = {
    title: "Bearer Rocks!"
  }

response = Curl.post("https://bearer.sh", payload)
puts response.status, response.body_str
```

Like Typhoeus, [Curb](https://github.com/taf2/curb) is built on libcurl. This allows it to be very peformant. Curb offers a simple interface (`Curl::Easy`) for dealing with quick requests, as well as a more advanced API (`Curl::Multi`) for managing multiple URLs at the same time. Curb has been around since 2006, and while it may not have the popularity of some of the others on this list, it is a great option if you're looking for a gem with curl under the hood.

## Use the client that's right for

You should feel confident choosing any of the popular libraries noted above. Choose the mix of feature-set and syntax that best matches the needs of your team. We also recommend keeping tabs on the state of the HTTP client gem ecosystem through [Ruby Toolbox](https://www.ruby-toolbox.com/categories/http_clients).

Did we miss your favorite client in this list? Let us know and connect [@BearerSH](https://twitter.com/bearersh). Looking for a solution to actively shield your application from the inconsistencies of third-party APIs? Get started with [Bearer](https://bearer.sh) today without complex code changes or configuration.

_📢 [The top Ruby HTTP clients for 2020](https://www.bearer.sh/blog/top-ruby-http-client-gems) was originally written by on the Bearer blog._

[![Learn more about Bearer.sh (hero image)](https://dev-to-uploads.s3.amazonaws.com/i/5vn0mz3l200z437wubax.jpg)](https://www.bearer.sh/blog?utm_source=dev.to&utm_medium=hero&utm_campaign=top-ruby-clients)