explaingit

lostisland/faraday

5,931RubyAudience · developerComplexity · 2/5Setup · easy

TLDR

Faraday is a Ruby library that gives you one consistent way to make HTTP requests no matter which underlying HTTP client you use, with a middleware pipeline for logging, retrying, and automatic JSON parsing.

Mindmap

mindmap
  root((faraday))
    What It Does
      Single HTTP interface
      Swap adapters freely
      Middleware pipeline
    Tech Stack
      Ruby 3.0+
      Net HTTP adapters
      Typhoeus Patron
    Use Cases
      Build API clients
      Add request logging
      Auto retry on failure
    Audience
      Ruby developers
      API wrapper authors
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add logging and automatic JSON parsing to all HTTP requests in your Ruby app without changing your core request code.

USE CASE 2

Build a reusable Ruby API client library that lets users swap the underlying HTTP adapter without rewriting anything.

USE CASE 3

Insert retry logic for failed requests by stacking Faraday middleware in the order you choose.

Tech stack

Ruby

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Faraday is a Ruby library for making HTTP requests. HTTP requests are how programs talk to web APIs and external services, and Faraday provides a single consistent interface for doing that regardless of which underlying HTTP tool you actually use. Instead of locking you into one specific HTTP client, Faraday sits on top of many different adapters, such as Net::HTTP (built into Ruby's standard library), Typhoeus, Patron, Excon, HTTPClient, and others, letting you swap between them without rewriting your code. The library borrows an idea from Rack, a standard component used in Ruby web applications. In Rack, requests pass through a chain of middleware pieces, each of which can inspect or modify the request or response before passing it along. Faraday applies the same pattern to outgoing HTTP calls. You can insert middleware for things like logging, retrying failed requests, authentication, or automatic JSON parsing, stacking them in the order you choose. Features built into Faraday include persistent connections (also called keep-alive, which avoids the overhead of opening a new connection for every request), parallel requests, automatic parsing of JSON and XML responses, file uploads, and streaming responses for large payloads. The library is aimed at developers building API clients or wrappers around web services in Ruby. Instead of coupling your library to a single HTTP tool, you write against Faraday's interface and let users choose the adapter that fits their environment. The project supports Ruby 3.0 and above. The README is brief and points to the project website and API documentation for more detail.

Copy-paste prompts

Prompt 1
Using Faraday in Ruby, show me how to set up a connection to a REST API with automatic JSON parsing and retry on failure.
Prompt 2
Write a Faraday middleware in Ruby that logs every outgoing HTTP request URL and the response status code.
Prompt 3
Show me how to switch the Faraday adapter from Net::HTTP to Typhoeus without changing any of my API request code.
Prompt 4
How do I use Faraday to make parallel HTTP requests to multiple endpoints at the same time in Ruby?
Open on GitHub → Explain another repo

← lostisland on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.