How to Temboo with Node.js

Temboo makes it easy to build Node.js 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 the Temboo Node.js SDK to write a simple Node.js script that uses Google's Geocoding API to retrieve the latitude and longitude for a specific address e.g., 104 Franklin St, New York City. 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 Node.js v0.8.0 (or later) on your system.

Get Set up

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

2Download the Temboo Node.js SDK and extract it to the directory where you'd like to build this Node.js sample project. The SDK is in a directory called node_modules in accordance with the convention established by the Node Package Manager.

3 Create a new .js file in the same location as the unzipped node_modules folder. In this example, we'll call the file hellotemboo.js (though you can call it whatever you like).

Test on our website

4 Go to the Google > Geocoding > GeocodeByAddress Choreo in our Library.

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

6 Now click Run. After a moment you'll see the data that Google sends back shown in the Output section.

Auto-Generate The Code

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 Node.js. Here we'll show you how to use these snippets in your code.

7 Scroll down to the Code section of the Library page, click on the Language drop-down menu, and select Node.js.

8 Copy the code snippet and paste it into your hellotemboo.js file. At this point, your code should look something like this:

// You'll need a single TembooSession object in your code, eg:
// var tsession = require("temboo/core/temboosession");
var session = new tsession.TembooSession("ACCOUNT_NAME", "APP_NAME", "APP_KEY");

var Google = require("temboo/Library/Google/Geocoding");

var geocodeByAddressChoreo = new Google.GeocodeByAddress(session);

// Instantiate and populate the input set for the choreo
var geocodeByAddressInputs = geocodeByAddressChoreo.newInputSet();

// Set inputs
geocodeByAddressInputs.set_Address("104 Franklin St., New York NY 10013");

// Run the choreo, specifying success and error callback handlers
    function(results) {
    function(error) {

9Make sure that all of your import statements are included. Both of the following lines should be present and uncommented in your code.

var tsession = require("temboo/core/temboosession");
var Google = require("temboo/Library/Google/Geocoding");

Print 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 accessor methods tailored specifically to the outputs of that Choreo. Using the ResultSet, you can retrieve the raw data XML or JSON returned by a third-party API and, in most cases, relevant fields that we've parsed out of the response for you. Remember, sample code for every Choreo can be found in the Library.

The example code already logs the longitude, you simply have to ask it to log the latitude as well:

10Edit the success callback (function(results){...}) so that it looks like this:

function(results) {
    console.log("Latitude: %s", results.get_Latitude());
    console.log("Longitude: %s", results.get_Longitude());

Your finished version of the execute() method should look like this:

// Run the choreo, specifying success and error callback handlers
    function(results) {
    	console.log("Latitude: %s", results.get_Latitude());
    	console.log("Longitude: %s", results.get_Longitude());
    function(error){console.log(error.type); console.log(error.message);}

Try It Out

11Now you're ready to run the script and see the output. Here's the command you need to run if you're executing this from the command line. Otherwise just run it from your IDE.

node hellotemboo.js

Congrats! You just ran your first Choreo from our Node.js SDK! You should see the coordinates for the address you specified printed to the console.

What next?

Now you're ready to run any of our 2000+ Choreos in Node.js. 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.

Get Live Updates About Your Application

Integrate Temboo with Slack to get up-to-the-second notifications and alerts about your deployed Temboo code.

Commit Code to GitHub

Commit Temboo-generated code directly to GitHub and share with the world. Learn more.

Need help?

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