Using the Chatter REST API to build a Rails3 jQuery Mobile app

I decided to take the Chatter REST API---available in pilot during Summer '11 pre-release, and developer preview at GA---for a spin and built a Rails3 + jQuery mobile app deployed on Heroku.

Over the past week I have been playing with the Chatter REST API which is in Summer '11 pre-release pilot, and planned for Developer preview when Summer '11 goes GA next month. And I have to say it, it has made working with Chatter data externally to the Platform amazingly more efficient. Sandeep and Dave are going to give you a little preview in Summer 11 preview webinar, but I wanted to share some additional information.  

As many of you know, the REST API is a great light-weight approach for retrieving data from, but the standard REST API wasn't optimized for working with Chatter. In Chatter's case, you wanted to get a feed as well as all the comments, likes, tracked changes etc, but you didn't want to perform multiple REST calls to retrieve it, then work out how to get the older entries and so on. The Chatter REST API now allows me to retrieve the entire feed for an item including comments, likes and so on in one REST call as well as perform updates such as status, comments, and like. In addition, the JSON response for feeds includes a next and previous page URL for navigating newer and older entries. Nice!

Let's look at an example. Here is a call in Ruby using HTTParty to make a REST call for getting a user info, plus a helper method to get my info using the 'me' format you might be familar with if you have used the Facebook Graph API:




  def self.root_url
@root_url = ENV['sfdc_instance_url']+"/services/data/v"+ENV['sfdc_api_version']+"/chatter"
def self.get_users_info(id)
def self.get_my_info

And what about getting a newsfeed. How about this:

 def self.get_newsfeed(id)

Yes, that's right – that was the entire code!

Now that I have a single response in JSON, I can quickly navigate through the payload to use the data however I need. In my example, I let Httparty automagically converts the JSON to a multi-dimensional hash which makes it easy for me to create my UI or working with the response with syntax like this:


I found working with the new Chatter REST API so quick I  thought I would whip up a little app I like to call Rhatter. Rhatter is basically a Rails3 application deployed on Heroku ( which points to a pre-release org. I decided to implement it using jquerymobile because Chatter is better on the go, and I like to play 🙂  The pic above was taken off my phone using the phone number from my Chatter profile to dial right from the app. 

Here is a quick video of what it looks like. And, of course, you can download all the code right here.(remember, during pre-release, the Chatter REST API is in pilot, and will not be enabled in all pre-release orgs)

Leave your comments...

Using the Chatter REST API to build a Rails3 jQuery Mobile app