Karotz + Ruby = Love

I made myself a little present this christmas by putting a “Karotz”:http://www.karotz.com/ under my christmas tree. This little digital bunny robot is the 3rd generation of a gadget that was once known as “Nabaztag”:http://en.wikipedia.org/wiki/Nabaztag.

Karotz can connect to the internet and you can deploy applications on it. It’s a tiny multitalent, speaks, blinks, turns his ears, takes photos and plays musik. The really cool stuff about all this, is that you can also access it via a “REST-api”:http://dev.karotz.com/api/.

I was a little disturbed by the bad documentation of the api, but since Karotz has had a pretty shaken history, I was willing to see over it. Nevertheless “I had a really hard time figuring out how to use the API”:https://groups.google.com/forum/?hl=en#!topic/karotzdev/FPTzH_d8FAU, especially the “interactiveMode sessions”:http://dev.karotz.com/api/interactiveid.html, which are crucial for interacting with Karotz. That’s why I wanted to give you a short HOW-TO wrapup on it.

h2. Basic Setup

First of all you need to have a Karotz up and running, like it’s described in the handbook. Register yourself at karotz.com and click on the “lab”:http://www.karotz.com/lab button at the bottom of the page. Once you registered yourself for all the developer stuff, you need to register a new application for yourself in order to get access to the credentials needed to talk to Karotz.

In order to get your own application, you need to create a “descriptor.xml”:http://dev.karotz.com/dev/register_app.html#descriptor-xml and package it as a zip-file and then load it up to the appstore and then deploy it to your bunny. Here is an example, which exposes the install-id of your application, which you need to accesss your Karotz:


Have a look at this “Christops Blog”:http://www.christophs-blog.de/2011/09/karotz-command-line-tool/ if you don’t get it working for yourself.

h2. Using the Gem

There are already some code-examples on the “developer-pages”:http://dev.karotz.com/api/signed.html#Php-sample on how to get an _interactive_id_ for your Karotz and some code has been released for Ruby as ruby-karotz “here”:https://github.com/MadsBuus/ruby-karotz and “here”:https://github.com/XVI-kondoh/Ruby-Karotz none of them exposing a nice API or describing the process of how to get all the peaces of the puzzle together. That’s why I am currently writing this…

So here is an example of how to interact with the “karotz gem”:https://rubygems.org/gems/karotz:

Karotz::Configuration.configure do |config|
  config.install_id = ENV['KAROTZ_INSTALL_ID']
  config.api_key    = ENV['KAROTZ_API_KEY']
  config.secret     = ENV['KAROTZ_SECRET']

Karotz::Client.session do |karotz|

This will rotate Karotz ears, blink the LED, say ‘test’ and let it play the A-TEAM theme!