Wednesday, April 18th, 2007

Google announces new AJAX Feed API

Category: Google, JavaScript, Library

<p>The Google AJAX API team has announced a genuinely useful Feed API that gives an Ajax developer the ability to access feeds, cached in the fast Google edge cache where appropriate, from across the web using a simple JavaScript API.

This is a subtle service that does one thing that is currently a pain-point for developers of certain applications. Ajax developers now have a clean way to access public feeds on any domain, and get access to the content in a uniform way.

Gone is the need for us to create a proxy on the server to access feeds from other domains.

Gone is the need to have to deal with all of the feed types. RSS, Atom, RDF, we can now use either MIXED_FORMAT or JSON_FORMAT to use the uniform access. The full set of feed formats supported is Atom 1.0, Atom 0.3, RSS 2.0, RSS 1.0, RSS 0.94, RSS 0.93, RSS 0.92, RSS 0.91, RSS 0.9. The unified feed result elements are: title, link, description, author and a list of entries[]. The entries[] list has the following elements: title, link, content, contentSnippet, publishDate, and categories.

XML and mixed formats allow you to also get access to the XML document itself, and then you can use standard DOM tactics to get what you want from that content (e.g. getElementsByTagName). You would want to use XML if you needed to grab out something specific from the feed, such as the digg:count.

RSSBling Redone

Funny story. Ben and I created Ajaxian.com as a place to host RSS Bling back in 2005, as you can see via the Wayback Machine. It was only later that we started the blog.

RSS Bling was an offline RSS reader that we create as an example of doing offline and Ajax before it was cool. We got a lot of mileage out of doing presentations and unplugging the net and seeing that it still worked.

One of our problems was getting access to feeds. We could have created a proxy to feeds, but instead we used bloglines as the proxy, and got the data from there.

With the new Feed API we can go directly to the feeds itself. We ported RSS Bling to use the API, and you can view it here.

Once you load the Feed API, you can grab a feed using google.feeds.Feed, passing in the feed URL, setting any values on it (e.g. the mode to use, how many entries you want in the result size, etc.), and then calling load(callback). The callback allows the API to grab the feed asynchronously, and holds the result itself.

Here is an example from RSS Bling that loads a feed and shows the entries in the main window:

javascript
< view plain text >
  1. new google.feeds.Feed(feeds[feedId].feedUrl).load(function(result) {
  2.   if (!result.error) {
  3.     var html = "";                
  4.     var feed = result.feed;
  5.  
  6.     html += '<div class="titlebar">';
  7.     html += '<div class="title"><a href="' + feed.link + '">' + feed.title + '</a></div>';
  8.     html += '<div class="description">' + feed.description + '</div>';
  9.     html += '</div><div class="entries">';
  10.  
  11.     for (i = 0; i < result.feed.entries.length; i++) {
  12.       var entry = result.feed.entries[i];
  13.  
  14.       html += '<div class="entryTitle"><a href="' + entry.link + '">' + entry.title + '</a></div>';
  15.       html += '<div class="entryText">' + entry.content + '</div>';
  16.     }
  17.  
  18.     html += "";
  19.     document.getElementById("feedContent").innerHTML = html;
  20.   } else {
  21.     showError();
  22.   }
  23. });

I am really looking forward to seeing how the API is used.

For more infomation you can visit the Ajax Feed API home or check out the FAQ.

RSS Bling Feed API version

name lookup timed out

Posted by Dion Almaer at 9:00 am
13 Comments

+++--
3.8 rating from 46 votes

13 Comments »

Comments feed TrackBack URI

aha… I was waiting for that to happen… http://braincast.nl/pivot/entry.php?id=23

Comment by Marc — April 18, 2007

So how do they get around the JavaScript security constraints?

Comment by henry turner — April 18, 2007

here’s the link: http://code.google.com/apis/ajaxfeeds/

Comment by Marc — April 18, 2007

Henry,

They don’t get around the security constraints as they get the feeds through a proxy at Google (which happens to be on a nice fast edge cache).

You can read more at the FAQ: http://code.google.com/support/bin/topic.py?topic=11330.

Cheers,

Dion

Comment by Dion Almaer — April 18, 2007

Using a proxy is certainly not a new idea. It is nice of them to provide a proxy though.

Comment by Kris Zyp — April 18, 2007

This is really cool! I’ve noticed some people using Pipes to do the same thing, but this is much cleaner and should be much faster.
-edward

Comment by Edward Ho — April 18, 2007

Looks their recent hiring of Mark Pilgrim might have been to support his universal feed parser that probably underlies this offering.

Comment by Bud Gibson — April 18, 2007

I think it is great services are coming out but as I wrote here:
http://www.techthoughts.com/techthoughts/2007/04/google_ajax_fee.html
why not charge a fee like S3 and allow people to make services that actually make money. Note the following from the terms of use:

5.6 You agree that if you use the Feed API to develop a service for
other users, it must be made accessible to your end users without
charge.
I would love something like this – much like how S3 provides cheap grid function for small companies – without having the constraints.

Comment by Ben B — April 18, 2007

Guys, they’re not using AJAX, so there is no domain constraint. The only reason you need a proxy is to convert the RSS/whatever into Javascript.

Moreover Technologies (bought by Verisign a while back) has been doing this exact thing for years, except in any output format you like and with a contextual advert added at the top.

Comment by Richard Marr — April 19, 2007

This has actually been available for a while. It just wasn’t really obvious.

We have a lot of people using Spinn3r for similar purposes and solve the same goal. Basically a way to get access to feed data without all the difficult and painful issues of crawling or parsing.

The problem with the Google Feed API though is that you have to know the feed before hand. We mostly deal with BULK access right now. 250k feeds, 1M feeds. etc.

What’s really cool is that we have about a 1/2 dozen PhDs using it right now which is kind of fun.

Comment by Kevin Burton — April 19, 2007

Does this technology just use document.write and some dynamic script insertions or something? It can’t be Ajax if the proxy is on google’s domain and my page is on my domain.

Comment by henry turner — April 20, 2007

no comparion between Feed API and Pipes.

Comment by Adnan Siddiqi — April 20, 2007

Hi Everybody, I’ve just finished my new job search engine based on Google AJAX Feed API.
JobGeni – The Realtime Job Aggregator http://www.jobgeni.com pulls the data from several major job sites like indeed, simplyhired, yahoo hotjobs, monster and jobster.

Comment by vidaldewit — April 15, 2008

Leave a comment

You must be logged in to post a comment.