How to Temboo with Processing


Temboo makes it simpler and easier to build sketches 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 Processing sketch 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.

Gather your supplies

1If you don't already have it, download the latest version of Processing.

2Download the Temboo Library for Processing. Unzip the file and put the temboo folder into your Documents/Processing/libraries/ folder (or My Documents/Processing/libraries/ on a PC). If Processing is currently open, restart it so that it will recognize the Temboo library that you just added.

Generate your code online

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

4 Go to our Library and find the Google > Geocoding > GeocodeByAddress Choreo. Select Processing from the drop down menu at the top of the page.

5 Enter any address or ZIP code in the Address input field.

6 Now 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 of the page (which is right below the Input section).

Create Your Processing Sketch

When you run a Choreo from the website, Temboo automatically generates code that can be used to make the same API call from a Processing sketch.

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

8 Copy the code, and paste it into a new sketch in the Processing editor.

Using your Temboo account details

9 In order to run this sketch, your Temboo account name and application details must be included here:

When you're logged in, this information is automatically populated in your sketch.

Remember to remove your account details if you share your sketch. Also, you can always change your application details here.

Run the Sketch

10 Run the sketch from Processing, and you will see the results in the Processing console. Congrats! You just ran your first Choreo in Processing.

Want to set up some global variables?

Usually you'll want to use a Choreo's inputs and outputs other places in your Sketch. You can do this easily by assigning global variables to the inputs and outputs – they're called out in the sample code below:

The following Sketch already includes some global variables up top that are utilized in the rest of the code. Use this approach to start connecting Choreos to whatever you might dream up.

import com.temboo.core.*;
import com.temboo.Library.Google.Geocoding.*;

// Create a session using your Temboo account application details
TembooSession session = new TembooSession("ACCOUNT_NAME", "APP_NAME", "APP_KEY");

// Set up some global variables
String location = "New York, NY";
float latitude, longitude;

void setup() {
  // Run the GeocodeByAddress Choreo function
  runGeocodeByAddressChoreo();
}

void runGeocodeByAddressChoreo() {
  // Create the Choreo object using your Temboo session
  GeocodeByAddress geocodeByAddressChoreo = new GeocodeByAddress(session);

  // Set inputs
  geocodeByAddressChoreo.setAddress(location);

  // Run the Choreo and store the results
  GeocodeByAddressResultSet geocodeByAddressResults = geocodeByAddressChoreo.run();

  // Save latitude and longitude as floats
  latitude = float(geocodeByAddressResults.getLatitude());
  longitude = float(geocodeByAddressResults.getLongitude());

  // Print latitude and longitude
  println("location: " + location);
  println("latitude: " + latitude);
  println("longitude: " + longitude);
}

What next?

Congratulations! Now you're ready to run any of our 2000+ Choreos in Processing. You're just a few steps away from making something extraordinary. Check out some more examples here.

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 support@temboo.com, and we'll answer your questions.


Back