Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Faraday Middleware

Gem Version GitHub Actions CI

A collection of useful Faraday middleware. See the documentation.

gem install faraday_middleware


As highlighted in Faraday's UPGRADING guide, faraday_middleware is DEPRECATED, and will not be updated to support Faraday 2.0. If you rely on faraday_middleware in your project and would like to support Faraday 2.0:

  • The json middleware (request and response) are now both bundled with Faraday 🙌
  • The instrumentation middleware is bundled with Faraday
  • All other middlewares, they'll be re-released as independent gems compatible with both Faraday v1 and v2, look for awesome-faraday

Most of the middlewares are up for adoption, contributors that would like to maintain them. If you'd like to maintain any middleware, have any question or need any help, we're here! Please reach out opening an issue or a discussion.


Ruby >= 2.3.0

As of v0.16.0, faraday and faraday_middleware no longer officially support JRuby or Rubinius.

Some dependent libraries are needed only when using specific middleware:

Middleware Library Notes
FaradayMiddleware::Instrumentation activesupport
FaradayMiddleware::OAuth simple_oauth
FaradayMiddleware::ParseXml multi_xml
FaradayMiddleware::ParseYaml safe_yaml Not backwards compatible with versions of this middleware prior to faraday_middleware v0.12. See code comments for alternatives.
FaradayMiddleware::Mashify hashie
FaradayMiddleware::Rashify rash_alt Make sure to uninstall original rash gem to avoid conflict.


require 'faraday_middleware'

connection = '' do |conn|
  conn.request :oauth2, 'TOKEN'
  conn.request :json

  conn.response :xml,  content_type: /\bxml$/
  conn.response :json, content_type: /\bjson$/

  conn.use :instrumentation
  conn.adapter Faraday.default_adapter