So, the guys over at AideRSS released a REST service for their PostRank API. The new API, at PostRank.com, provides access to some interesting data.

It’s fun to see how you rank up against other sites (although, I rank pretty low, heh).

Anyway, back on track, I’ve created a Ruby wrapper around the API that people will hopefully find useful. I’ve currently tagged it as a 0.5 beta release until I can get some feedback on if the API is right for other people as well. (Plus, I know I want to change the Exception handling at some point so there will be changes before a 1.0.)

You can grab the postrank-0.5.gem or install it through the GitHub gem server by entering:

gem sources -a http://gems.github.com
sudo gem install dj2-postrank

Or, if you want to can grab the code from GitHub and build it yourself.

If you find any problems, have any suggestions or patches, you can file them on the LightHouse project page.

For a quick example of the API, I present the following:

!/usr/bin/env ruby

require 'rubygems'
require 'postrank'

include PostRank

server = Server.new("com.everburning")
eb = server.feed("http://everburning.com")

puts "The GREAT everburning feeds"
eb.entries(:level => Level::GREAT).each do |entry|
  puts entry
end

puts "\nThe top 5 posts in the last week on everburing"
eb.top_posts(:period => Period::WEEK).each do |entry|
  puts "#{entry.title} -- #{entry.post_rank} -- #{entry.post_rank_color}"
end

puts "\nGet thematic PostRanked items"
server.post_rank(["http://flickr.com/photos/14009462@N00/2654539960/",
                  "http://www.flickr.com/photos/21418584@N07/2447928272/",
                  "http://www.flickr.com/photos/pilou/2655293624/"]).each do |entry|
  puts entry
end

puts "\nGet PostRanked items"
server.post_rank(['http://everburning.com/news/on-recent-media/',
                  'http://everburning.com/news/californication/',
                  'http://everburning.com/news/the-weary-traveler/'],
            :feeds => [eb]).each do |entry|
  puts entry
end

Running it you’ll see something similar too:

Rei:ruby-postrank dj2$ ruby examples/simple_example.rb
The GREAT everburning feeds
http://everburning.com/news/the-weary-traveler/ -- Post rank: 10.0
http://everburning.com/news/book-review-the-mirrored-heavens/ -- Post rank: 8.0
http://everburning.com/news/the-incredible-hulk/ -- Post rank: 10.0
http://everburning.com/news/kung-fu-panda/ -- Post rank: 10.0
http://everburning.com/news/im-on-the-intertubes/ -- Post rank: 10.0
http://everburning.com/news/and-in-recent-travels/ -- Post rank: 8.0
http://everburning.com/news/the-chronicles-of-narnia-prince-caspian/ -- Post rank: 8.0
http://everburning.com/news/going-fullscreen-with-medium/ -- Post rank: 8.0

The top 5 posts in the last week on everburing
On recent media -- 1.0 -- #ffe08e

Get thematic PostRanked items
http://flickr.com/photos/14009462@N00/2654539960/ -- Post rank: 1.0
http://www.flickr.com/photos/21418584@N07/2447928272/ -- Post rank: 1.0
http://www.flickr.com/photos/pilou/2655293624/ -- Post rank: 5.0

Get PostRanked items
http://everburning.com/news/on-recent-media/ -- Post rank: 1.0
http://everburning.com/news/californication/ -- Post rank: 1.0
http://everburning.com/news/the-weary-traveler/ -- Post rank: 5.0
Rei:ruby-postrank dj2$

There you go. Grab the gem, whip up some Ruby, and let’s see how you can use your PostRank information.