« December 2005 | Main | April 2006 »

NewsGator API Best Practices

Nick Bradbury posted on Coming soon: super-fast synching in FeedDemon.  It's true, Nick Bradbury, Nick Harris (the dev for NewsGator Outlook, AKA the "less famous Nick"), Brent Simmons, and I all spent an hour talking about how to use the API.  Nick and Brent had missed some details on how to use the API.  One of the big points developers seem to miss is the whole point of the sync token; devs seem to have a hard time with this concept, so they ignore it.
The sync token was introduced into the API because we had concerns about bandwidth usage, and because SOAP doesn't have anything like Conditional GET, the sync token was the answer for the SOAP interface. With the sync token, as Nick noted, NewsGator Online will tell you what feeds have content that you haven't seen before, based on your sync token.  Maybe an example would help.  Assuming you made a call to Subscription.asmx/GetSubscriptionList, and this <outline> was in the result set:

<outline title="ranchero.com" 
text="ranchero.com" ng:id="43"
xmlUrl="http://ranchero.com/xml/rss.xml"
htmlUrl="http://ranchero.com/" description="News and software for smart people. Mostly Mac." ng:syncXmlUrl="http://services.newsgator.com/ngws/svc/Feed.aspx/43" 
ng:folderId="0"
ng:unseen="True"
ng:unread="True"
ng:private="False"
xmlns:ng="http://newsgator.com/schema/opml" />

The important things here are the ng:unseen and ng:unread attributes.  ng:unseen="True" tells you that based on the Sync token you sent, this feed has news that you haven't seen from this location.  ng:unread="True" tells you that there's at least one unread post in the feed - read states are the same across all locations.  So if you had a location that wanted to see only unread posts, you'd use ng:unread to tell you that you needed to get news.  If you want to get content, regardless of read state, unseen is the deciding factor in whether you need to retrieve a feed.  Unseen and unread are the 2 points you need to make a decision on.  If you have a lightweight client that just wants to look at unread posts, then you use ng:unread.  FeedDemon and products like it use ng:unseen to determine whether to retrieve the feed.  The big win in both these situations is that you don't have to retrieve every feed in your subscription list.  With the normal situation, you have to at least poll the feed; even though a 304 is a lightweight operation on the network, there's still network delays in connection establishment.  So this is where the download savings Nick's talking about come from.
One last word on locations: locations are intended to line up 1:1 with the user application / machine tuple.  In fact, one good method for creating a location is to combine the application name and machine name, for instance NetNewsWire_Gordonslaptop.  The normal situation is that a user uses one aggregator per machine they own, but if there's a chance the user will switch aggregators, having a unique name will keep each instance from stepping on other instances. 
 

Posted by gordonw on February 3, 2006 at 02:48 PM | Permalink | Comments (2) | TrackBack