Saturday, July 23, 2011

OData Feed Fun Or There's no Atom/RSS Feed, but there is OData, so there IS an Atom feed (that you can customize to your liking too)

One of the [many] things I whine about is when a site or gallery doesn't have an RSS/Atom/web feed. My days are to short and if there's no web feed then it's not likely I'm going to be able to keep up with what you're providing.

But what if there's a cool gallery that I really want to keep up to date on? Like the NuGet Package Gallery? Before yesterday I thought I was SOL.

Then this post from John Sheehan, Building @NuGetLatest in Two Hours, got me thinking.

OData...hum... The NuGet Gallery has an OData feed ( OData provides its content as Atom XML right?  So doesn't that mean I could just point my Feed reading or choice at the NuGet OData Feed?

Yep, pretty much!

But of course it's not really that simple (it never is is it?).  The issue is that that the NuGet Packages OData feed provides a pretty raw/direct view of the packages (think Select * from Packages).

Here's what I'm looking for in feed form;


First issue was that every version of every package is listed and the "active/current" version has its IsLatestVersion bit set to true. So any feed we get should only return those that IsLatestVersion is True. Good thing we're talking OData here! Filtering the data is a piece of cake ($filter=IsLatestVersion eq true).

Next issue was order. A feed should order by the last updated, in descending order. I.e. getting you the latest/recent items. Again OData "just does that" ($orderby=LastUpdated desc).

That's about it. A little OData query param tweaks and I've got my feed.

Here's the complete URL:$filter=IsLatestVersion eq true&$orderby=LastUpdated desc

The result in IE;


Finally in my reader of choice;


So far this appear seems to be working like a charm, with one problem, the links don't work. It's expected that clicking on the feed title will let you view that item. Not so using this approach. With additional work and a man in the middle (like Yahoo Pipes, etc) this could be fixed, but for my use this is good enough. It lets me monitor the NuGet Package Gallery and frees up a Whine Point which I can now use somewhere else... :)

No comments: