Overview of the Digg API - Adding Digg Stats to Your Site
Embed:
Recently, Digg released an API for developers that makes much of its stored information publicly available.The developer simply sends a specially structured request to Digg's server and the server responds with the desired information. This info - usually delivered in XML - can be converted into a useful format.
How the Digg API Works
In technical terms, the Digg API works because the developer's server sends an HTTP Request to Digg's server. Digg's server follows a given protocol and sends an HTTP Response. Your server parses the data from a standard format and then let's you play with it.
In simpler terms, you send your server to visit a special website on Digg's server. An HTTP GET request - the type used by the Digg API - is just like going to a page called "http://www.digg.com/stories?mode=info&time=weekly."
What Goes In the URL?
The API lays out what needs to go in this specially structured URL. The URL starts with "http://services.digg.com/."
From there, you add what's called an "Endpoint." This is just an extra portion of the URL. A common endpoint would be "stories/topic/programming." Add that to the base URL, and you get the beginning of a request for stories in the programming category.
You then add a bunch of parameters to the end, like "?count=5&offset=10." This determines things like how many articles you get. The API lays out specifically what parameters you can and should use for each possible endpoint.
Put it In Action - Get a Random Article
One possible use for this is to get a random article from Digg's database and display it on your site. Sometimes good articles fall through the cracks - and if they aren't dugg a lot in the beginning, they'll quickly disappear.
By fetching random articles from the past couple of weeks, we might be able to find some diamonds in the rough that previously got overlooked. It also adds some content to our site that isn't floating around on everyone else's site that syndicates Digg's RSS feed.
You may also like...
- Introduction to PHP 5 and SimpleXML
- The Founder and Visionary of Digg.com, Kevin Rose: Internet Wizard or High-Tech Fraud?
- How to Digg Without Getting Your Digg Account Banned
- HD-DVD Scandal Could Spell the End of Digg.com
- How to Add "Digg It!" Button to Your WordPress Blog Posts
- How to Add Your Associated Content Videos to Digg.com
- How to Protect PHP Code
- How To Use vDeck Stats
- How to Add an Associated Content Article to Digg.com
- Digg.com Scandal Heats Up - No End of Corruption in Sight
Takeaways
- The Digg API makes tons of content and data available to you and your scripts.
- An HTTP Request is just a specially formatted URL - as documented in the API.
- You can use this to get a random article from Digg's database and create a link to it on your site.
Comments
Type in Your Comments Below - (1000 characters left)
Most Commented On


