CLI tool
jnunemaker/httparty avatar
jnunemaker/httparty

HTTParty: a Ruby HTTP client that wraps requests in a class

:tada: Makes http fun again!

5,899 stars975 forksRubyMIT

At a glance

What is it?
HTTParty is an MIT-licensed Ruby gem that turns HTTP calls into class methods and parsed responses. It suits small scripts and API clients that want defaults out of the box, and it is the wrong pick when you need fine-grained connection control.
Who is it for?
Adopt HTTParty if you are writing Ruby scripts or small API clients and want get and post calls that return parsed bodies without assembling a middleware stack. Do not adopt it if you need per-request connection pooling or a pluggable adapter chain, which is the ground Faraday covers.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What HTTParty replaces in a Ruby codebase

Plain Ruby ships Net::HTTP in the standard library. It works, but every call tends to drag along the same setup: build a URI, open a connection, set headers, read the body, decode it. HTTParty exists to collapse that into a method call. The README opens with the shortest version of the idea, a one-line GET whose result exposes body, code, message and headers, and then shows the same call wrapped inside a class that includes HTTParty and declares a base_uri.

The target user is a Ruby developer writing a script, a rake task, or a thin client for one or two APIs. If your program talks to a single service and you want the response parsed rather than raw, the gem removes a layer of boilerplate. It is less interesting for a large application that needs to swap transports, instrument every request, or share a connection pool across threads.

How the class-method interface and response object fit together

The mechanism is module inclusion. When a class includes HTTParty, it gains class-level request methods and a place to store defaults such as base_uri. Instance methods call back into the class, which is why the README example writes self.class.get("/2.2/questions", @options) rather than calling an instance-level client.

The options hash carries the per-request data. In the README example it holds a query key, so the parameters are merged into the URL rather than into the body. The return value is a response object with body, code, message and headers, and the documentation describes the CLI as printing a pretty-printed Ruby object by default, which suggests the parsed representation is part of the design rather than an add-on.

The repository layout backs this up. There is a lib/ directory for the implementation, a docs/ directory referenced from the README, and an examples/ directory with files such as basic.rb, custom_parsers.rb, headers_and_user_agents.rb, logging.rb, multipart.rb and stream_download.rb. Each of those names points at a behaviour the gem supports, but the README itself only demonstrates the basic GET path. For anything past that, the examples directory is the real documentation.

Installing HTTParty and making a first POST

The README gives one install command and states a requirement of Ruby 2.7.0 or higher. Install it as a gem, or add it to a Gemfile if your project uses Bundler.

bash
gem install httparty

After that, a script can require the gem and issue a GET. The README's first example hits the Stack Exchange API and prints four things: the body, the status code, the message, and the headers.

ruby
require 'httparty'

response = HTTParty.get('https://api.stackexchange.com/2.2/questions?site=stackoverflow')

puts response.body, response.code, response.message, response.headers.inspect

The class form is the one most projects end up using, because it keeps the base URL and the query defaults in one place. Note the shape: base_uri takes a host without a scheme, and the request path starts with a slash.

ruby
class StackExchange
  include HTTParty
  base_uri 'api.stackexchange.com'

  def initialize(service, page)
    @options = { query: { site: service, page: page } }
  end

  def questions
    self.class.get("/2.2/questions", @options)
  end
end

The gem also installs a command-line executable. The README shows it taking a URL and printing the response, with an option to switch the output to formatted XML or JSON, and points at httparty --help for the full flag list.

bash
httparty "https://api.stackexchange.com/2.2/questions?site=stackoverflow"

That CLI is genuinely useful in the first ten minutes with an unfamiliar API, because you can read the structure of a response before writing a parser for it.

Where HTTParty is the wrong tool

The README is thin on failure behaviour. It does not document timeouts, retries, or what happens when a request fails, even though timeout is one of the phrases people search for around this gem. The examples directory contains files such as logging.rb and peer_cert.rb, so logging and TLS peer certificates are covered somewhere in the repository, but the README does not walk through them. If your application needs a documented retry policy, you will be reading source and examples rather than a specification.

