3

Is there any Google Reader API that I can plug in to? I building a clean RSS/Atom reader in PHP and would love to get all the goodies from Google Reader like the history of a feed, able to add comments to each feed item, etc.

3 Answers 3

9

I've built some google reader integration in python but I can share some of the api knowledge so you can get started. output=json is also available for all.

Login: https www.google.com/accounts/ClientLogin

POST &email=email&passwd=password&service=reader&source=appname&continue=http://www.google.com

from the response grab Auth=

Next hit: www.google.com/reader/api/0/token

HEADER Authorization=GoogleLogin auth=$Auth

That response becomes $token for the session.

From there it's just hitting some url's always passing that auth header and including the token in the querystring or post.

Gets a list of your subscriptions: www.google.com/reader/api/0/subscription/list?output=xml

To modify subscriptions this is the base url plus some post data for the action to perform

www.google.com/reader/api/0/subscription/edit?pos=0&client=$source

POST to add: s=$streams&t=$title&T=$token&ac=subscribe

POST to remove: s=$stream&T=$token&ac=unsubscribe

The $stream is generally feed/$feedurl like this for techcrunch, feed/http:// feeds.feedburner.com/Techcrunch

Sorry had to mangle some of the urls cause i don't have enough rep yet.

4
  • Thank you! It seems to be "easy" for me use the GR API for my PHP RSS Client. Do you have a demo of what you have built =) Commented Nov 6, 2010 at 22:15
  • Best example is this video I posted on youtube, youtube.com/watch?v=UWnb7o0utfA
    – smilbandit
    Commented Nov 7, 2010 at 3:22
  • Is there a way to add a subscription in Google Reader using the API? Thanks! Commented Jan 6, 2012 at 16:21
  • Would this approach still work after Google Reader was discontinued? Commented Mar 3, 2014 at 6:51
2

this is a working example in python:

import urllib, urllib2
import json, pprint

email, password = '[email protected]', 'nowayjose'
clientapp, service = 'reader', 'reader'

params = urllib.urlencode({'Email': email, 'Passwd': password, 'source': clientapp, 'service': service})
req = urllib2.Request(url='https://www.google.com/accounts/ClientLogin', data=params)
f = urllib2.urlopen(req)

for line in f.readlines():
  if line[0:5] == 'Auth=':
    auth=line[5:]

root = "http://www.google.com/reader/api/0/"

req = urllib2.Request(root + "token")
req.add_header('Authorization', 'GoogleLogin auth=' + auth)
f = urllib2.urlopen(req)
token = f.readlines()[0]

# get user id
req = urllib2.Request(root + "user-info?output=json&token="+token)
req.add_header('Authorization', 'GoogleLogin auth=' + auth)
f = urllib2.urlopen(req)
dictUser = json.loads(f.read())
user_id = dictUser["userId"]
print "user_id",user_id

req = urllib2.Request(root + "subscription/list?output=json&token="+token)
req.add_header('Authorization', 'GoogleLogin auth=' + auth)
f = urllib2.urlopen(req)

# for line in f.readlines():
#     print line
dictSubscriptions = json.loads(f.read())

# pprint.pprint(dictSubscriptions)
# print the first 3 subscription titles
for i in dictSubscriptions["subscriptions"][0:2]:
    print i["title"]

req = urllib2.Request("http://www.google.com/reader/api/0/unread-count?output=json&token="+token)
req.add_header('Authorization', 'GoogleLogin auth=' + auth)
f = urllib2.urlopen(req)
dictUnread = json.loads(f.read())
# pprint.pprint(dictUnread)
# print the first 3 unread folders
for i in dictUnread["unreadcounts"][0:3]:
    print i["count"], i["id"]

# this returns all starred items as xml
req = urllib2.Request("http://www.google.com/reader/atom/user/"+user_id+"/state/com.google/starred?token="+token)
req.add_header('Authorization', 'GoogleLogin auth=' + auth)
f = urllib2.urlopen(req)
starredItems = f.read()
0

Google Reader has feeds for user's. I guess you could use those. Also, they're PubSubHubbub ready, so you will get comments/likes... as soon as they happen.

Also, as of July 1st 2013, Google Reader is no more. Options for replacements include Superfeedr.

1
  • Yupp, know that =) But my users should be able to add/edit/remove feeds from within my app, and that feed should work like in Google Reader with the ability to comment, add notes, share, etc. Commented Oct 31, 2010 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.