Skip to main content
How To Combine APIs With Flogo Apps In TIBCO Cloud Integration
  1. Blog/

How To Combine APIs With Flogo Apps In TIBCO Cloud Integration

·4 mins·

In 2002 Jeff Bezos issued a mandate that would change the world forever. At the very least it brought a massive change to how data is reused on the Internet:

  • All teams will henceforth expose their data and functionality through service interfaces.
  • Teams must communicate with each other through these interfaces.
  • There will be no other form of inter-process communication allowed: no direct linking, no direct reads of another team’s data store, no shared-memory model, no back-doors whatsoever. The only communication allowed is via service interface calls over the network.
  • It doesn’t matter what technology they use.
  • All service interfaces, without exception, must be designed from the ground up to be externalizable. That is to say, the team must plan and design to be able to expose the interface to developers in the outside world. No exceptions.
  • Anyone who doesn’t do this will be fired. Thank you; have a nice day!

That mandate kicked off a lot of what we now call the API economy. Many enterprises have APIs that deliver data so you can focus on building value rather than figuring out how to get the data. That said, most APIs out there are documented but don’t have a swagger.json you can import directly. The Web Integrator in TIBCO Cloud Integration lets you paste sample messages from API docs and use those as the basis for invoking REST APIs.

This one is heavy on screenshots. I’ll use the MetaWeather API as the example.

Create your app
#

Step 1: Create an app!

pic
Step 2: Give the app a name, make it something meaningful like WeatherApp ;-)
pic
Step 3: Choose the Web Integrator (powered by Project Flogo) as the type
pic
Step 4: Create a new flow in your new Web Integrator app
pic
Step 5: Give your flow a name and select the Timer to start, after all who doesn’t like a good timer?
pic
Step 6: Click on your new flow to open the editor. For now it will have only a single tile, but when we’re done there will be a few more!
pic

Getting data from MetaWeather
#

Step 7: Check out the MetaWeather API Location search. The URL pattern is /api/location/search/?query

pic
Step 8: Here’s a sample response for London
pic
Step 9: Add an InvokeRESTService tile and paste the URL for the location search, without the query. So the URL will be https://www.metaweather.com/api/location/search
pic
Step 10: On the Input Settings tab, add an entry in the Query Params called query. This tells the tile to expect a new parameter
pic
Step 11: On the Input tab, give your query parameter a value. Expand queryParams, select the parameter, and type a value on the right. I’ll go with London.
pic
Step 12: On the Output Settings, paste the sample response from the MetaWeather API (from step 8)
pic
Step 13: Add a log activity to see data in the logs. On the Input tab we only want the first WOEid, so the value is $InvokeRESTService.responseBody.woeid[0].
pic

Add a second API call
#

A single API call is useful, but let’s use the output of the first call to invoke another API. Step 14: Check out the MetaWeather API for Location. The URL pattern is /api/location/{woeid} (which explains why the WOEid was interesting just now :))

pic
Step 15: Here’s a sample response (longer than the previous one, but it has much more data)
pic
Step 16: Add another InvokeRESTService tile and paste the URL with woeid in curly braces: https://www.metaweather.com/api/location/{woeid}
pic
Step 17: The curly braces are Path parameters. On the Input Settings tab, map the first woeid from the previous step: $InvokeRESTService.responseBody.woeid[0]
pic
Step 18: On the Output Settings, paste the sample response from step 15
pic
Step 19: Add another log step and log the WOEid to confirm it’s still the same city.
pic
Step 20: Push the app and check the logs tab for the result! As a next step, try modifying the second log to show more information.

That’s it
#

You used to need a lot of programming to orchestrate APIs into something useful. With the Web Integrator you can use the sample messages most APIs provide to chain calls together without writing code. As always let me know your thoughts on this tutorial either by commenting below or posting something on the TIBCO Community!

Related

How To Connect Google Forms to APIs

·4 mins
Ever wanted to capture data from a form and send it somewhere useful? Google Forms handles the collection side well, but what about routing that data to an API? That’s where TIBCO Cloud Integration comes in.