Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 95e49f81d7
Fetching contributors…

Cannot retrieve contributors at this time

115 lines (76 sloc) 3.475 kb


In Greek mythology, Orthrus (Greek: Όρθρος) was a two-headed dog and son of Typhoeus. He was charged with guarding Geryon's herd of red cattle in Erytheia.


Thanks to the guys who are developing Typhoeus (

Orthrus is a small extension inspired by the original remote method API from Paul Dix which is deprecated in the current Typhoeus release.

It can be used to encapsulate remote method calls in a clean way and provide an easy interface to work with. All of its functionality is covered by tests as well.

orthrus build status


gem install orthrus


In general, Orthrus will accept all options that Typhoeus does. Here are some examples how to use it:

Simple Example: OpenLibrary

require 'rubygems'
require 'typhoeus'
require 'orthrus'

class OpenLibrary
  include Orthrus
  remote_defaults :base_uri => "", :format => "json"

  define_remote_method :book, :path => '/books'

book = => {:bibkeys => "ISBN:0451526538"})
puts book.inspect # Typhoeus::Response

Advanced: Twitter Example with JSON handling and path interpolation

require 'rubygems'
require 'typhoeus'
require 'orthrus'
require 'json'

class Twitter
  include Orthrus
  remote_defaults :on_success => lambda { |response| JSON.parse(response.body) },
                  :on_failure => lambda { |response| puts "error code: #{response.code}"; {} },
                  :base_uri   => "",
                  :version    => 1

  define_remote_method :search, :path   => "/:version/search.json"
  define_remote_method :trends, :path   => "/:version/trends/:time_frame.json"
  define_remote_method :tweet,  :path   => "/:version/statuses/update.json",
                                :method => :post

# Get all tweets mentioning pluto
tweets = => {:q => "pluto"})

# Get all current trends
trends = Twitter.trends(:time_frame => :current)

# Submit a tweet. Authentication skipped in example.
Twitter.tweet(:params => {:status => "I #love #planets! :)"})


To use Typhoeus' hydra to perform multiple request parallel, you can set the return_request option in remote_defaults, define_remote_method or even on per request basis to true. Orthrus will return the crafted Typhoeus::Request, including the success and error handling.

require 'rubygems'
require 'typhoeus'
require 'orthrus'

class WeatherInformation
  include Orthrus
  remote_defaults :base_uri       => "http://wackyweather.test",
                  :return_request => true

  define_remote_method :city, :path => "/city/:name"

hydra =
hydra.queue new_york = => "new_york")
hydra.queue berlin   = => "berlin")

puts berlin.handled_response

For more information about the hydra feature, visit:


  • no cache handling yet.


Johannes Opper


Published under the Ruby License. For detailed information see and

Jump to Line
Something went wrong with that request. Please try again.