Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

a google reader api (unofficial) written in ruby

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 GoogleReaderApi.gemspec
Octocat-spinner-32 License
Octocat-spinner-32 README.mdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
README.mdown

GoogleReaderAPI

A Google Reader api. Programmed in ruby. This is an unofficial api. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

Usage

If you would like to implement your own methods, you can quite easily use the api class provided.

api = GoogleReaderApi::Api.new {:email => 'example@gmail.com', :password => 'the pass'}

# OR

api = GoogleReaderApi::Api.new {:auth => 'token'}

# OR If your token was getted from oauth2 (bearer token)

api = GoogleReaderApi::Api.new {:auth => 'token', :auth_type => :bearer}    

and then you can perform requests using the get_link and post_link methods.

# this will give the user info.
api.get_link "api/0/user-info"

# this will add a feed 
api.post_link 'api/0/subscription/edit', :s => "feed/#{url}" , :ac => :subscribe

The following methods all use the Api class, so there is no magic involved.

# password should be asked by the app using the api
# you probably don't want to type that in cleartext here
user = GoogleReaderApi::User.new {:email => 'example@gmail.com', :password => 'the pass'}

# OR

user = GoogleReaderApi::User.new {:auth => 'token'}

you can access your feeds from there

user.feeds

which will return an array of GoogleReader::Feed objects. then you can get the unread items, the read items, ...

hn = user.feeds.find {|feed| feed.title =~ /hacker news/i }
# return 3 unread items (ordered by date)
hn.unread_items(3)
# return all the read items
hn.read_items
# all the starred items
hn.starred_items

you get the idea. you can like items, star items, and mark them as read or unread.

hn.all_unread_items.each {|item| item.toggle_read}

subscribing to new feeds is also easy

user.subscriptions.add "any feed url here"

unsubscribing is best done via remove_if method

user.subscriptions.remove_if {|feed| feed.title =~ /hacker news/i}

Todo

  • provide nicer convenience methods. (user.subscriptions.feeds is not a good way to access your feeds).
  • labels should be part of the api.
Something went wrong with that request. Please try again.