Wednesday, February 21, 2007

Google Reader API

From http://www.niallkennedy.com/blog/archives/2005/12/google_reader_a.html

Google Reader users are assigned a 20-digit user ID used throughout Google's feed system. User-specifc data is accessible using the google.com cookie named "SID."...Google assigns each user a 20 digit user ID that would not change over time, and a session ID (SID) you can delete, regenerate, and expire.

Google converts all feed data to Atom regardless of its original publication format. All RSS feed post content appears in the summary element and...I found no additional metadata about the feed containing full posts but Google does publish content data where available.

You may request any feed from the Google Reader system using the following URL structure:

  • http://www.google.com/reader/atom/feed/ + [Feed URL]



You may specify the total number of feed entries to retrieve using the n parameter. The default number of feed items returned is 20 (n=20).

Google strips off all the data it does not render in Reader. Stripped data includes namespaced data such as Apple iTunes podcast data and Yahoo! Media RSS, additional author data such as e-mail and home URL, and even copyright data.

Subscription list



/reader/atom/user/[user id]/pref/com.google/subscriptions

Google Reader's feed subscription list contains a user's current feed subscriptions as well as past deleted subscriptions. Each feed is contained in an entry complete with feed URL, published and updated dates, and user-specific tags, if present. Current subscriptions are categorized as a reading list state. You may request the full list of feeds by setting the complete to true.

Reading list



/reader/atom/user[user id]/state/com.google/reading-list

My favorite feature of the Google Reader backend is direct access to a stream of unread entries across all subscribed feeds. Google will output the latest in a "river of news" style data view...You may specify the total number of entries you would like Google to return using the n parameter -- the default is 20 (n=20).

Read items only



http://www.google.com/reader/atom/user/[user ID]/state/com.google/read

You can retrieve a listing of read items from Google Reader. You might want to analyze the last 100 items a user has read to pull out trends or enable complete search and this function may therefore be useful. You may adjust the number of items retrieved using the n parameter -- the default is 20 (n=20).

Reading list by tag



/reader/atom/user/[user id]/label/[tag]

You may also view a list of recently published entries limited to feeds of a certain tag. If you have tagged multiple feeds as "marketing" you might want to request just the latest river of news for those marketing feeds. The returned feed contains both read and unread items. Read items are categorized as read (state/com.google/read) if you would like to hide them from view. The number of returned results may be adjusted using the n parameter.

Starred items only



/reader/atom/user[user id]/state/com.google/starred

Google Reader users can flag an item with a star. These flagged items are exposed as a list of entries with feed URL, tags, and published/updated times included. You may specify the total number of tagged entries to return using the n parameter -- the default value is 20 (n=20). Google treats starred items as a special type of tag and the output therefore matches the tag reading list.

Add or delete subscriptions



/reader/api/0/edit-subscription

You may add any feed to your Google Reader list using the Google Reader API via a HTTP post.

  • /reader/api/0/edit-subscription -- base URL

  • ac=["subscribe" or "unsubscribe"] -- requested action

  • s=feed%2F[feed URL] -- your requested subscription

  • T=[command token] -- expiring token issued by Google. Obtain your token at /reader/api/0/token.



Add tags



/reader/api/0/edit-tag

You may also add tags to any feed or individual item via a HTTP post.

  • /reader/api/0/edit-tag -- base URL

  • s=feed%2F[feed URL] -- the feed URL you would like to tag

  • i=[item id] -- the item ID presented in the feed. Optional and used to tag individual items.

  • a=user%2F[user ID]%2Flabel%2F[tag] -- requested action. add a tag to the feed, item, or both.

  • a=user%2F[user ID]%2Fstate%2Fcom.google%2Fstarred -- flag or star a post.

  • T=[special scramble] -- three pieces of information about the user to associate with the new tag. Security unknown and therefore unpublished.



Conclusion



It is possible to build a your own feed reader on top of Google's data with targeted server calls. You can power an application both online and offline using Google as your backend and focus on building new experiences on top of the data. Advanced functionality is available with a numeric Google ID and some variable tweaks.

Google has built the first application on top of this data API, the Google Reader lens, and judging from their choice of URLs the lens may not be Google's last application built on this data set. I like the openness of the data calls and think the Google Reader APIs are simple enough to bootstrap a few new applications within Google or created by third-party developers.

No comments: