the official tarpipe blog

June 3, 2009

Extending tarpipe with the REST connector

[warning: technical information ahead]

We've created a connector that lets you easily extend any workflow by connecting to an external REST endpoint. The REST connector is compatible with the Yahoo! Pipes Web Service Module — the only difference is that we only process with a single entry instead of a feed of entries.

The connector POSTs a JSON encoded list of properties to a service URL and expects a JSON or RSS formatted response. Here's an example JSON response:

  1. {
  2. "items"[
  3. {
  4. "title" : "My title",
  5. "link" : "http://example.com",
  6. "description" : "My Description"
  7. }
  8. ]
  9. }

The compatibility means that you can use any existing Web Service that already worked with Yahoo! Pipes. OpenCalais offers a service with those characteristics and we decided to give it a try with our new REST connector.

This example workflow uses the REST connector to talk directly to the Calais Yahoo! Pipes Web Service. The OpenCalais URL (including the API key) is specified using the TextInput connector.

Creating your own external Web service is also very easy. All you have to do is wait for a POST, process the incoming JSON information and output a JSON formatted response. Here's an example written in PHP:

  1. <?php
  2. //
  3. // Obtain the input from the POST "data" field
  4. //
  5. $input = json_decode($_POST['data']);
  6.  
  7. if ($input) {
  8. //
  9. // As an example, the output is copied from the input
  10. //
  11. $output = array();
  12. $output['title'] = $input->items[0]->title;
  13. $output['link'] = $input->items[0]->link;
  14. $output['description'] = $input->items[0]->description;
  15.  
  16. //
  17. // Output JSON encoded response
  18. //
  19. echo json_encode(array('items' => array($output)));
  20. }
  21. ?>

We hope this new REST connector will create new possibilities and expand what you can already do with your workflow. Please let us know how you'll use it with your Web services.

Filed under: code, news, release, workflow — Bruno Pedro @ 9:48 pm UTC

4 Comments

  1. One word: Yay!! :)

    Comment by Ray Scott — June 4, 2009 @ 7:58 am UTC

  2. Is there a way to use RSS output from Yahoo! Pipes are the source data for Tarpipe? For example, can I create a RSS feed in Pipes and have Tarpipe automatically post each new feed item to Delicious each time a new item appears in the feed?

    Comment by Joe Lazarus — June 4, 2009 @ 7:57 pm UTC

  3. Thanks for the feedback Joe,

    Executing a workflow based on new items coming from a feed is something that we don’t offer at this moment.

    Comment by Bruno Pedro — June 5, 2009 @ 1:17 pm UTC

  4. Your picture seems to show the MailDecoder plugging both its From and Body fields into the Description of the REST connector – yet this doesn’t seem to work if I try it in a workflow. What’s the story there?

    Thanks,

    J.

    Comment by Jonathan Lister — July 24, 2009 @ 5:01 pm UTC

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress