Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Noel Welsh edited this page · 10 revisions

Myna Ruby/EventMachine Client

This is a Ruby client for the v1 Myna API, using EventMachine for asychronous goodness. Tested in Ruby 1.9.2


The package is available via RubyGems and can be installed in the usual way:

gem install myna_eventmachine

See Rails for specific details on running in Rails.


If you're not already using EventMachine, you need to start it

You can get a suggestion from Myna without authorizing:

expt = Myna.experiment('45923780-80ed-47c6-aa46-15e2ae7a0e8c')
suggestion = expt.suggest.get
# suggestion has two attributes: choice and token
# suggestion.choice is a string, the choice made by Myna
# suggestion.token is a string, the token you send back to Myna when you reward
puts("Choice is #{suggestion.choice}")
expt.reward(suggestion.token, 1.0)

To create an experiment, add and delete variants, and so on, you must authorize first:

myna = Myna.authorize('email', 'password')
# Create an experiment
expt = myna.create('My funky new experiment').get
expt.create_variant('My new variant')
expt.create_variant('My other new variant')

When you've finished with Myna you might want to stop EventMachine, though this is entirely optional


For more detail, see:

Getting Help

Find us on #myna on Freenode.

Join the Myna Users group on Google Groups.

Email hello at mynaweb dot com

Something went wrong with that request. Please try again.