Python client implementation for Digg's new writable API
Pull request Compare This branch is even with JeremyGrosser:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



# easy_install

easy_install will download and install python-digg and all of the required dependencies on it's own.

Required dependencies

Optional dependencies


Simple example

from digg.api import Digg
digg = Digg()

for story in digg.story.getPopular(count=20, topic='apple')['stories']:
    print story['title']
    print '%i diggs, %i comments' % (story['diggs'], story['comments'])

Caching example

from digg.api import Digg
import memcache

cache = memcache.Client([''])
digg = Digg(cache=cache)

OAuth example

Digg's API requires an OAuth access token in order to authenticate a user with certain methods (eg. story.digg). Note that this procedure is subject to change in future releases, especially the ugly parse_qs nonsense.

from urlparse import parse_qs
import sys

from oauth2 import Consumer, Token
from digg.api import Digg

consumer = Consumer(key='myoauthconsumerkey', secret='myoauthconsumersecret')
digg = Digg(oauth_consumer=consumer)

response = digg.oauth.getRequestToken(oauth_callback='oob')
request_token = parse_qs(response)
print 'Please visit the following URL to authorize this application'
print '' % request_token['oauth_token'][0]

sys.stdout.write('Type the verification number: ')
verifier = sys.stdin.readline().rstrip('\r\n')

request_token = Token(request_token['oauth_token'][0], request_token['oauth_token_secret'][0])

response = digg.oauth.getAccessToken(oauth_token=request_token)
response = parse_qs(response)

access_token = Token(response['oauth_token'][0], response['oauth_token_secret'][0])

print digg.oauth.verify(oauth_token=access_token)

print digg.story.digg(id=22091157, oauth_token=access_token)