The deeper limitation is architectural. A class that includes HTTParty holds its configuration at the class level. That is convenient for one service and awkward when you need different connection settings per request, or when you want to swap the underlying transport for a test double. The gem is also a client, not a framework: there is no middleware chain to hook into, so cross-cutting concerns such as instrumentation have to be added by other means.

Finally, the version floor matters. Ruby 2.7.0 or higher is stated as a requirement. If you maintain a gem that supports older Rubies, adding HTTParty as a dependency raises your own floor.

HTTParty versus Faraday, and versus Net::HTTP

Faraday is the comparison people reach for, and the difference is structural. Faraday is built around a middleware stack: you compose adapters and middleware, and each request passes through them. That design pays off when you need to insert authentication, retries, logging, or a different HTTP backend without touching call sites.

HTTParty takes the opposite approach. Configuration lives on the class that includes the module, requests are class methods, and the response is parsed for you. There is no adapter chain to configure because there is no chain. For a script that calls one API, that is less ceremony. For an application that talks to five services with different auth and retry rules, the class-level model starts to strain, and Faraday's composition is the more natural fit.

Against Net::HTTP, the trade is different. Net::HTTP is in the standard library, so it adds no dependency and no version floor, and it exposes connection-level control directly. HTTParty sits on top of that and trades that control for convenience. If you need to manage sockets, keep-alive behaviour, or connection reuse explicitly, the standard library gives you the handles; HTTParty's README does not describe exposing them.

Release cadence, licence, and upgrade cost

The repository is not archived, and the last push was on 2026-09-21. Recent releases are v0.24.0 on 2025-12-29, then v0.24.1 and v0.24.2 on 2026-01-14, so the 0.24 line saw two patch releases in a single day, which usually signals a fix landing quickly after a release. The project is published under the MIT licence, with the licence file named MIT-LICENSE at the repository root.

For most users the upgrade surface is small. The public interface is the module inclusion plus get and post style class methods, and the README's examples have that shape. The cost shows up if you depend on parser internals or on the CLI output format, since the README presents the pretty-printed Ruby object as a default that can be overridden rather than as a stable contract.

MIT is permissive: it allows commercial use and modification, and it requires that the licence notice be preserved. That is a general description of the licence text, not advice about your situation. If your organisation has rules about attribution in distributed binaries, read MIT-LICENSE and Changelog.md before you pin a version.

Editorial conclusion

Adopt HTTParty if you are writing Ruby scripts or small API clients and want get and post calls that return parsed bodies without assembling a middleware stack. Do not adopt it if you need per-request connection pooling or a pluggable adapter chain, which is the ground Faraday covers. Before you commit, check the Ruby version requirement against your runtime, since the README states Ruby 2.7.0 or higher, and confirm that the response format you need is one the gem parses by default.

Frequently asked questions

How does HTTParty differ from Ruby's Net::HTTP?

Net::HTTP ships with Ruby and exposes connection-level control; HTTParty is a separate gem that adds class-level request methods and returns a response object with body, code, message and headers. The README's shortest example is a single HTTParty.get call that prints all four. Choosing HTTParty means accepting a dependency and a Ruby 2.7.0 floor in exchange for less boilerplate.

How do I install the HTTParty gem?

The README gives one command, gem install httparty, and states that Ruby 2.7.0 or higher is required. Projects using Bundler can add it to a Gemfile instead. There is no separate setup step documented.

Does HTTParty include a command line tool?

Yes. The README states that the gem includes an executable named httparty, which queries a web service and prints the response as a pretty-printed Ruby object by default. The output can be overridden to formatted XML or JSON, and httparty --help lists the options.

How do I send a POST with HTTParty?

The README does not include a POST example; it demonstrates GET through both the class-method form and a class that includes HTTParty. The examples directory in the repository is where the README points for more usage, so check there for a POST request.

Official sources

  1. Issues
  2. jnunemaker/httparty on GitHub
  3. License: MIT
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/jnunemaker-httparty.svg)](https://hysenlabs.com/projects/jnunemaker-httparty)