Using RSS as an API Sep25 '07

In my last post, I discussed how to parse an RSS feed with PHP, and display the contents directly on your site.

The advantages of using a server-side programming language to parse an RSS feed are:

  1. The content is obtained as the page is being served, meaning there is no additional delay for end-viewers.
  2. You can format the content to fit into your existing HTML markup.

The disadvantages of Flash and JavaScript "widgets" are:

  1. Sloppy-looking, blocky, hard to customize, and often break site layouts.
  2. Pull content after the page has loaded, meaning there is an additional "wait time" as the client browser reaches out to the remote URL's.
  3. Invisible to search engines, meaning they offer no additional page-rank value to your site.

RSS as an API

In a sense, an RSS feed is an API. On systems where you don't have direct access to the server or database, using the public RSS feed is the only way to obtain the content for use elsewhere.

The main drawback to using an RSS feed as an API is you are limited to whatever is in the RSS feed, meaning if the feed only displays 10 posts, you can only obtain 10 posts. Most RSS feeds have a limit of how many items are displayed. This site has over 1,000 blog posts. However, my RSS feed only displays the 10 most recent.

It would serve me no purpose to offer a feed that contains every post. I can imagine it would only cause the file to be extremely large, slowing down feed readers' response time when trying to access my feed for subscribers.

However, offering a "flag" on the feed itself could be useful. In other words, here's the RSS feed for this site:

http://matthom.com/feed/matthom.xml

This pulls the 10 most recent posts. What if a user wanted to write an application using my data, but needed access to every post? I could provide a "flag" or "parameter" for them to supply:

http://matthom.com/feed/matthom.xml?count=all

The variable count could be set to any number, or "all" for all posts.

It might be wise to consider authenticating the "all" feed, and providing access to individuals as you see fit.

Categories: API , RSS

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Similar Entries

Stats

5 unique visits since August 2008

Syndicate

Advertisements