PyDigg – A Python Toolkit for the Digg API

PyDigg is a Python toolkit for the Digg API. It provides an object-oriented interface to all of the available endpoints of the API. It is offered under the MIT License.

Download it here: (tar.gz | zip)

Over the years, I’ve used Python for various purposes. I’ve always found it to be a great language for just about anything, from a batch file alternative to web applications to scripting a real-time 3D application. It was therefore my pleasure to write a Python toolkit for the recently released Digg API.

Full documentation is coming soon, so in the meantime here are some guidelines for using this toolkit. I’m assuming that if you read past this point, you’re familiar with the Python programming language.

The toolkit is contained in one module (’’), made up of one class (’Digg’) with several nested classes. It depends on the standard Python libraries ‘urllib’ and ‘xml.dom’.

You will only ever have to instance the root class, ‘Digg’. From there it’s a matter of using that class instance’s methods to retrieve instances of nested classes such as ‘Story’, ‘User’, ‘Comment’, etc. The ‘Digg’ class contains all methods necessary to access data. Each nested class, such as ‘Story’, contains convenience methods that redirect back to the methods in “Digg”.

The following example outputs the titles of the latest stories submitted to Digg:

from digg import *
d = Digg(APPKEY) #insert your own application key string
stories = d.getStories()
for story in stories:
print story.title

In the above example, the Digg.getStories() method returns an instance of the ‘Stories’ container class, which contains n number of ‘Story’ instances. All response data from the Digg API is accessible by class properties. For instance, the ‘User’ class has the following properties: name, icon, registered, profileviews. I tried to align my naming conventions with those of the Digg API wherever possible.

Please send me links to anything you use this for. Also, if you’re interested in contributing to the PyDigg toolkit, feel free to contact me or join the Google Code Project.

Happy Programming!