Find file
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (108 sloc) 3.98 KB


Snafu is a Ruby gem that provides an interface to the API for Glitch, a browser-based MMO created by Tiny Speck.

API Support

Currently Supported

  • In-Game Time & Date (See the GlitchTime class for more info)
  • Giants
    • giants.list (Snafu::Giants#get_giants)
  • Locations
    • locations.getHubs (Snafu::Locations#get_hubs)
    • locations.getStreets (Snafu::Locations#get_hub)
    • locations.streetInfo (Snafu::Locations#get_street)

Not Yet Supported

  • Achievements
  • Auctions
  • Avatar
  • Players
  • Skills


To get started, instantiate the client with either no options or with the OAuth token of an authenticated user if ‘identity’ scope or higher is required.

    snafu = => "your-oauth-token")

Snafu currently does not support Glitch’s OAuth authentication. There are other gems that support authenticating with Glitch such as OmniAuth.

In-Game Time & Date

Note that the hour, minute, day of week, day of year, and day of month are all zero-based.

To get the current in-game date and time:

    current_time = snafu.glitch_time
    => 20
    => "Spork"
    => "Hairday"


You can get a list of all giants:

    # giants.list
    giants = snafu.get_giants
    => "Alph"

Or, if you supply read-level OAuth token, you can see the user’s favor with all giants:

    # giants.getFavor
    giants = snafu.get_giants_favor
    => "Alph"
    => 323


All locations.* methods are supported. Each method returns a Ruby object representing the returned data.

    # locations.*
    hubs = snafu.get_hubs # "locations.getHubs"
    hub = snafu.get_hub(hub_id) # "locations.getStreets"
    street = snafu.get_street(street_tsid) # "locations.streetInfo"


    achievements = snafu.get_achievements # "achievements.listAll"
    => "1-Star Cuisinartist"
    => "Whipped up 11 meals with an Awesome Pot"

Manual Method Calls

You can also receive raw data from the Glitch API by passing any method name into #call and supplying any required parameters via an options hash. This returns a Hash representation of the JSON returned by Glitch.

For example, to manually call the Glitch calendar.getholidays method:"calendar.getHolidays")
    => {
    =>   "ok"=>1,
    =>   "days"=>
    =>   [{"month"=>1, "day"=>5, "name"=>"AlphCon"},
    =>    {"month"=>2, "day"=>2, "name"=>"Lemadan"},
    =>    {"month"=>3, "day"=>3, "name"=>"Pot Twoday"},
    =>    {"month"=>4, "day"=>2, "name"=>"Root"},
    =>    {"month"=>4, "day"=>3, "name"=>"Root"},
    =>    {"month"=>4, "day"=>4, "name"=>"Root"},
    =>    {"month"=>4, "day"=>11, "name"=>"Sprinkling"},
    =>    {"month"=>6, "day"=>17, "name"=>"Croppaday"},
    =>    {"month"=>7, "day"=>1, "name"=>"Belabor Day"},
    =>    {"month"=>8, "day"=>37, "name"=>"Zilloween"},
    =>    {"month"=>11, "day"=>11, "name"=>"Recurse Eve"}]
    => }"locations.getStreets", :hub_id => 27)
    => {
    =>   "ok"=>1,
    =>   "hub_id"=>"27",
    =>   "name"=>"Ix",
    =>   "streets"=>
    =>   {
    =>     "LM416LNIKVLM1"=>{"name"=>"Baby Steppes"},
    =>     "LM413SQ6LRN58"=>{"name"=>"East Spice"},
    =>     "LM410QQ0CHARO"=>{"name"=>"Flipside"},
    =>     "LM4115NJ46G8M"=>{"name"=>"Groddle Ladder"},
    =>     "LM4109NI2R640"=>{"name"=>"Guillermo Gamera Way"},
    =>     "LM410TMR0S2S1"=>{"name"=>"Ruta Asuncion"},
    =>     "LM413RQ6LRG9N"=>{"name"=>"West Spice"}
    =>   }
    => }


Jeff Browning – Original author
Lee Jensen – Contributions to GlitchTime