How to Temboo with Ruby

Temboo makes it simpler and easier to build Ruby applications that connect to over 100 web-based resources and services (e.g. Facebook, Dropbox, US Census data) by standardizing how you interact with their Application Programming Interfaces (APIs). Don't worry if you're not familiar with APIs – with Temboo you don't have to worry about the details.

Here we'll show you how to use Temboo by creating a simple Ruby example that retrieves the latitude and longitude for a specific address from the Google Geocoding API. What makes Temboo uniquely powerful and useful is that, once you know how to use one API, you know how to work with any API in our Library.

Before we get started, make sure that you've got Ruby 1.9 (or later) and a Ruby code editor.

Get Set Up

1 Create a new Ruby project somewhere in your filesystem.

2Download the Temboo Ruby SDK.

3 In a terminal window, navigate to the location of your downloaded SDK. Type gem install temboo-ruby-sdk-x.gem, where x is the version number. You will now be able to access Temboo's Ruby SDK in your code.

4 Add a new Ruby script to your project. You can call it whatever you like.

Auto-Generate your code

5 Log in to Temboo. If you don't already have an account, you can register for free here.

6 Go and find the Google > Geocoding > GeocodeByAddress Choreo in our Library. Select Ruby from the drop down menu at the top of the page.

7 Enter any address or ZIP code in the Address input field e.g., 104 Franklin Street, New York City.

8 Click Generate Code to test the Choreo from our website. After a moment you'll see the data that Google sends back shown in the Output section.

Create Your Ruby program

When you run any Choreo from our website, we automatically generate code that can be used to make the same API call many languages, including Ruby. Here we'll show you how to use these snippets in your code.

9 Scroll down to find the Code section of the Choreo page.

10 Copy the code snippet and paste it into your Ruby script.

At this point, your code should look something like this:

# Instantiate the Choreo, using a previously instantiated TembooSession object, eg:
geocodeByAddressChoreo =

# Get an InputSet object for the choreo
geocodeByAddressInputs = geocodeByAddressChoreo.new_input_set()

# Set inputs
geocodeByAddressInputs.set_Address("104 Franklin St New York, NY")

# Execute Choreo
geocodeByAddressResults = geocodeByAddressChoreo.execute(geocodeByAddressInputs)

11 Make sure your imports are in place at the top of the file. They should look like the sample below.

require "temboo"
require "Library/Google"

Print your results

Before we try a test run of the app, let's update the code to print the results returned from Google's Geocoding service.

Each Choreo in the SDK returns a ResultSet subclass that contains get methods tailored specifically to the outputs of that Choreo. Using the ResultSet, you can retrieve the raw data (typically XML or JSON) returned by a third-party API or relevant fields that we've parsed out of the response for you.

To print the latitude and longitude returned by the Choreo, simple do the following:

12 Add the following code at the bottom of your script:

    # Print lat/lon
    printf("Latitude: %s\n", geocodeByAddressResults.get_Latitude())
    printf("Longitude: %s\n", geocodeByAddressResults.get_Longitude())

13 Run the code and you will see the results in the console. Congrats! You just ran your first Choreo from our Ruby SDK.

What next?

Now you're ready to run any of our 2000+ Choreos in Ruby. You're just a few steps away from making something extraordinary.

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Need help?

We're always happy to help. Just email us at, and we'll answer your questions.